Skip to content

Commit 7ae7d89

Browse files
authored
Remove git version from mcpgateway.version and web ui (#418)
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 7997da7 commit 7ae7d89

File tree

3 files changed

+6
-63
lines changed

3 files changed

+6
-63
lines changed

mcpgateway/templates/version_info_partial.html

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,11 @@ <h2 class="text-2xl font-bold mb-4 flex items-center">
3030
</div>
3131
</div>
3232

33-
{% if payload.app.version or payload.app.git_revision %}
33+
{% if payload.app.version %}
3434
<div class="mt-4 pt-4 border-t border-blue-300">
35-
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
36-
{% if payload.app.version %}
37-
<div class="text-center">
38-
<div class="text-lg font-medium">Version</div>
39-
<div class="text-blue-100 font-mono text-sm">{{ payload.app.version }}</div>
40-
</div>
41-
{% endif %}
42-
{% if payload.app.git_revision %}
43-
<div class="text-center">
44-
<div class="text-lg font-medium">Git Revision</div>
45-
<div class="text-blue-100 font-mono text-sm">{{ payload.app.git_revision }}</div>
46-
</div>
47-
{% endif %}
35+
<div class="text-center">
36+
<div class="text-lg font-medium">Version</div>
37+
<div class="text-blue-100 font-mono text-sm">{{ payload.app.version }}</div>
4838
</div>
4939
</div>
5040
{% endif %}

mcpgateway/version.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
- Cross-platform system metrics (Windows/macOS/Linux), with fallbacks where APIs are unavailable
1414
- Optional dependencies: psutil (for richer metrics) and redis.asyncio (for Redis health); omitted gracefully if absent
1515
- Authentication enforcement via `require_auth`; unauthenticated browsers see login form, API clients get JSON 401
16-
- Redacted environment variables, sanitized DB/Redis URLs, Git commit detection
16+
- Redacted environment variables, sanitized DB/Redis URLs
17+
1718
"""
1819

1920
# Future
@@ -25,7 +26,6 @@
2526
import os
2627
import platform
2728
import socket
28-
import subprocess
2929
import time
3030
from typing import Any, Dict, Optional
3131
from urllib.parse import urlsplit, urlunsplit
@@ -89,26 +89,6 @@ def _public_env() -> Dict[str, str]:
8989
return {k: v for k, v in os.environ.items() if not _is_secret(k)}
9090

9191

92-
def _git_revision() -> Optional[str]:
93-
"""
94-
Retrieve the current Git revision (short) if available.
95-
96-
Returns:
97-
Optional[str]: The Git commit hash prefix or None if unavailable.
98-
"""
99-
rev = os.getenv("GIT_COMMIT")
100-
if rev:
101-
return rev[:9]
102-
try:
103-
out = subprocess.check_output(
104-
["git", "rev-parse", "--short", "HEAD"],
105-
stderr=subprocess.DEVNULL,
106-
)
107-
return out.decode().strip()
108-
except Exception:
109-
return None
110-
111-
11292
def _sanitize_url(url: Optional[str]) -> Optional[str]:
11393
"""
11494
Redact credentials from a URL for safe display.
@@ -261,7 +241,6 @@ def _build_payload(
261241
"name": settings.app_name,
262242
"version": __version__,
263243
"mcp_protocol_version": settings.protocol_version,
264-
"git_revision": _git_revision(),
265244
},
266245
"platform": {
267246
"python": platform.python_version(),

tests/unit/mcpgateway/test_version.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def _build_app(monkeypatch: pytest.MonkeyPatch, auth_ok: bool = True) -> FastAPI
8282
# Stub heavy helpers
8383
monkeypatch.setattr(ver_mod, "_database_version", lambda: ("db-vX", True))
8484
monkeypatch.setattr(ver_mod, "_system_metrics", lambda: {"stub": True})
85-
monkeypatch.setattr(ver_mod, "_git_revision", lambda: "deadbeef")
8685
monkeypatch.setattr(ver_mod, "REDIS_AVAILABLE", False, raising=False)
8786

8887
# Auth override
@@ -114,7 +113,6 @@ def test_version_json_ok(client: TestClient) -> None:
114113
payload: Dict[str, Any] = rsp.json()
115114
assert payload["database"]["server_version"] == "db-vX"
116115
assert payload["system"] == {"stub": True}
117-
assert payload["app"]["git_revision"] == "deadbeef"
118116

119117

120118
def test_version_html_query_param(client: TestClient) -> None:
@@ -167,30 +165,6 @@ def test_sanitize_url() -> None:
167165
assert ver_mod._sanitize_url(url) == "postgres://u@host:5432/db"
168166

169167

170-
def test_git_revision_env(monkeypatch: pytest.MonkeyPatch) -> None:
171-
# First-Party
172-
from mcpgateway import version as ver_mod
173-
174-
monkeypatch.setenv("GIT_COMMIT", "0123456789abcdef")
175-
assert ver_mod._git_revision() == "012345678"
176-
177-
178-
def test_git_revision_subprocess(monkeypatch: pytest.MonkeyPatch) -> None:
179-
"""Ensure subprocess branch returns short hash."""
180-
# First-Party
181-
from mcpgateway import version as ver_mod
182-
183-
# Remove env override
184-
monkeypatch.delenv("GIT_COMMIT", raising=False)
185-
186-
fake_subprocess = types.SimpleNamespace(
187-
check_output=lambda *a, **kw: b"abc123\n",
188-
DEVNULL=-3, # needed by _git_revision
189-
)
190-
monkeypatch.setattr(ver_mod, "subprocess", fake_subprocess)
191-
assert ver_mod._git_revision() == "abc123"
192-
193-
194168
# --------------------------------------------------------------------------- #
195169
# _database_version branches #
196170
# --------------------------------------------------------------------------- #

0 commit comments

Comments
 (0)