Streamable HTTP client: a 401 or 403 with a JSON-RPC error body and no WWW-Authenticate loses its HTTP status
I maintainer di solito rispondono entro 3 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- authentication, backend
Direzione di ricerca
Leggi crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs, in particolare il ramo delle risposte non riuscite intorno alle righe 276–306 e i controlli precedenti per 401/403. Confronta la gestione con legacy_discover_response e il percorso di errore in testo semplice. Il lavoro è completato quando una risposta 401 o 403 con un corpo di errore JSON-RPC conserva lo stato HTTP per chi effettua le chiamate; esegui i test pertinenti del client HTTP Streamable.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When a Streamable HTTP server answers a POST with 401 Unauthorized (or 403 Forbidden) without a WWW-Authenticate header and with a JSON-RPC error body, the reqwest client returns Ok(StreamableHttpPostResponse::Json(..)). The caller then gets an ordinary JSON-RPC error, ClientInitializeError::JsonRpcError during initialize or ServiceError::McpError after it, and cannot tell that the server rejected the credentials.
Where
The non-success branch parses the body with parse_json_rpc_error before it looks at the status:
AuthRequired and InsufficientScope come only from the checks above it, which require WWW-Authenticate. The same 401 with a plain-text body becomes UnexpectedServerResponse("HTTP 401 Unauthorized: …"), so the status survives on that path but not on the JSON one.
Reproduce
rmcp 3.5.1 (main has the same code). The server answers initialize with:
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{"jsonrpc":"2.0","id":0,"error":{"code":-32001,"message":"Unauthorized"}}
serve_client over StreamableHttpClientTransport::with_client(reqwest::Client, config) fails with ClientInitializeError::JsonRpcError (code -32001, message "Unauthorized"). Nothing in the error says HTTP 401.
Why it matters
A client that sends a static token through custom_headers wants to tell the user that the token was rejected. An OAuth client wants to start or refresh authorization. Both need the status. The MCP authorization spec asks servers that implement authorization to send WWW-Authenticate with a 401, but a server that only takes a static token is not bound by that and may answer with a JSON-RPC error body instead.
Possible fixes
- Handle 401 and 403 before the JSON-RPC branch, as
legacy_discover_responsealready does ("Keep authentication failures and server errors on their original paths"). For example, returnAuthRequiredorInsufficientScopefor every 401 or 403, with the challenge optional, or returnUnexpectedServerResponse("HTTP 401 …")as the plain-text path does. - Or keep the JSON-RPC error and carry the HTTP status with it.
- Lingua principale
- Rust
- Stelle
- 4k
- Fork
- 662
- Merge medio
- 3g 10h
- PR unite (30g)
- 33
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun 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/rust-sdk
-
rmcp and rmcp-macros crates no longer include LICENSE (regression since 1.3.0)Forse già presa @Steeve-Crypto l’ha presa 1 giorno fa. Apertabug P2 ready for work T-config
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
modelcontextprotocol/rust-sdk#1335 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scopeForse già presa @jstar0 l’ha presa 4 giorni fa. Apertabug P1 ready for work T-security T-transport
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
modelcontextprotocol/rust-sdk#1330 ·
I maintainer di solito rispondono entro 3 giorni
-
P3 question Stale T-documentation T-enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
modelcontextprotocol/rust-sdk#1155 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
bug P1 ready for work T-handler T-model
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
modelcontextprotocol/rust-sdk#1347 ·
I maintainer di solito rispondono entro 3 giorni
-
A request whose `id` is not an i64 or a string is parsed as a notificationForse già presa @talhayme l’ha presa 1 giorno fa. Apertabug P1 ready for work T-core T-model
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
modelcontextprotocol/rust-sdk#1345 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di modelcontextprotocol/rust-sdk
Issue simili
-
Add MimirAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
slavakurilyak/awesome-ai-agents#759 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
compiler-explorer/compiler-explorer#9272 ·
I maintainer di solito rispondono entro 1 giorno
-
Trash, bin or rubbish?Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 63/100
pop-os/cosmic-files#2117 ·
I maintainer di solito rispondono entro 2 giorni
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
dependabot/dependabot-core#16547 ·
I maintainer di solito rispondono entro 1 giorno
-
bug status:ready-for-test
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
UniClipboard/UniClipboard#1985 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno