Skip to content

Add a global default for MCP codemode #49576

Open

Description

@NeKon69

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Since MCP tools are often invoked with different arguments, routing all of them through Code Mode adds an extra layer to simple tool calls. It also leaves the agent with multiple ways to invoke a tool.

I would like a global default for codemode, with the per-server setting taking precedence. This would allow direct tools globally with selected servers opting into Code Mode, or Code Mode globally with selected servers opting out.

Currently, codemode has to be configured separately for every MCP server. A plugin can approximate this with ctx.mcp.transform, but this is a configuration preference and should not require a plugin.

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the suggestion! You're asking for a global default for MCP codemode, where each server's own codemode setting would still take precedence. That would let you use direct tools by default and opt chosen servers into Code Mode, or the other way round. Maintainers will consider it.

    Related issues and PRs:

    As you mentioned, a plugin can do this until then. Here is a short one. Save it as ~/.config/opencode/plugins/mcp-codemode-default.ts (or put it in .opencode/plugins/ in a project). I haven't type-checked it, so please let us know if it doesn't load:

    import { Plugin } from "@opencode/plugin"
    
    // Global default for MCP `codemode`. Servers that set `codemode` themselves keep their own value.
    const DEFAULT_CODEMODE = false // false = direct tools by default, true = Code Mode by default
    
    export default Plugin.define({
      id: "mcp-codemode-default",
      setup: async (ctx) => {
        const fallback: boolean = ctx.options.codemode ?? DEFAULT_CODEMODE
        await ctx.mcp.transform((editor) => {
          for (const [, server] of editor.list()) {
            if (server.codemode === undefined) server.codemode = fallback
          }
        })
      },
    })

    One caveat: the order in which plugins run decides one case. If this plugin runs before OpenCode's built-in defaults, servers such as Executor would get your global default instead of the built-in codemode: false. Setting codemode on those servers in your config avoids this.

    I agree this is really a config preference, so we've kept the request open for a built-in option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions