Skip to content

Active Streamable HTTP sessions are not terminated during shutdown #2150

@emmahoggan

Description

@emmahoggan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions