-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
Context
This is primarily a repost of this fastmcp issue as it seems to actually be a bug in the mcp python sdk and I want to make sure we've got visibility over here.
When shutting down a FastMCP server (CTRL+C) while clients have active streaming connections, Uvicorn logs:
ERROR: ASGI callable returned without completing response.The error occurs because StreamableHTTPSessionManager cancels the task group without first gracefully terminating active SSE/streaming connections.
Expected behavior would be the active connections being closed with a proper http response before the rest of shutdown.
Example Code
from fastmcp import FastMCP
mcp = FastMCP("Test Server")
@mcp.tool
def hello() -> str:
return "Hello, World!"
if __name__ == "__main__":
mcp.run(transport="streamable-http", port=8000)Python & MCP Python SDK
Python 3.12
MCP Python SDK 1.26.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels