Streamable HTTP client drops the HTTP status of an error response
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
- #3870 di @tang-ontheway — chiusa senza merge
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 70/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- api, networking
Direzione di ricerca
L'errore generico viene costruito in mcp/client/streamable_http.py, dove la risposta non 2xx viene convertita in un ErrorData con il messaggio "Server returned an error response". Inizia da lì e verifica quali valori della risposta (codice di stato, reason phrase, URL) sono ancora nel campo di visibilità in quel punto. Mantieni lo stato nel messaggio e in un campo dati come http_status, quindi conferma che un 401 e un 502 producono errori diversi nei test del client. Il lavoro è completato quando i chiamanti possono leggere lo stato senza un hook di risposta personalizzato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
When the server (or a proxy or gateway in front of it) answers a JSON-RPC request with a non-2xx status and no JSON-RPC error body, the streamable HTTP client replaces the response with a generic error:
# mcp/client/streamable_http.py (main and 2.3.0)
error_data = ErrorData(code=INTERNAL_ERROR, message="Server returned an error response")
The status code, reason phrase and URL are dropped, so a caller cannot tell a 401 from a 502 or a 504. Every non-404 HTTP failure reaches the caller as the same -32603 error.
Why it matters
- Callers cannot decide whether a failure is worth retrying (a gateway 502/503/504) or not (a 401, 403 or 413).
- Logs and user-facing errors cannot name the cause. We saw this with an install whose MCP URL went through an auth proxy: every call failed with a 401, and all we could log was "Server returned an error response".
Suggestion
Keep the HTTP status in the error, for example ErrorData(code=INTERNAL_ERROR, message=f"Server returned an error response ({status} {reason})", data={"http_status": status}), so callers can branch on it without a response hook of their own.
Versions
mcp 2.3.0 (checked against main as well).
- Lingua principale
- Python
- Stelle
- 25k
- Fork
- 4.2k
- Merge medio
- 10m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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.
Altre issue di modelcontextprotocol/python-sdk
-
v2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
modelcontextprotocol/python-sdk#3978 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Client serves cached tools after its context exits with an exceptionForse già presa @jonxsong l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
modelcontextprotocol/python-sdk#3968 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
modelcontextprotocol/python-sdk#3957 ·
I maintainer di solito rispondono entro 1 giorno
-
v2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
modelcontextprotocol/python-sdk#3934 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug v1
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
modelcontextprotocol/python-sdk#3929 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelcontextprotocol/python-sdk
Issue simili
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwiseForse già presa @abdulwaarith0 l’ha presa oggi. Apertaneeds-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
MakazhanAlpamys/Soup#3690 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug data-types native-format
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
ClickHouse/clickhouse-connect#1320 ·
I maintainer di solito rispondono entro 1 giorno
-
Public benchmark import end-to-end test fails when the test stack's worker runs the parity jobApertaaccepted
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
future-agi/future-agi#6392 ·
I maintainer di solito rispondono entro 1 giorno