Skip to content

fix(transport): fall back after JSON discover rejections - #1288

Open
alexhancock wants to merge 1 commit into
mainfrom
alexhancock/fix-discover-4xx-json-fallback
Open

alexhancock wants to merge 1 commit into
mainfrom
alexhancock/fix-discover-4xx-json-fallback

Conversation

@alexhancock

Copy link
Copy Markdown
Contributor

Motivation and Context

Check the discover fallback before the JSON-RPC error branch, or middleware rejections with an uncorrelated id abort the handshake instead of falling back to legacy initialize.

How Has This Been Tested?

Unit tests, and tested in a client app (goose)

Breaking Changes

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Related goose issue aaif-goose/goose#12257

@alexhancock
alexhancock requested a review from a team as a code owner September 21, 2026 18:53
@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes T-transport Transport layer changes labels Sep 21, 2026
.text()
.await
.unwrap_or_else(|_| "<failed to read response body>".to_owned());
// A 4xx rejection of `server/discover` is a legacy-server signal even when

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite in agreement with https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning#backward-compatibility-with-initialization-based-versions :

a recognized modern JSON-RPC error (such as UnsupportedProtocolVersionError) identifies a modern server: the client retries with a supported version rather than falling back. Anything else identifies a legacy server.

so I think this fixes the generic uncorrelated error case, but may treat recognized modern errors as legacy servers. We need to check the body here too to see if it parses

Check the discover fallback before the JSON-RPC error branch, or middleware
rejections with an uncorrelated id abort the handshake instead of falling back
to legacy `initialize`.
@alexhancock
alexhancock force-pushed the alexhancock/fix-discover-4xx-json-fallback branch from 83ea96b to 04b4738 Compare September 21, 2026 20:38
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.

2 participants