Skip to content

[FEATURE]: Allow per-project MCP enabled/disabled overrides #4525

@jknlsn

Description

@jknlsn

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

Problem

Currently, OpenCode starts all configured MCP servers regardless of whether any agent has access to their tools. The sidebar shows "Connected" MCPs, but it's not obvious whether they're actually usable or not. For example, if I have Linear, GitHub, and Xcode MCPs configured globally but disable them all with "linear_*": false, "github_*": false, "xcode_*": false, all three MCP servers still start up - they're just not accessible to agents.

Proposed Solution

Only start MCP servers that are accessible to at least one agent based on the tools configuration. This involves:

  1. Check accessibility before starting - Before initializing an MCP server, check if any agent can access its tools
  2. Add "inaccessible" status - Mark MCPs that won't be started as "inaccessible" (displayed as "Inactive" in the UI)
  3. UI improvements - Sort MCP list (connected first), add optional hiding of inactive MCPs, improve status display

Example Use Case

Global config (~/.config/opencode/opencode.jsonc):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "linear": { "type": "remote", "url": "https://mcp.example.com/linear" },
    "github": { "type": "remote", "url": "https://mcp.example.com/github" },
    "xcode": { "type": "local", "command": ["npx", "-y", "@example/xcode"] },
  },
  "tools": {
    // Disable all MCPs globally by default
    "linear_*": false,
    "github_*": false,
    "xcode_*": false,
  },
  "tui": {
    "sidebar": {
      "hide_inactive_mcp": true, // Optional: hide inactive MCPs from UI
    },
  },
}

Project config (~/project/.opencode/opencode.jsonc):

{
  "$schema": "https://opencode.ai/config.json",
  "tools": {
    // Enable only the MCPs this project needs
    "linear_*": true,
    "github_*": true,
    // xcode remains disabled (inherited from global)
  },
}

With this approach:

  • All MCP servers are defined once (global config)
  • Each project specifies which MCPs it needs (project config)
  • Only enabled MCPs start
  • Inactive MCPs can be hidden from the UI (cleaner interface)

Why this belongs in OpenCode

This feature enables a more efficient and scalable MCP configuration workflow:

  • Doesn't run unnecessary processes
  • Can choose to define MCPs once, enable per-project
  • Can see at a glance which MCPs are active vs inactive
  • Builds on OpenCode's existing layered config system (global + project)

Implementation notes

I have a reference implementation on my fork that includes:

  • Core accessibility checking logic (MCP.isAccessible())
  • New "inaccessible" status type
  • Sidebar UI improvements/tweaks (sorting, hiding inactive MCPs, better status display)
  • Unit tests
  • Documentation updates

Reference implementation here: https://github.com/jknlsn/opencode/

I haven't opened a PR yet as I wanted to discuss the feature idea first per the contributing guidelines!

What do you think?

  1. Does this align with OpenCode's goals?
  2. Should inactive MCPs be hidden by default, or should that be opt-in (as currently implemented)?
  3. Any concerns about the approach or edge cases to consider?

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionUsed for feature requests, proposals, ideas, etc. Open discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions