Skip to content

Disabling MCPs doesn't persist across sessions #13763

Closed as not planned
Closed as not planned

Description

@andreagrandi

Description

I've 5 MCPs configured in OpenCode. If I disable them, when I restart opencode the MCPs are enabled again. I would expect the status to persist across sessions.

Plugins

No response

OpenCode version

1.2.5

Steps to reproduce

  1. /mcps
  2. press to toggle an mcp
  3. close opencode
  4. re-open opencode
  5. /mcps -> the previously disabled mcp has been enabled again

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. dawidbednarczyk commented on Feb 25, 2026

    @dawidbednarczyk

    +1 — This is a significant pain point for users with many MCP servers configured.

    Use case

    I run 8+ MCP servers (RADKit, Webex RAG, CDETS, Topic Search, GitHub Enterprise, Chrome DevTools, etc.). In a 128k context window, MCP tool definitions alone consume ~40k tokens — a third of available context before any conversation begins. Being able to start lean and enable MCPs on-demand was a killer workflow in Claude Code, where the disable state persisted across sessions.

    With OpenCode, the toggle resets every restart, so I ended up permanently removing servers from config instead of just disabling them — which means re-adding them later when I need them. That's exactly the wrong tradeoff.

    Technical root cause

    After reading the source, the gap is clear:

    • Model selection persists to Global.Path.state/model.json via Filesystem.writeJson (local.tsx L123-151)
    • MCP toggle only updates in-memory Instance.state (mcp/index.ts L554-564) — no filesystem write

    The pattern already exists for models; MCPs just need the same treatment.

    Suggested implementation

    The lowest-friction approach: save toggle state to Global.Path.state/mcp-state.json (mirroring model.json), and read it back during MCP initialization in state(). The local.tsx model persistence pattern is a clean template.

    Prior art

    Claude Code has persistent MCP disable at the UI level. See also anthropics/claude-code#10447 where users calculated ~65K tokens lost per session to unused MCP tool definitions — a compelling argument for start-lean-enable-on-demand workflows.

    Related issues

  2. micheldenario commented on Mar 2, 2026

    @micheldenario

    Second this, I will also like this to persist across sessions like vscode does, I don't want MCP's to be auto-enabled unless I activate them when I need them. I have big mcp tools that can consume a lot of tokens if activated.

  3. iMaxTomas commented on Apr 12, 2026

    @iMaxTomas

    I've conducted an exhaustive investigation into why MCPs cannot be effectively disabled in OpenCode, and I believe your issue (#13763) touches on a symptom of a deeper architectural problem that may not be fully solved by simply persisting toggle state.

    Key finding: at least two MCPs — chrome-devtools and morphllm-fast-apply — are hardcoded into the opencode binary itself. They spawn automatically on every startup (visible in logs as service=mcp key=chrome-devtools type=local found) even when the user's opencode.json contains no reference to them.

    This means:

    • Persisting /mcps toggle state will help user-defined MCPs, but it will not give users a way to turn off these binary-bundled defaults.
    • Attempting to add "chrome-devtools": { "enabled": false } to opencode.json currently produces a fatal schema validation error (Invalid input mcp.chrome-devtools) in the session attach path.
    • The public JSON schema (https://opencode.ai/config.json) does not even declare an mcp property; validation is handled by an internal zod schema that rejects built-in names.

    I've opened a dedicated feature request (#22188) specifically requesting an official mechanism to disable built-in MCP servers. It may be worth considering that fix alongside toggle persistence so that users can actually opt out of all MCPs, not just the ones they manually configured.

    Evidence summary: #22188

  4. removed
    bugSomething isn't working
    on May 3, 2026
  5. rekram1-node commented on May 22, 2026

    @rekram1-node
    Collaborator

    Key finding: at least two MCPs — chrome-devtools and morphllm-fast-apply — are hardcoded into the opencode binary itself. They spawn automatically on every startup (visible in logs as service=mcp key=chrome-devtools type=local found) even when the user's opencode.json contains no reference to them.

    This is NOT true

  6. rekram1-node commented on May 22, 2026

    @rekram1-node
    Collaborator

    Currently /mcps is only for toggling on/off on the fly not for persisting but yeah prolly should

  7. github-actions commented on Jul 22, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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