-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
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:
- Check accessibility before starting - Before initializing an MCP server, check if any agent can access its tools
- Add "inaccessible" status - Mark MCPs that won't be started as "inaccessible" (displayed as "Inactive" in the UI)
- 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):
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?
- Does this align with OpenCode's goals?
- Should inactive MCPs be hidden by default, or should that be opt-in (as currently implemented)?
- Any concerns about the approach or edge cases to consider?
{ "$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 }, }, }