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 /mcp with headers:
Accept: application/json, text/event-stream
Content-Type: application/json
mcp-session-id: stale-session-id
- Send any valid JSON-RPC request body (for example ping/tool call).
- Observe raw HTTP response is
401 Unauthorized with body Unauthorized: Session not found and missing Content-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:
If this direction looks good, I can open a PR immediately.
Describe the bug
With streamable HTTP, when a client sends a stale/invalid
mcp-session-id, the server returns401 Unauthorizedplain text withoutContent-Type. The reqwest streamable client then surfaces this asStreamableHttpError::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:
StreamableHttpService.POST /mcpwith headers:Accept: application/json, text/event-streamContent-Type: application/jsonmcp-session-id: stale-session-id401 Unauthorizedwith bodyUnauthorized: Session not foundand missingContent-Type.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:
401 UnauthorizedUnauthorized: Session not foundContent-Type: missingCurrent client error:
StreamableHttpError::UnexpectedContentType(None)Validation commands run against patch branch:
Additional context
Per contribution guidance, posting this issue first to discuss before opening PR.
Patch is ready on fork branch:
fix/rmcp-stale-session-error-mapping0666ba4If this direction looks good, I can open a PR immediately.