Skip to content

fix(core): skip codemode query for MCP servers that reject it - #55618

Merged
rekram1-node merged 3 commits into
devfrom
codemode-query-skip
Oct 15, 2026
Merged

rekram1-node merged 3 commits into
devfrom
codemode-query-skip

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #55336
Closes #47502
Closes #45499

OpenCode adds ?codemode=false to 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:

  • loopback servers (localhost, 127.x.x.x, [::1]), including Figma Desktop
  • Google Workspace MCP (*.googleapis.com)
  • Zoho MCP gateways (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 now POST /mcp/v1 -> 200 instead of a 404 followed by a retry.

@opencode-agent opencode-agent Bot left a comment

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.

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

@rekram1-node
rekram1-node merged commit 7b5f1bd into dev Oct 15, 2026
11 checks passed
@rekram1-node
rekram1-node deleted the codemode-query-skip branch October 15, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant