[feature request]: ability to dynamic turn on mcp server for specific agent #1941

Open
opened 2026-02-16 17:33:20 -05:00 by yindo · 10 comments
Owner

Originally created by @zelifish on GitHub (Oct 3, 2025).

Originally assigned to: @adamdotdevin on GitHub.

Hope I'm not doing this wrong, but with this opencode config in version 0.11.1

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "graphql": {
      "type": "local",
      "enabled": false,
      "command": ["bunx", "mcp-graphql"],
      "environment": {
        "ENDPOINT": "http://localhost:13087/graphql"
      }
    }
  }
}

And this agent definition

---
description: test agaent
mode: primary
tools:
  graphql_*: true
---

This is a test agent

My agent can't actually see the graphql mcp tools. I tried various permutations of graphql, graphql*, graphql_*, etc.

Originally created by @zelifish on GitHub (Oct 3, 2025). Originally assigned to: @adamdotdevin on GitHub. Hope I'm not doing this wrong, but with this opencode config in version 0.11.1 ```json { "$schema": "https://opencode.ai/config.json", "mcp": { "graphql": { "type": "local", "enabled": false, "command": ["bunx", "mcp-graphql"], "environment": { "ENDPOINT": "http://localhost:13087/graphql" } } } } ``` And this agent definition ```yml --- description: test agaent mode: primary tools: graphql_*: true --- This is a test agent ``` My agent can't actually see the graphql mcp tools. I tried various permutations of `graphql`, `graphql*`, `graphql_*`, etc.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 3, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2888: Discussion about global default tools configuration for agents and tool inheritance behavior
  • #1101: Request for enabling/disabling MCP servers by mode, with detailed tool configuration syntax
  • #2277: Request to restrict MCP tool use to specific agents/subagents only
  • #514: Feature request for enabling/disabling MCP servers at runtime

Feel free to ignore if none of these address your specific case with disabled MCP servers not being accessible through agent tool configurations.

@github-actions[bot] commented on GitHub (Oct 3, 2025): This issue might be a duplicate of existing issues. Please check: - #2888: Discussion about global default tools configuration for agents and tool inheritance behavior - #1101: Request for enabling/disabling MCP servers by mode, with detailed tool configuration syntax - #2277: Request to restrict MCP tool use to specific agents/subagents only - #514: Feature request for enabling/disabling MCP servers at runtime Feel free to ignore if none of these address your specific case with disabled MCP servers not being accessible through agent tool configurations.
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

@zelifish so here is what you need to do:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "graphql": {
      "type": "local",
      "enabled": true,
      "command": ["bunx", "mcp-graphql"],
      "environment": {
        "ENDPOINT": "http://localhost:13087/graphql"
      }
    }
  },
  "tools": {
    "graphql*": false
  }
}

enabled being false means the MCP server won't ever turn on at all so it isn't possible to give to llm

@rekram1-node commented on GitHub (Oct 3, 2025): @zelifish so here is what you need to do: ``` { "$schema": "https://opencode.ai/config.json", "mcp": { "graphql": { "type": "local", "enabled": true, "command": ["bunx", "mcp-graphql"], "environment": { "ENDPOINT": "http://localhost:13087/graphql" } } }, "tools": { "graphql*": false } } ``` `enabled` being false means the MCP server won't ever turn on at all so it isn't possible to give to llm
Author
Owner

@zelifish commented on GitHub (Oct 3, 2025):

Hmm, my motivation for this was to mitigate long startup times for tools that we only need when working on the front end portion of our repo. Is there a better way of doing that? My only other solution was to move my opencode configs down into the FE section but then I can't actually use them when working across the back and the front end having started opencode from a higher directory (or can I)?

I guess I could explicitly pass the config in the opencode command but no one's going to obey my complicated instructions if that's what I make them do.

