🐞 Bug Summary
Virtual servers configured with tools from an OAuth2-authenticated MCP server lose their tool associations after some time. The tools become unlinked from the virtual server even though the MCP server remains online.
🧩 Affected Component
🔁 Steps to Reproduce
- Connect an MCP server that uses OAuth2 authentication
- Authorize user and fetch tools from the MCP server
- Create a virtual server
- Associate tools from the OAuth2-authenticated MCP server with the virtual server
- Wait some time (hours/days)
- View the virtual server configuration
- Observe: Tools are no longer linked to the virtual server
- Note: The MCP server shows as online in the MCP servers list
🤔 Expected Behavior
Tools associated with a virtual server should remain linked until explicitly removed, regardless of:
- OAuth2 token refresh cycles
- MCP server reconnections
- Gateway restarts
🔍 Investigation Needed
- Token expiration handling: Does OAuth2 token refresh affect tool registration?
- Tool ID stability: Do tool IDs change after token refresh?
- Database relationships: Are foreign keys maintained correctly?
- Background jobs: Is there a cleanup job removing associations?
Files to Check
mcpgateway/services/server_service.py - Virtual server tool management
mcpgateway/services/gateway_service.py - OAuth2 connection handling
mcpgateway/services/tool_service.py - Tool registration/refresh
📓 Logs / Error Output
(Add any relevant logs when reproducing)
🧠 Environment Info
| Key |
Value |
| Version or commit |
1.0.0-BETA-2 |
| Runtime |
Python 3.11, Gunicorn |
| Platform / OS |
Ubuntu 22.04 |
| Container |
Docker |
✅ Acceptance Criteria
🐞 Bug Summary
Virtual servers configured with tools from an OAuth2-authenticated MCP server lose their tool associations after some time. The tools become unlinked from the virtual server even though the MCP server remains online.
🧩 Affected Component
mcpgateway- APImcpgateway- UI (admin panel)mcpgateway.wrapper- stdio wrapper🔁 Steps to Reproduce
🤔 Expected Behavior
Tools associated with a virtual server should remain linked until explicitly removed, regardless of:
🔍 Investigation Needed
Files to Check
mcpgateway/services/server_service.py- Virtual server tool managementmcpgateway/services/gateway_service.py- OAuth2 connection handlingmcpgateway/services/tool_service.py- Tool registration/refresh📓 Logs / Error Output
(Add any relevant logs when reproducing)
🧠 Environment Info
✅ Acceptance Criteria