Repository navigation
fix(core): skip codemode query for MCP servers that reject it - #55618
Conversation
There was a problem hiding this comment.
The fix looks good. I ran the #55336 mock reproduction from source on the base and on this branch, adding a run with the mock on localhost:3845 so the new host check is used. On the base the first request was POST /mcp/v1?codemode=false, and the HTML 404 page was logged as mcp transport error before the retry. With this change the first request is POST /mcp/v1, with no warning. Hosts outside the list behave as before. bun test test/mcp.test.ts has the same result on base and PR (77 pass; the stdio descendant-termination test fails on both), and typecheck in packages/core passes.
Public API is unchanged: config keys, the explicit codemode setting and codemode query values all work as before.
Non-blocking note: servers that reject the query with something other than 400/404 still get no fallback to the configured URL (the 403 case in the #55336 repro). Unknown servers that 404 on query strings still pay one failed request and log the full HTML page. The issue covers both cases, but neither affects Google, Zoho or Figma, so they are fine to leave for later.
Related: #55079
Closes #55336
Closes #47502
Closes #45499
OpenCode adds
?codemode=falseto remote MCP URLs so servers that bundle their own Code Mode, like Cloudflare's, expose raw tools instead of nesting inside OpenCode's Code Mode (#45377). Servers that reject unknown query parameters then fail the first request on every connect before the 400/404 retry kicks in.This stops sending the flag to:
localhost,127.x.x.x,[::1]), including Figma Desktop*.googleapis.com)zohomcp.*)The MCP test servers run on localhost, so the tests that relied on the flag being added there are removed.
Verified live against
gmailmcp.googleapis.com: the first request is nowPOST /mcp/v1 -> 200instead of a 404 followed by a retry.