Skip to content

Active Streamable HTTP sessions are not terminated during shutdown #2150

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions