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