Skip to content

fix(transport): fall back after sessionless HTTP discover rejections - #1211

Open
jstar0 wants to merge 3 commits into
modelcontextprotocol:mainfrom
jstar0:fix/1040-http-legacy-discover-fallback-current
Open

fix(transport): fall back after sessionless HTTP discover rejections#1211
jstar0 wants to merge 3 commits into
modelcontextprotocol:mainfrom
jstar0:fix/1040-http-legacy-discover-fallback-current

Conversation

@jstar0

@jstar0 jstar0 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Some legacy streamable-HTTP servers reject server/discover in middleware with an empty or plain-text 4xx response before JSON-RPC dispatch. That prevents ClientLifecycleMode::Auto from reaching the legacy initialize path.

This change:

  • Converts only sessionless server/discover client-error responses into a correlated INVALID_REQUEST response for the existing lifecycle classifier.
  • Preserves 401/403 responses, 5xx responses, existing-session failures, and non-discover requests as transport errors.
  • Applies the fallback to both the reqwest and Unix socket HTTP clients.
  • Adds regressions for plain-text 4xx fallback and the sessionful discovery boundary.

This addresses #1040. It is complementary to #1141, which handles JSON-RPC error responses; this change covers transport-level empty, malformed, and non-JSON 4xx responses.

Testing

  • cargo fmt --all -- --check
  • cargo test -p rmcp --test test_streamable_http_4xx_error_body --features client,reqwest,transport-streamable-http-client-reqwest,transport-streamable-http-server
  • cargo test -p rmcp --test test_discover_http_client_startup --features client,reqwest,transport-streamable-http-client-reqwest,transport-streamable-http-server
  • cargo test -p rmcp --test test_unix_socket_transport --features client,server,transport-streamable-http-client-unix-socket
  • cargo test -p rmcp --features client,server,reqwest,transport-io,transport-streamable-http-client-reqwest,transport-streamable-http-server (296 unit tests, all integration tests, and 39 non-ignored doctests)

Breaking Changes

None.

@jstar0
jstar0 requested a review from a team as a code owner August 24, 2026 15:00
@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes T-transport Transport layer changes labels Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant