-
Notifications
You must be signed in to change notification settings - Fork 469
Description
Describe the bug
With streamable HTTP, when a client sends a stale/invalid mcp-session-id, the server returns 401 Unauthorized plain text without Content-Type. The reqwest streamable client then surfaces this as StreamableHttpError::UnexpectedContentType(None) instead of a status-aware error that preserves the real failure context (401 session not found).
To Reproduce
Steps to reproduce the behavior:
- Start a stateful
StreamableHttpService. - Send
POST /mcpwith headers:Accept: application/json, text/event-streamContent-Type: application/jsonmcp-session-id: stale-session-id
- Send any valid JSON-RPC request body (for example ping/tool call).
- Observe raw HTTP response is
401 Unauthorizedwith bodyUnauthorized: Session not foundand missingContent-Type. - Observe reqwest streamable client error is
UnexpectedContentType(None).
Expected behavior
For non-success HTTP responses, the streamable reqwest client should return a status-aware transport error (including HTTP status and response body), not a content-type parsing error.
Logs
Raw HTTP from stale session path:
- status:
401 Unauthorized - body:
Unauthorized: Session not found Content-Type: missing
Current client error:
StreamableHttpError::UnexpectedContentType(None)
Validation commands run against patch branch:
cargo test -p rmcp --test test_streamable_http_stale_session --features "client server transport-streamable-http-client-reqwest transport-streamable-http-server"
cargo test -p rmcp --test test_streamable_http_priming --features "server client transport-streamable-http-server reqwest"
cargo test -p rmcp --test test_custom_headers --features "client server transport-streamable-http-client-reqwest transport-streamable-http-server"Additional context
Per contribution guidance, posting this issue first to discuss before opening PR.
Patch is ready on fork branch:
- branch:
fix/rmcp-stale-session-error-mapping - commit:
0666ba4 - link: https://github.com/adam-r-kowalski/rust-sdk/tree/fix/rmcp-stale-session-error-mapping
If this direction looks good, I can open a PR immediately.