rust-sdk/crates/rmcp/src
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jeremy Schoemaker c345078867
fix(auth): map 401/403 challenges on the SSE GET stream (#1152)
`post_message_with_max_sse_event_size` turns a 401 or 403 carrying a
`WWW-Authenticate` header into `StreamableHttpError::AuthRequired` /
`InsufficientScope`. `get_stream_with_max_sse_event_size`, in the same file,
handles only 405 and then falls through to `error_for_status()?`, so the same
challenge becomes an opaque `StreamableHttpError::Client`.

That matters because `AuthClient::get_stream` routes through
`call_reacting_to_challenges`, whose whole purpose is to catch `AuthRequired`,
run `try_refresh_or_reauth()`, and retry once. It never sees that variant from
this path, so an expired token on the standalone SSE stream is never refreshed —
the stream just fails, while the identical expiry on `post_message` recovers
silently.

Copies the two blocks verbatim from `post_message` in the same file.
`unix_socket.rs` already does the same thing in its own `get_stream`.

Adds four tests against an axum mock server: a 401 with a challenge maps to
`AuthRequired`, a 403 maps to `InsufficientScope` with the scope extracted, a
401 *without* a challenge is still not `AuthRequired`, and 405 keeps reporting
`ServerDoesNotSupportSse`. The first two fail before this change with
`Err(Client(reqwest::Error { kind: Status(401, None) }))`; the last two pass
either way and exist to catch an over-broad fix.
2026-08-07 15:39:55 -04:00
..
handler fix: expose MRTR state to tool handlers (#1104) 2026-08-05 09:55:09 -04:00
model fix(model): decode metadata-bearing input-required results affecting mrtr (#1097) 2026-07-31 09:23:56 -04:00
service feat: classify authorization-required errors (#1056) 2026-07-31 09:00:23 -04:00
transport fix(auth): map 401/403 challenges on the SSE GET stream (#1152) 2026-08-07 15:39:55 -04:00
error.rs refactor!: remove deprecated v3 APIs (#1066) 2026-07-28 14:01:56 -04:00
handler.rs fix: remove unnecessary doc-cfg (#661) 2026-02-17 10:07:40 -05:00
lib.rs refactor!: remove deprecated v3 APIs (#1066) 2026-07-28 14:01:56 -04:00
model.rs fix: disambiguate input-required results (#1103) 2026-08-03 12:54:59 -04:00
service.rs fix: honor supported_protocol_versions when negotiating initialize (#1093) 2026-07-30 15:44:37 -04:00
task_manager.rs feat: route SEP-2260 associated server requests to the originating SSE stream (#1029) 2026-07-23 13:12:20 -04:00
transport.rs feat: classify authorization-required errors (#1056) 2026-07-31 09:00:23 -04:00