Repository navigation
Description
Summary
Remote MCP servers that answer the server/discover probe with an HTTP 5xx (the common Spring AI / mcp-java response for unimplemented methods) fail to connect with Version negotiation failed: the server answered the probe with HTTP 500. The documented auto-mode "falls back to legacy when the server does not support it" behavior does not trigger, and per the docs the default should be legacy (plain initialize) — yet the client probes by default. A plain initialize handshake against the same server succeeds, so the server is usable.
Environment
- opencode version: 2.4.1 (install channel: latest; binary updated 2026-11-23 16:19 local time)
- OS: Darwin 27.2.0 (macOS, arm64)
- Terminal: TERM_PROGRAM=vscode, TERM=xterm-256color
- Shell: /bin/zsh (login), bash 5.3.20 in
shellconfig - Active plugins: none found in config
Reproduction
-
Configure a remote MCP server whose implementation has no
server/discoverhandler and surfaces unknown methods as HTTP 500. A live public example:https://mcp.mate-ds.de/mate-mcp(unauthenticated).Probe behavior (verifies server health and the failure shape):
# 500 + "Missing handler for request type: server/discover" curl -i -X POST https://mcp.mate-ds.de/mate-mcp \ -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \ -d '{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{}}' # 200, valid InitializeResult (protocolVersion 2025-06-18) — server works via legacy handshake curl -i -X POST https://mcp.mate-ds.de/mate-mcp \ -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"1.0.0"}}}'
-
Add to project config (v2 nested form):
{ "mcp": { "servers": { "mate-design-system": { "type": "remote", "url": "https://mcp.mate-ds.de/mate-mcp", "enabled": true } } } } -
Run
opencode mcp list.
Result is consistent, 100% reproducible; reproduces in fresh sessions and fresh opencode serve instances.
Expected Behavior
legacyis the default: "OpenCode opens every server with the classic MCPinitializehandshake by default." — the observed default probes withserver/discoverinstead.auto"probes withserver/discover… and falls back tolegacywhen the server does not support it" — an HTTP 500 answer to a method the server does not implement is "does not support it" in practice; no fallback occurs.
The default flip to auto appears intentional (commit bda12b51 updated the schema description accordingly) — the core ask is that a 5xx probe answer triggers the documented "falls back to legacy when the server does not support it" behavior, as #39354 requested for JSON-RPC error answers. Secondary ask: the docs page still describes legacy as the default and should be reconciled with the schema.
Actual Behavior
✗ mate-design-system failed: Version negotiation failed: the server answered the probe with HTTP 500
Log: three connect attempts (~150 ms apart), then mcp connect failed. No fallback to initialize. Same URL connects fine when protocol: "legacy" is set explicitly (verified: 17 tools listed).
Additional Context
- Regression commit identified:
bda12b51"feat(mcp): negotiate the newest protocol by default" (feat(mcp): negotiate the newest protocol by default #65282), shipped in v2.4.0 (2026-11-23). It flipped the default toauto(config.protocol ?? "auto") and added auto→legacy fallback for local stdio onConnectionClosed/EraNegotiationFailed("Some legacy servers exit on the auto probe's unknown request"), but for remote HTTP the fallback only catchesRequestTimeout(unanswered probe). A probe answered with HTTP 5xx falls through as fatal. The remote gap is the same "server does not support it" situation the stdio path already covers.- Note: the same commit updated the schema description to
"auto" (default), but the docs page (opencode.ai/docs/mcp-servers) still states legacy/initialize is the default.
- Note: the same commit updated the schema description to
- Regression window confirmed: connections with v2.3.2 succeeded until 2026-11-23 12:02 UTC (v2.4.0 released 09:22 UTC); failures began the same evening after updating. The server side never changed (its repository contains no
server/discoverhandler at any revision). - Related: v1.18.8 remote MCP fails:
server/discoverprobe rejected by server (-32700), no fallback to classicinitialize#39354 (fixed via PR fix(mcp): restore legacy SDK compatibility #39373) made JSON-RPC-error probe answers fall back; HTTP 5xx answers still hard-fail. Many real-world servers answer unknown JSON-RPC methods with 5xx (Spring AI 2.0WebMvcStatelessServerTransportdoes), so the fallback rarely gets its "clean" signal. MCP 2026-07-28's own compatibility matrix ("Modern client → Legacy server: Fails") makes these collisions common during the transition. - Workaround that works:
"protocol": "legacy"in the v2 nestedmcp.servers.<name>form — verified connecting (tools=17). - Secondary, confusing: the same
protocolkey is silently dropped when the deprecated flat form"mcp": { "<name>": { … } }is used — connection keeps probing with no warning. Verified by A/B in one process: nested+protocol→ connected; flat+protocol→ probe 500. At minimum this should warn or error. - Also observed:
opencode reloadre-fires MCP connects but from the stale config snapshot (still probing after a config change was written); a fullopencode service restartwas needed for some sessions. Additionally,MCP_PROTOCOL_NEGOTIATION=legacy(string present in the binary) had no observable effect on remote connects.
Activity
opencodejr commentedon Nov 24, 2026
Thanks for the detailed report. I reproduced this with the released CLI against your public server, with nothing mocked.
protocolset, the server answers theserver/discoverprobe with HTTP 500.opencode mcp listthen shows✗ mate-design-system failed: Version negotiation failed: the server answered the probe with HTTP 500. The service log shows two connect retries and thenmcp connect failed, andinitializeis never tried."protocol": "legacy"the same server shows✓ connected.protocolset, so this is a regression.dev(87dd60cbe), which I ran from source.The script below reproduces it. It writes the nested
mcp.serversconfig, runsopencode mcp listand compares the default protocol withlegacy. Until this is fixed, the workaround you found ("protocol": "legacy"in the nestedmcp.servers.<name>form) works.I only tested the main failure, not the flat config form,
opencode reloadorMCP_PROTOCOL_NEGOTIATION.Reproduction script (repro.sh)
Run it:
sh repro.shfix(mcp): fall back to legacy when the probe answer is an HTTP error
ransagy commentedon Nov 24, 2026
A second failure shape from the same regression, where the probe succeeds and
the fallback never gets a chance: Railway's hosted MCP (
https://mcp.railway.com).It answers
server/discoverwithsupportedVersions: ["2026-07-28"], so 2.4.1commits to the modern revision. It then opens
subscriptions/listen, gets theack, and
tools/listnever returns — 30s startup timeout,mcp connect failed,Railway tools dropped from the session. Same server with
protocol: "legacy":85 tools in ~2.2s.
Against the Railway proxy, stdin kept open:
initialize+tools/listserver/discover+tools/listserver/discover+subscriptions/listen+tools/listSo the 5xx fallback fixes one case, but
autocan also negotiate successfullyand then fail at catalog time with no path back. Falling back (or retrying
initialize) when the modern-era catalog fails would cover this one.opencode 2.4.1, Railway CLI 5.71.0 and 5.75.0. Filed on the Railway side:
railwayapp/cli#1376
batestguy commentedon Nov 26, 2026
Same root cause on a different transport, plus a second trigger that is easy to reproduce — posting in case it narrows the fix down.
Environment: opencode 2.4.2 (latest, npm
@opencode/cli), Windows 11. Two local stdio servers built on themcp2.0.0 Python SDK (rmcp0.11.0 andmcp-server-motherduck1.1.1) both failed; two older local servers (@upstash/context7-mcp,@playwright/mcp) were unaffected, because they answerserver/discoverwith "method not found" and stay on the legacy path.Trigger: the
mcpblock was still in the v1 flat shape, server names directly undermcp:{ "mcp": { "rmcp": { "type": "local", "command": ["rmcp", "start"], "protocol": "legacy" } } }That shape still launches the server, but the per-server
protocolis dropped during normalisation, so the client probes withserver/discovereven though the documented default islegacy. The tell isopencode debug config: it prints noprotocolkey for those servers. Moved under the v2 shape ("mcp": { "servers": { ... } }), the identical"protocol": "legacy"is honoured and both servers connect immediately.Why it hard-fails instead of falling back:
mcp2.0.0's server runner picks the connection era from the first frame (opens_modern = opening.method != "initialize" and _has_modern_envelope(...)), so the probe locks the connection to 2026-07-28 and theinitializethat follows is refused:Two things that may be worth handling independently of transport:
"protocol"written in the flat shape is silently ignored rather than rejected or warned about. A setting that cannot take effect is worse than an error, because the failure surfaces as a server-side handshake problem.Received a response for an unknown message ID: server-discover-probe-1— the probe reply is not tracked, which may be why the documented fallback does not engage cleanly.Workaround for anyone hitting this with local servers: move the block under
mcp.servers, set"protocol": "legacy", then confirm withopencode debug configthat the key survives, not just that the server starts.