@zelifish commented on GitHub (Oct 3, 2025): Hmm, my motivation for this was to mitigate long startup times for tools that we only need when working on the front end portion of our repo. Is there a better way of doing that? My only other solution was to move my opencode configs down into the FE section but then I can't actually use them when working across the back and the front end having started opencode from a higher directory (or can I)? I guess I could explicitly pass the config in the opencode command but no one's going to obey my complicated instructions if that's what I make them do.
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

@zelifish rn there isn't a better way of doing it tbh, in opentui version there will probably be a mechanism to enable and disable mcp servers on the fly but rn it isn't super easy

@rekram1-node commented on GitHub (Oct 3, 2025): @zelifish rn there isn't a better way of doing it tbh, in opentui version there will probably be a mechanism to enable and disable mcp servers on the fly but rn it isn't super easy
Author
Owner

@benceferdinandy-signifyd commented on GitHub (Oct 16, 2025):

@rekram1-node do you have an estimate for opentui release?

@benceferdinandy-signifyd commented on GitHub (Oct 16, 2025): @rekram1-node do you have an estimate for opentui release?
Author
Owner

@rekram1-node commented on GitHub (Oct 16, 2025):

@benceferdinandy-signifyd if you need it specifically for this issue, i can't really give a timeline on when this will be addressed as it is a lower priority rn

As for opentui version shipping in general id say next week probs

@rekram1-node commented on GitHub (Oct 16, 2025): @benceferdinandy-signifyd if you need it specifically for this issue, i can't really give a timeline on when this will be addressed as it is a lower priority rn As for opentui version shipping in general id say next week probs
Author
Owner

@benceferdinandy-signifyd commented on GitHub (Oct 16, 2025):

Just generally opentui, thanks!

@benceferdinandy-signifyd commented on GitHub (Oct 16, 2025): Just generally opentui, thanks!
Author
Owner

@emilford commented on GitHub (Nov 21, 2025):

@rekram1-node the suggested approach doesn't seem to work for me. I have the GitHub MCP server set up and enabled, tools in the global configuration includes "github*": false and the subagent markdown includes tools: "github*": true, but the agent doesn't have access to the tools. If I comment out the global tools line everything works. What am I missing? 🤔

Edit:

Ah, it looks like configuring the agent tools in opencode.js works in the way described above. Is this a markdown limitation?

  "tools": {
    "github*": false,
    ...
  },
  "agent": {
    "github": {
      "tools": {
        "github*": true
      }
    }
  }
@emilford commented on GitHub (Nov 21, 2025): @rekram1-node the suggested approach doesn't seem to work for me. I have the GitHub MCP server set up and enabled, tools in the global configuration includes `"github*": false` and the subagent markdown includes `tools: "github*": true`, but the agent doesn't have access to the tools. If I comment out the global tools line everything works. What am I missing? 🤔 Edit: Ah, it looks like configuring the agent tools in opencode.js works in the way described above. Is this a markdown limitation? ``` "tools": { "github*": false, ... }, "agent": { "github": { "tools": { "github*": true } } } ```
Author
Owner

@rekram1-node commented on GitHub (Nov 23, 2025):

@emilford this is what it'd look like in markdown:

---
description: ALWAYS use this when writing docs
tools:
  "github*": false
---
@rekram1-node commented on GitHub (Nov 23, 2025): @emilford this is what it'd look like in markdown: ``` --- description: ALWAYS use this when writing docs tools: "github*": false --- ```
Author
Owner

@lcswillems commented on GitHub (Dec 11, 2025):

@rekram1-node The issue is that the MCP server will appear in all sessions for all agents even though the agents are not allowed to use it...

I've opened another issue that focuses on this context issue. This is very annoying...

https://github.com/sst/opencode/issues/5373

@lcswillems commented on GitHub (Dec 11, 2025): @rekram1-node The issue is that the MCP server will appear in all sessions for all agents even though the agents are not allowed to use it... I've opened another issue that focuses on this context issue. This is very annoying... https://github.com/sst/opencode/issues/5373
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1941