-
Notifications
You must be signed in to change notification settings - Fork 240
Labels
bugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)triageIssues / Features awaiting triageIssues / Features awaiting triage
Milestone
Description
Bug: API incorrectly shows hardcoded version "1.0.0" instead of semantic version from version
Summary
When UI is disabled (MCPGATEWAY_UI_ENABLED=False
), the root API endpoint returns a hardcoded version "1.0.0" instead of using the semantic version from the __version__
variable. This causes version mismatch and inconsistency across the application. Example:
{"name":"MCP_Gateway","version":"1.0.0","description":"MCP_Gateway API - UI is disabled","ui_enabled":false,"admin_api_enabled":false}
Check test cases and other components that have a hard coded 1.0.0 version..
Affected Component
-
mcpgateway
- API (main.py) - Federation/Discovery service (discovery.py)
Steps to Reproduce
- Set
MCPGATEWAY_UI_ENABLED=False
in environment variables - Start the MCP Gateway
- Access the root endpoint (
GET /
) - Observe the returned JSON shows
"version": "1.0.0"
regardless of actual version
Expected Behavior
The API should return the actual semantic version from __version__
variable, matching the version shown in other parts of the application (e.g., /version
endpoint, wrapper server info).
Current Code (main.py)
from mcpgateway import __version__ # Already imported at the top
# ... later in the file ...
@app.get("/")
async def root_info():
"""
Returns basic API information at the root path.
...
"""
logger.info("UI disabled, serving API info at root path")
return {
"name": settings.app_name,
"version": "1.0.0", # ❌ Hardcoded version
"description": f"{settings.app_name} API - UI is disabled",
"ui_enabled": False,
"admin_api_enabled": ADMIN_API_ENABLED
}
Fixed Code (main.py)
@app.get("/")
async def root_info():
"""
Returns basic API information at the root path.
...
"""
logger.info("UI disabled, serving API info at root path")
return {
"name": settings.app_name,
"version": __version__, # ✅ Use imported __version__
"description": f"{settings.app_name} API - UI is disabled",
"ui_enabled": False,
"admin_api_enabled": ADMIN_API_ENABLED
}
Additional Instances Found
1. discovery.py - LocalDiscoveryService
# Current code (line ~66)
self._service_info = ServiceInfo(
self._service_type,
f"{settings.app_name}.{self._service_type}",
addresses=[socket.inet_aton(addr) for addr in self._get_local_addresses()],
port=settings.port,
properties={
"name": settings.app_name,
"version": "1.0.0", # ❌ Hardcoded version
"protocol": PROTOCOL_VERSION,
},
)
# Should be:
from mcpgateway import __version__ # Add import at top
# Then use:
properties={
"name": settings.app_name,
"version": __version__, # ✅ Use imported __version__
"protocol": PROTOCOL_VERSION,
}
Files to Check/Update
- ✅ main.py - root_info() function
- ✅ discovery.py - LocalDiscoveryService.init() method
- ❓ Any other files that might reference "1.0.0" as a version string
Impact
- Version inconsistency between different endpoints
- Misleading version information for API consumers
- Difficult to track actual deployed version when UI is disabled
- Service discovery broadcasts incorrect version information
Environment Info
- Version: Issue present in current main branch
- Component: mcpgateway API and discovery services
Additional Notes
The __version__
variable is already being correctly imported and used in other parts of the codebase (e.g., wrapper.py), so this fix aligns with existing patterns and ensures consistency across all version reporting.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)triageIssues / Features awaiting triageIssues / Features awaiting triage