-
Notifications
You must be signed in to change notification settings - Fork 559
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using FastAPI-MCP with SSE connections active, Uvicorn's reload functionality gets stuck during shutdown phase, requiring manual process termination. This severely impacts development workflow.
To Reproduce
- Create minimal FastAPI app
main.py
with MCP mounted:
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP
app = FastAPI()
mcp = FastApiMCP(app)
# Mount the MCP server directly to your FastAPI app
mcp.mount()
- Start server with reload:
uvicorn --reload --port 9000 main:app
Open browser to SSE endpoint: http://localhost:9000/mcp
and hold on:

- Modify any file (e.g. main.py) to trigger reload
Expected Behavior:
Server should:
- Detect file changes
- Gracefully close existing connections
- Restart with new code
Actual Behavior:
Server hangs at shutdown phase:
INFO: Shutting down
INFO: Waiting for connections to close. (CTRL+C to force quit)
System Information:
fastapi==0.115.12
fastapi-mcp==0.3.6
uvicorn==0.34.2
Python==3.12.10
OS: Linux
Proposed Solutions:
- Add proper SSE connection tracking in FastAPI-MCP
- Implement graceful shutdown handler for SSE
- Provide API to manually close connections before reload
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working