modelcontextprotocol / modelcontextprotocol/python-sdk
Streamable HTTP client logs a WARNING for valid 202 Accepted on session termination (DELETE)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in mcp/client/streamable_http.py at the DELETE session-termination response handling. Verify that a 202 response is treated as successful without a warning, while 405 remains a debug case and other unsuccessful statuses still warn; run the relevant client test suite if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100