Initial Checks
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
Initial Checks
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.
Expected behavior would be the active connections being closed with a proper http response before the rest of shutdown.
Example Code
Python & MCP Python SDK