modelcontextprotocol / modelcontextprotocol/python-sdk
Streamable HTTP client logs a WARNING for valid 202 Accepted on session termination (DELETE)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 24.3k
- Fork
- 4k
- Merge medio
- 1g 1h
- PR unite (30g)
- 31
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in mcp/client/streamable_http.py, nella gestione della risposta DELETE per la terminazione della sessione. Verifica che una risposta 202 venga trattata come riuscita senza avvisi, mentre 405 rimanga un caso di debug e gli altri status non riusciti continuino a generare avvisi; esegui la suite di test pertinente del client, se disponibile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- api, networking
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 85/100