Streamable HTTP client stays closed after an interrupted response and raises ExceptionGroup on cleanup
還沒有人認領這個 Issue。
評估
研究方向
從 mcp.client.streamable_http 中的 streamable_http_client 入口點開始,並針對 mcp-failure-lab 執行提供的 repro.py。追蹤中斷的斷線回應如何影響用戶端和工作群組清理;當斷線失敗得到回報、同一個用戶端上的後續 ping 成功,且離開內容脈絡時不會引發 ExceptionGroup,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Description
With the current 2.x release, one interrupted Streamable HTTP tool response permanently closes the Python client session. The failing request is reported, but a subsequent normal request on the same client fails with MCPError: Connection closed. Exiting streamable_http_client(...) then raises an unhandled ExceptionGroup from its background task group.
The same MCP server remains healthy. Under the identical sequence, @modelcontextprotocol/sdk@1.30.0 reports the interrupted request and successfully completes the next ping on the same client.
Expected behavior
The interrupted request should fail, while a subsequent request should be able to use a fresh HTTP connection and succeed. Transport cleanup should not raise an additional ExceptionGroup.
Actual behavior
disconnectinterrupts its active HTTP response.- Python reports the request failure.
- A following
pingfails immediately withMCPError: Connection closed. - Context cleanup raises
ExceptionGroup: unhandled errors in a TaskGroupwhose nested cause ishttpx2.RemoteProtocolError: Server disconnected without sending a response.
Comparison
The official TypeScript client 1.30.0 receives TypeError: fetch failed for the deliberately interrupted request, then successfully sends ping through the same client. This suggests the server remains available and the problem is in Python client recovery/cleanup.
I also searched the existing issues. #3494 concerns a server-side incomplete SSE body during initialize, and #3441 concerns an unresolved 1.x request; neither appears to cover this v2 same-client recovery failure.
Minimal reproduction
# Terminal 1
npx mcp-failure-lab@0.9.0 serve --transport http --host 127.0.0.1 --port 43118 --path /mcp
# Terminal 2: save as repro.py, then run: python repro.py
import anyio
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
URL = "http://127.0.0.1:43118/mcp"
async def main():
try:
async with streamable_http_client(URL) as streams:
async with ClientSession(
streams[0], streams[1], read_timeout_seconds=1.0
) as session:
await session.initialize()
try:
await session.call_tool(
"disconnect", {}, read_timeout_seconds=0.6
)
except BaseException as error:
print("disconnect:", type(error).__name__, error)
# Expected: succeeds. Actual: MCPError: Connection closed
print("ping:", await session.call_tool("ping", {}))
except BaseException as error:
# Actual: ExceptionGroup from streamable_http_client cleanup
print("cleanup:", type(error).__name__, error)
anyio.run(main)
Environment
Python 3.12.14; mcp 2.2.0; macOS arm64. Server: mcp-failure-lab 0.9.0; protocol 2026-07-28.
- 主要語言
- Python
- 星號
- 24.3k
- 分支
- 4k
- 平均合併
- 1 天 1 小時
- 30 天內合併 PR
- 31
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/python-sdk 的其他 Issue
-
v1 v2
難度 2/5 1-3 小時 新手友好度 85/100
modelcontextprotocol/python-sdk#3546 · 4 則留言 ·
-
v1 v2
難度 2/5 1-3 小時 新手友好度 76/100
modelcontextprotocol/python-sdk#3545 · 1 則留言 ·
-
v1 v2
難度 1/5 1 小時以內 新手友好度 91/100
modelcontextprotocol/python-sdk#3508 · 2 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 64/100
modelcontextprotocol/python-sdk#3504 ·
-
v1 v2
難度 2/5 1-3 小時 新手友好度 82/100
modelcontextprotocol/python-sdk#3492 · 1 則留言 ·
查看 modelcontextprotocol/python-sdk 的全部 Issue
相似的 Issue
-
link-check link-check:sphinx-theme
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難度 2/5 1-3 小時 新手友好度 88/100
OpenHands/extensions#626 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
CSCfi/sd-search-api#39 ·
-
難度 1/5 1 小時以內 新手友好度 90/100