Repository navigation
Conversation
Cloudflare's MCP server is a Code Mode server itself, so OpenCode Code Mode is turned off for it by default, the same way it already is for executor.sh. Without this the model receives a catalog of thousands of Cloudflare OpenAPI operations instead of Cloudflare's four Code Mode meta-tools. An explicit `codemode` in config is still left exactly as configured.
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
This reverses a deliberate earlier design. #43157 first exempted the Cloudflare API MCP from OpenCode Code Mode. #45377 then took that exemption out on purpose and made client.ts add ?codemode=false to remote URLs instead, so Cloudflare sends its individual API tools and they stay behind OpenCode's searchable catalog rather than being nested inside Cloudflare's own Code Mode. This PR goes back to Cloudflare's 4 meta-tools with OpenCode Code Mode off. That is a defensible choice, but it should engage with the reasoning in #45377 and needs a maintainer decision; the description doesn't mention it.
How I checked: the changed unit test passes and typecheck in packages/core is clean. I read how this interacts with the ?codemode=false logic in packages/core/src/mcp/client.ts. I could not test against a live Cloudflare MCP server.
Public API: unchanged. Only the default for Cloudflare MCP servers that don't set codemode changes; explicit codemode settings are respected as before.
Concerns (inline): a Cloudflare URL configured with ?codemode=false now also gets OpenCode Code Mode turned off, so thousands of tools go straight to the model; and docs.mcp.cloudflare.com is not a Code Mode server.
| const urls = [/^https:\/\/executor\.sh\/[^/]+\/mcp$/] | ||
| const urls = [ | ||
| /^https:\/\/executor\.sh\/[^/]+\/mcp$/, | ||
| /^https:\/\/mcp\.cloudflare\.com\/mcp$/, |
There was a problem hiding this comment.
The plugin drops the query string before matching (${url.origin}${url.pathname}). So a URL configured as https://mcp.cloudflare.com/mcp?codemode=false, where the user explicitly asked Cloudflare for its raw OpenAPI tools, also gets codemode: false. All of those thousands of tools would then go straight to the model with no OpenCode catalog in front, which is worse than both the current behaviour and what this PR is aiming for. If Cloudflare is matched here, please skip it when the URL already has a codemode parameter set to false/off.
As far as I can tell, docs.mcp.cloudflare.com serves a few documentation-search tools, not its own Code Mode interface. That's different from executor.sh or mcp.cloudflare.com. This list is meant for servers that are Code Mode themselves, so I'd drop this entry unless you can show the docs server behaves like the API server.
| codemode: false, | ||
| }, | ||
| { | ||
| name: "cloudflare raw tools", |
There was a problem hiding this comment.
This case asserts the behaviour described in the comment on the defaults file: a user who configured ?codemode=false to get Cloudflare's raw tools ends up with OpenCode Code Mode off too. I'd expect undefined here.
Issue for this PR
Closes #
Type of change
What does this PR do?
Cloudflare's MCP server is a Code Mode server:
https://mcp.cloudflare.com/mcpserves Cloudflare's Code Mode interface (4 meta-tools: search / docs / execute / whoami), whilehttps://mcp.cloudflare.com/mcp?codemode=falseserves the raw OpenAPI operation list (thousands of individual tools).Today OpenCode wraps it in its own Code Mode, so the model gets a catalog of thousands of Cloudflare OpenAPI operations instead of Cloudflare's 4 meta-tools — a bad default for every user.
This adds Cloudflare's endpoints to the
urlslist inmcp-codemode-defaults.ts, which turns OpenCode Code Mode off for them (codemode: false). It mirrors the existingexecutor.shhandling exactly: Cloudflare's MCP is a Code Mode server in the same sense, so its own Code Mode no longer ends up nested inside OpenCode's.An explicit
codemodein config is still left exactly as configured, bothtrueandfalse.How did you verify your code works?
bun run checkfrom the repo root is also clean.Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist