-
Notifications
You must be signed in to change notification settings - Fork 615
[BUG]: Server ID Context Dropped During Stateful Session/ Session Affinity Processing #2973
Copy link
Copy link
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)
Milestone
Description
🐞 Bug Summary
When use_stateful_sessions and mcpgateway_session_affinity_enabled are enabled, the
list_tools endpoint incorrectly returns tools from all servers instead of filtering by the specific server_id in the URL. This happens because the server ID context is lost during request processing in stateful sessions.
🧩 Affected Component
Select the area of the project impacted:
-
mcpgateway- API -
mcpgateway- UI (admin panel) -
mcpgateway.wrapper- stdio wrapper - Federation or Transports
- CLI, Makefiles, or shell scripts
- Container setup (Docker/Podman/Compose)
- Other (explain below)
🔁 Steps to Reproduce
- Enable stateful sessions in .env:
MCPGATEWAY_USE_STATEFUL_SESSIONS=true
MCPGATEWAY_SESSION_AFFINITY_ENABLED=true- Start the gateway.
- Make a request to a specific server's tools endpoint (e.g., http://localhost:8000/servers/server-id/mcp) and list the tools.
- Keep the session alive (or make enough requests to trigger session affinity).
- Observe that the response contains tools from other servers or an empty list (if default context is used), instead of the tools specific to .
🤔 Expected Behavior
The gateway should correctly identify the server_id from the URL, even in stateful sessions, and return ONLY the tools belonging to that specific server.
🧠 Environment Info
You can retrieve most of this from the /version endpoint.
| Key | Value |
|---|---|
| Version or commit | e.g. v0.9.0 or main@a1b2c3d |
| Runtime | e.g. Python 3.11, Gunicorn |
| Platform / OS | e.g. Ubuntu 22.04, macOS |
| Container | e.g. Docker, Podman, none |
🧩 Additional Context (optional)
Add any configuration details, flags, or related issues.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)