Skip to content

[Bug]: Fix Version Endpoint to Include Semantic Version (Not Just Git Revision) #369

@crivetimihai

Description

@crivetimihai

Fix Version Endpoint to Include Semantic Version (Not Just Git Revision)

Priority: Medium (API/Operations)

Description:
The /version endpoint currently only returns git revision information and is missing the semantic version number of the application. The version is already available via from mcpgateway import __version__ but is not being included in the version endpoint response.

Current Behavior:

  • /version endpoint returns app name, MCP protocol version, and git revision
  • No semantic version (e.g., "0.3.1") is displayed
  • Version information is incomplete for deployment tracking

Current Code in version.py:

"app": {
    "name": settings.app_name,
    "mcp_protocol_version": settings.protocol_version,
    "git_revision": _git_revision(),
},

Expected Behavior:

  • /version endpoint should include the semantic version from __version__
  • Version should be displayed in both JSON API responses and the Admin UI

Simple Implementation:

  1. Update version.py - Add import and include version in payload:
# Add to imports at top of version.py
from mcpgateway import __version__

# Update the app section in _build_payload function
"app": {
    "name": settings.app_name,
    "version": __version__,
    "mcp_protocol_version": settings.protocol_version,
    "git_revision": _git_revision(),
},
  1. Update the HTML template (templates/version_info_partial.html) to display the version:
<!-- Add to the app section of the template -->
<tr>
    <th>Version</th>
    <td>{{ payload.app.version }}</td>
</tr>
  1. Update the admin.js to properly display version in the UI:
// In the version info display section
if (data.app && data.app.version) {
    // Display the semantic version prominently
    const versionElement = document.createElement('div');
    versionElement.className = 'text-lg font-semibold mb-2';
    versionElement.textContent = `Version: ${data.app.version}`;
    // Insert at top of version panel
}

Complete Expected Response:

{
    "timestamp": "2025-01-11T12:00:00Z",
    "host": "hostname",
    "uptime_seconds": 3600,
    "app": {
        "name": "MCP_Gateway",
        "version": "0.3.1",  // Added from __version__
        "mcp_protocol_version": "2024-11-20",
        "git_revision": "abc123def"
    },
    "platform": {...},
    "database": {...},
    "redis": {...},
    "settings": {...},
    "env": {...},
    "system": {...}
}

Testing Requirements:

  • Verify /version endpoint returns the version from __version__
  • Test that version appears in JSON response
  • Verify version displays correctly in Admin UI version tab
  • Ensure version matches what's in mcpgateway/__init__.py

Benefits:

  • Clear version tracking for deployments using existing __version__
  • No need for complex version management systems
  • Minimal code changes required
  • Consistent with Python packaging best practices

Acceptance Criteria:

  • Version endpoint includes version field from __version__
  • Version displays in JSON API response
  • Version displays in Admin UI version tab
  • No breaking changes to existing version endpoint structure

Files to Modify:

  1. mcpgateway/version.py - Add import and version field
  2. templates/version_info_partial.html - Display version in HTML (if it exists)
  3. admin.js (optional) - Enhance version display in UI if needed

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfrontendFrontend development (HTML, CSS, JavaScript)pythonPython / backend development (FastAPI)triageIssues / Features awaiting triage

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions