fix(client): fall back on legacy JSON-RPC errors - #1141
Open
j45856021-dev wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e006650d-d10e-432f-aaa2-15a763fdf4b6
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.
Summary
server/discoverto legacyinitializefor JSON-RPC errors that do not positively identify a modern server.-32000unsupportedMCP-Protocol-Versionresponse, plus guards for modern capability and header errors.ClientLifecycleMode::Autobehavior in the README.This addresses the JSON-RPC interoperability cases in #1040 and is a narrower alternative to #1133 after the review concern that
Err(_)also catches 401/403 and client-side failures.Motivation and Context
The 2026-07-28 compatibility guidance says a client should fall back when a legacy server returns an error that is not a recognized modern JSON-RPC error. Some deployed legacy servers reject the modern protocol header before dispatch with an implementation-defined response such as:
Current
Autohandling only falls back forMETHOD_NOT_FOUND, so these servers fail even though the configured legacy protocol works. This change limits the broader fallback toJsonRpcError; transport and authorization failures still surface unchanged.How Has This Been Tested?
cargo fmt --all --checkcargo test -p rmcp --test test_client_lifecycle_modes --features clientcargo test -p rmcp --test test_discover_http_client_startup --features client,reqwest,transport-streamable-http-client-reqwest,transport-streamable-http-servercargo clippy -p rmcp --test test_client_lifecycle_modes --features client -- -D warningsBreaking Changes
None.
Types of changes
Checklist