modelcontextprotocol / modelcontextprotocol/python-sdk
Streamable HTTP client logs a WARNING for valid 202 Accepted on session termination (DELETE)
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 24.3k
- 分支
- 4k
- 平均合併
- 1 天 1 小時
- 30 天內合併 PR
- 31
描述
Problem
mcp/client/streamable_http.py treats any DELETE session-termination response outside {200, 204} as a failure and logs:
WARNING mcp.client.streamable_http: Session termination failed: 202
But 202 Accepted is a valid, spec-compliant response for an asynchronous delete — the server accepted the request and will process it later. The current code path:
if response.status_code == 405:
logger.debug("Server does not allow session termination")
elif response.status_code not in (200, 204):
logger.warning(f"Session termination failed: {response.status_code}")
Evidence
A long-running Hermes Agent (NousResearch) deployment with several Streamable HTTP MCP servers accumulated 72 Session termination failed: 202 warnings in ~36 hours in errors.log — pure noise from servers that correctly answer 202 to asynchronous termination. Real failures (connection errors) also surface through this same line, so the constant false positives bury the signal.
Suggested fix
Treat 2xx as success on termination, e.g.:
if response.status_code == 405:
logger.debug("Server does not allow session termination")
elif 200 <= response.status_code < 300:
pass # 200/202/204 all acceptable
else:
logger.warning(f"Session termination failed: {response.status_code}")
Environment
mcpPython SDK (client, streamable HTTP transport), observed on recent Hermes 0.21.x installs- Servers: multiple Streamable HTTP MCP endpoints (remote + local)
Happy to send a PR if the direction is agreed.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 mcp/client/streamable_http.py 中 DELETE 工作階段終止回應的處理部分開始。驗證 202 回應會被視為成功且不會發出警告,同時 405 仍作為 debug 情況處理,其他不成功的狀態仍會發出警告;如果相關 client 測試套件可用,請執行它。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- api, networking
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 85/100