Repository navigation
Conversation
A 401 on a request after initialize, such as call_tool, came back as ServiceError::TransportSend with source() returning None, so the WWW-Authenticate header could only be reached by matching the variant and walking the inner error by hand. Mark the TransportSend field as #[source] so the chain reaches the AuthRequiredError, and add ServiceError::auth_challenge() and ServiceError::is_authorization_required() to match ClientInitializeError. Fixes modelcontextprotocol#1458
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change exposing authorization challenges after initialization.
No open issues 🎉
What changed in this PR
This PR addresses #1458 by exposing authorization challenges on request failures after initialization, bringing ServiceError in line with the existing initialization-error API.
Changes:
- Preserves the standard error chain through
ServiceError::TransportSend. - Adds helpers to retrieve authentication challenges and detect authorization failures.
- Adds regression tests for a post-initialization 401 and a non-transport error.
| File | Description |
|---|---|
crates/rmcp/tests/test_streamable_http_call_auth_challenge.rs |
Tests challenge access, error-chain traversal, and non-transport behavior. |
crates/rmcp/src/service.rs |
Exposes the transport error source and adds authorization helpers. |
crates/rmcp/Cargo.toml |
Registers the new integration test with its required features. |
Review effort: Balanced
jokemanfire
approved these changes
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A 401 on a request made after a successful initialize, such as
call_tool, comes back asServiceError::TransportSend. Itssource()returnedNone, so theWWW-Authenticateheader was only reachable by matching the variant and walking the inner error by hand.Changes:
TransportSendfield as#[source](not#[from], so no newFromimpl). The chain below it was already intact, sosource()now reachesDynamicTransportErrorand thenAuthRequiredError.ServiceError::is_authorization_required(), which delegates toDynamicTransportError::is_authorization_required()forTransportSend.ServiceError::auth_challenge() -> Option<&str>, gated ontransport-streamable-http-client, mirroringClientInitializeError::auth_challenge.call_toolgets a 401 with a challenge. It checks both the header string fromauth_challenge()and thesource()chain down toAuthRequiredError. The test fails without the#[source]change.Behavior note:
source()onServiceError::TransportSendnow returnsSome(...)instead ofNone. That is the fix, but callers that inspect the error chain will see it. No existing test assertedsource().is_none()for this variant.ServiceErroris#[non_exhaustive], so the new methods are additive and no variants change.Fixes #1458