fix: fall back to legacy initialize on general errors - #1088
Open
jamadeo wants to merge 1 commit into
Open
Conversation
DaleSeo
reviewed
Jul 29, 2026
| // On stdio, legacy servers may reject an unknown pre-initialize request with | ||
| // any implementation-defined error (or not respond at all). Treat every | ||
| // failure not recognized as modern version negotiation as a legacy peer. | ||
| Err(_) => { |
Member
Contributor
Author
There was a problem hiding this comment.
The fix might not be quite as straightforward as I'd hoped. The core of the issue is
A client that needs to interoperate with both kinds of servers detects the server’s era with transport-specific mechanics, specified in the binding pages:
- stdio: probe with server/discover and fall back on any error that is not a recognized modern error.
- Streamable HTTP: attempt a modern request and inspect the body of a 400 Bad Request before falling back.
from here
so, I think the proper fix will need to implement this slightly differently.
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn auto_startup_falls_back_after_discover_invalid_params() { |
Member
There was a problem hiding this comment.
Would it be worth adding a test to catch a future ClientInitializeError variant being silently swept into Err(_)?
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.

fixes #1040
Motivation and Context
The fallback logic was too strict, only falling back on a single METHOD_NOT_FOUND error, while the spec states we should fall back on any error that does not indicate a modern server.
How Has This Been Tested?
Tested against FastMCP+goose
Breaking Changes
No
Types of changes
Checklist
Additional context