GeezerVison is showing github.com — fix(core): fall back to legacy when the MCP probe gets an HTTP 5xx by neriousy · Pull Request #66588 · anomalyco/opencode
Conversation
neriousy
commented
Nov 26, 2026
•
edited by opencodejr
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #66101
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
since #65282 remote servers default to auto, but the HTTP path only fell back to legacy when the server/discover probe timed out. lots of legacy servers (Spring AI / mcp-java) answer unknown methods with a 500, and the SDK turns that into SdkHttpError(EraNegotiationFailed), so the connect just failed and never tried initialize
negotiate in packages/core/src/mcp/client.ts now also falls back on a 5xx answer to the probe, same as the timeout case. network errors still fail (initialize would fail the same way)
- if the server is really down it now gets probe + initialize per attempt, so the pool "was down" test counts 6 requests instead of 3
- docs said
legacy is the default, fixed to auto
not covered here: the Railway case from the comments (probe succeeds, then tools/list hangs on the modern era) and protocol being dropped in the flat mcp.<name> config form
no flag, it's a fix
How did you verify your code works?
- new test in
packages/core/test/mcp.test.ts: an HTTP server that answers server/discover with 500 and speaks legacy otherwise. fails on dev, passes here (--rerun-each 10)
bun run script/test.ts test/mcp*.test.ts test/mcp and bun typecheck in packages/core
- docs build (
bun src/docs/script/build.ts) passes
Screenshots / recordings
n/a
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Related: #66577
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix works. I ran the #66101 repro script from source against a local proxy that answers server/discover with HTTP 500 and forwards everything else to the reporter's real Spring AI server. The public server itself now answers the probe with -32601, so it no longer shows the bug. On the base, the default protocol fails with Version negotiation failed: the server answered the probe with HTTP 500. With this PR it connects. The new test and the updated pool test both fail on the base and pass here. tsc passes for packages/core.
In the SDK, an SdkHttpError with the negotiation-failed code only comes from a probe answered with a 5xx. 401/403 keep their auth errors, and other 4xx answers already fell back. So the new condition covers just this case, and OAuth is unaffected.
Public API: unchanged. The docs now correctly say auto is the default, which matches the schema.
No blocking concerns.
Related: #66577
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.