Client tool call hangs forever if server crashes or connection dies when using streamable-http
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 冷清
- 技術堆疊
- python
- 領域
- api, networking
研究方向
從 streamablehttp_client 進入點和 client.py 中顯示的 ClientSession.call_tool 路徑開始,然後重現工具呼叫期間 server.py 的當機。當伺服器在回應前結束時,客戶端回報連線失敗而不是永遠等待,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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
If the server dies during a tool call before it sends a response the client will get stuck forever.
Example Code
# server.py
from mcp.server.fastmcp import FastMCP
import sys
mcp = FastMCP("StatefulServer")
@mcp.tool()
def greet(name: str = "World") -> str:
"""Greet someone by name."""
sys.exit(0)
return f"Hello, {name}!"
if __name__ == "__main__":
mcp.run(transport="streamable-http")
# client.py
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def main():
# Connect to a streamable HTTP server
async with streamablehttp_client("http://localhost:8000/mcp") as (
read_stream,
write_stream,
_,
):
# Create a session using the client streams
async with ClientSession(read_stream, write_stream) as session:
# Initialize the connection
await session.initialize()
res = await session.call_tool("greet", {"name": "World"})
print(res)
if __name__ == "__main__":
asyncio.run(main())
# Run server.py then client.py
# client.py will hang forever in the tool call and never complete. I would expect it to throw an error since the connection died and it will never get a response.
Python & MCP Python SDK
Python 3.13.7
mcp 1.20.0
- 主要語言
- Python
- 星號
- 24.4k
- 分支
- 4k
- 平均合併
- 2 天 9 小時
- 30 天內合併 PR
- 23
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/python-sdk 的其他 Issue
-
P3
難度 2/5 1-3 小時 新手友好度 78/100
modelcontextprotocol/python-sdk#3597 · 1 則留言 ·
維護者通常 1 天內回覆
-
v1 v2
難度 2/5 1-3 小時 新手友好度 68/100
modelcontextprotocol/python-sdk#3592 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 88/100
modelcontextprotocol/python-sdk#3590 ·
維護者通常 1 天內回覆
-
v1 v2
難度 2/5 1-3 小時 新手友好度 86/100
modelcontextprotocol/python-sdk#3589 ·
維護者通常 1 天內回覆
-
v1 v2
難度 2/5 1-3 小時 新手友好度 84/100
modelcontextprotocol/python-sdk#3585 · 1 則留言 ·
維護者通常 1 天內回覆
查看 modelcontextprotocol/python-sdk 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
BasedHardware/omi#20271 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 92/100
openai/openai-cookbook#3153 ·
維護者通常 1 天內回覆
-
cvss-severity:high devguard l3montree-cybersecurity/devguard/devguard pkg:golang/github.com/l3montree-dev/devguard risk:low state:open
難度 2/5 1-3 小時 新手友好度 65/100
l3montree-dev/devguard#3146 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
-
bug confirmed issue
難度 2/5 1-3 小時 新手友好度 76/100
open-webui/open-webui#31849 · 2 則留言 ·
維護者通常 1 天內回覆