33** Date:** 2026-07-27
44** Issue:** [ #795 ] ( https://github.com/modelcontextprotocol/rust-sdk/issues/795 )
55** Goal:** Let clients detect that MCP initialization requires re-authorization without downcasting a transport-specific error or matching multiple internal variants. Preserve the existing error details and ` WWW-Authenticate ` challenge.
6- ** Status:** In progress
6+ ** Status:** Complete
77
88## Context
99
@@ -51,12 +51,12 @@ impl ClientInitializeError {
5151
5252| File | Role | Status |
5353| --- | --- | --- |
54- | ` crates/rmcp/src/transport/streamable_http_client.rs ` | Make the HTTP 401 detail error visible through the standard source chain | Modify |
55- | ` crates/rmcp/src/transport.rs ` | Add transport-independent authorization-required classification | Modify |
56- | ` crates/rmcp/src/service/client.rs ` | Add the initialization-error convenience predicate | Modify |
57- | ` crates/rmcp/tests/test_auth_error_classification.rs ` | Exercise the public API and guard false positives | New |
58- | ` crates/rmcp/Cargo.toml ` | Declare the feature-gated integration test | Modify |
59- | ` docs/OAUTH_SUPPORT.md ` | Show callers how to branch back into authorization | Modify |
54+ | ` crates/rmcp/src/transport/streamable_http_client.rs ` | Make the HTTP 401 detail error visible through the standard source chain | Complete |
55+ | ` crates/rmcp/src/transport.rs ` | Add transport-independent authorization-required classification | Complete |
56+ | ` crates/rmcp/src/service/client.rs ` | Add the initialization-error convenience predicate | Complete |
57+ | ` crates/rmcp/tests/test_auth_error_classification.rs ` | Exercise the public API and guard false positives | Complete |
58+ | ` crates/rmcp/Cargo.toml ` | Declare the feature-gated integration test | Complete |
59+ | ` docs/OAUTH_SUPPORT.md ` | Show callers how to branch back into authorization | Complete |
6060
6161## Tasks
6262
@@ -100,7 +100,7 @@ impl ClientInitializeError {
100100
101101- [x] Callers do not need the transport type, backend error type, or a downcast.
102102- [x] Direct and multiply wrapped matching errors are recognized.
103- - [ ] Feature-disabled builds compile; feature-specific checks are guarded locally.
103+ - [x ] Feature-disabled builds compile; feature-specific checks are guarded locally.
104104- [x] Unknown custom transport errors return false.
105105- [x] The method is documented as a classification predicate, not an authorization action.
106106
@@ -114,7 +114,7 @@ impl ClientInitializeError {
114114
115115- [x] The issue's caller can replace its downcast helper with ` error.is_authorization_required() ` .
116116- [x] JSON-RPC, protocol negotiation, connection-closed, and cancellation failures return false.
117- - [ ] The method remains available consistently across client builds.
117+ - [x ] The method remains available consistently across client builds.
118118
119119### 5. Document the recovery pattern
120120
@@ -150,13 +150,13 @@ Explain that the predicate covers both missing/expired local authorization and a
150150
151151** Acceptance criteria:**
152152
153- - [ ] ` cargo test -p rmcp --test test_auth_error_classification --no-default-features --features "auth,client,transport-streamable-http-client" ` passes.
154- - [ ] ` cargo check -p rmcp --no-default-features --features client ` passes.
155- - [ ] ` cargo check -p rmcp --no-default-features --features "client,transport-streamable-http-client" ` passes.
156- - [ ] ` cargo test -p rmcp --all-features ` passes.
157- - [ ] ` cargo clippy -p rmcp --all-targets --all-features -- -D warnings ` passes.
158- - [ ] ` cargo fmt --all --check ` passes.
159- - [ ] The public change is additive and does not require a SemVer exemption.
153+ - [x ] ` cargo test -p rmcp --test test_auth_error_classification --no-default-features --features "auth,client,transport-streamable-http-client" ` passes.
154+ - [x ] ` cargo check -p rmcp --no-default-features --features client ` passes.
155+ - [x ] ` cargo check -p rmcp --no-default-features --features "client,transport-streamable-http-client" ` passes.
156+ - [x ] ` cargo test -p rmcp --all-features ` passes.
157+ - [x ] ` cargo clippy -p rmcp --all-targets --all-features -- -D warnings ` passes.
158+ - [x ] ` cargo fmt --all --check ` passes.
159+ - [x ] The public change is additive and does not require a SemVer exemption.
160160
161161## Open Questions
162162
0 commit comments