Streamable HTTP client: a 401 or 403 with a JSON-RPC error body and no WWW-Authenticate loses its HTTP status
メンテナーはふだん 3 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
crates/rmcp/src/transport/common/reqwest/streamable_http_client.rsを読み、特に276~306行付近の成功以外のレスポンス分岐と、その前にある401/403のチェックを確認してください。処理をlegacy_discover_responseおよびプレーンテキストのエラーパスと比較してください。401または403のレスポンスにJSON-RPCエラーボディが含まれる場合に、呼び出し元がHTTPステータスを保持できることを完了条件とし、関連するStreamable HTTPクライアントのテストを実行してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Rust
- スター
- 4k
- フォーク
- 654
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 37
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/rust-sdk のほかの issue
-
bug P2 ready for work T-config
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/rust-sdk#1335 ·
メンテナーはふだん 3 日以内に返信
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scope対応中かも @jstar0 が 2 日前に担当しました。 オープンbug P1 ready for work T-security T-transport
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
modelcontextprotocol/rust-sdk#1330 ·
メンテナーはふだん 3 日以内に返信
-
P3 question Stale T-documentation T-enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
modelcontextprotocol/rust-sdk#1155 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
enhancement P2 ready for work T-service
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
modelcontextprotocol/rust-sdk#1338 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Non-object outputSchema and structuredContent are sent to clients that negotiated 2025-06-18 / 2025-11-25, where an object is required対応中かも @Cassian433 が今日担当しました。 オープンbug P1 ready for work T-handler T-model
難易度 3/5 1〜2日 初心者へのやさしさ 28/100
modelcontextprotocol/rust-sdk#1337 ·
メンテナーはふだん 3 日以内に返信
modelcontextprotocol/rust-sdk の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
MattA-Official/vwmcp#20 ·
-
documentation good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
undergroundrap/hatchling#15 ·
-
Progress difficulty filter lists Hard before Medium対応中かも @Pandamachi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
sysprog21/codetrial#281 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
CLI: --verdict silently ignores extra program/file arguments対応中かも @oxura が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
HigherOrderCO/Bend#1503 ·
-
Add MySQL test coverage for numeric_precision/numeric_scale and seq_in_fk (follow-up to #939)対応中かも @tosinxt が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TabularisDB/tabularis#977 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信