modelcontextprotocol / modelcontextprotocol/python-sdk
Active Streamable HTTP sessions are not terminated during shutdown
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 24.3k
- フォーク
- 4k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 31
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
StreamableHTTPSessionManager の shutdown 処理から始め、Python 3.12 で streamable-http の例を使って問題を再現します。アクティブな SSE 接続またはストリーミング接続がどのようにキャンセルされるかを追跡し、その後、shutdown によって適切な HTTP レスポンスとともに接続が閉じられ、Uvicorn ASGI エラーが発生しないことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100