[FEATURE]: Allow to manage mcp when running Opencode with run command #7527

Closed
opened 2026-02-16 18:07:27 -05:00 by yindo · 5 comments
Owner

Originally created by @iambpn on GitHub (Jan 25, 2026).

Originally assigned to: @thdxr on GitHub.

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

I am using opencode with the run command to test something or grab a text from the internet with playwright MCP, but I don't need this MCP all the time and when I use opencode regularly I need to manually disable this MCP, and it's kind of annoying.

It would be useful if opencode can add the --enableMcp and --disableMcp flag to the run command so that users can configure the MCP when using run command.

Like this:
opencode mcp list -> list the configured MCP names
opencode run <prompt> --enableMcp playwrignt -> playwright this should be the same MCP server as listed by above MCP list comand

Originally created by @iambpn on GitHub (Jan 25, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request I am using opencode with the `run` command to test something or grab a text from the internet with playwright MCP, but I don't need this MCP all the time and when I use opencode regularly I need to manually disable this MCP, and it's kind of annoying. It would be useful if opencode can add the `--enableMcp` and `--disableMcp` flag to the `run` command so that users can configure the MCP when using `run` command. Like this: `opencode mcp list` -> list the configured MCP names `opencode run <prompt> --enableMcp playwrignt` -> `playwright` this should be the same MCP server as listed by above MCP list comand
yindo added the discussion label 2026-02-16 18:07:27 -05:00
yindo closed this issue 2026-02-16 18:07:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 25, 2026):

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

  • #5373: Allow to enable MCP on a per-agent basis (similar per-context MCP management)
  • #9696: Add @ mention syntax for one-time MCP server activation in chat (one-time MCP activation)
  • #7399: Filter which tools are loaded from MCP servers (includeTools/excludeTools config)
  • #9801: How can I disable a specific MCP service for a specific model? (selective MCP disabling)

These issues address similar needs for selective MCP management. Your feature request for CLI flags to manage MCP during run command execution is a complementary approach to these configuration-based solutions. Feel free to ignore if your specific use case requires command-line flags rather than configuration.

@github-actions[bot] commented on GitHub (Jan 25, 2026): This issue might be a duplicate of existing issues. Please check: - #5373: Allow to enable MCP on a per-agent basis (similar per-context MCP management) - #9696: Add @ mention syntax for one-time MCP server activation in chat (one-time MCP activation) - #7399: Filter which tools are loaded from MCP servers (includeTools/excludeTools config) - #9801: How can I disable a specific MCP service for a specific model? (selective MCP disabling) These issues address similar needs for selective MCP management. Your feature request for CLI flags to manage MCP during `run` command execution is a complementary approach to these configuration-based solutions. Feel free to ignore if your specific use case requires command-line flags rather than configuration.
Author
Owner

@ariane-emory commented on GitHub (Jan 25, 2026):

I would consider designing yourself a custom agent with the MCP toils that you want disabled disabled and then specifying this agent when you invoke your opencode run command.

@ariane-emory commented on GitHub (Jan 25, 2026): I would consider designing yourself a custom agent with the MCP toils that you want disabled disabled and then specifying this agent when you invoke your `opencode run` command.
Author
Owner

@R44VC0RP commented on GitHub (Jan 25, 2026):

Thanks for the feature request! This is a common workflow need.

The good news is you can achieve this today using a custom agent. Here's the pattern:

  1. Globally disable the MCP tools (so they're off by default)
  2. Create a custom agent with those tools re-enabled
  3. Use --agent flag with opencode run

Example config:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "playwright": {
      "type": "local", 
      "command": ["npx", "-y", "@anthropic-ai/mcp-playwright"]
    }
  },
  "tools": {
    "playwright_*": false  // Disabled globally
  },
  "agent": {
    "scraper": {
      "description": "Web scraping with Playwright MCP",
      "mode": "primary",
      "tools": {
        "playwright_*": true  // Enabled only for this agent
      }
    }
  }
}

Usage:

# Regular development (no Playwright)
opencode run "fix this bug"

# Web scraping (with Playwright)
opencode run "grab the pricing table from example.com" --agent scraper

The --agent flag on run lets you specify which agent to use, giving you the dynamic MCP control you're looking for.

Docs references:

Let me know if this works for your use case!

@R44VC0RP commented on GitHub (Jan 25, 2026): Thanks for the feature request! This is a common workflow need. The good news is you can achieve this today using a **custom agent**. Here's the pattern: 1. **Globally disable the MCP tools** (so they're off by default) 2. **Create a custom agent** with those tools re-enabled 3. **Use `--agent` flag** with `opencode run` ### Example config: ```jsonc { "$schema": "https://opencode.ai/config.json", "mcp": { "playwright": { "type": "local", "command": ["npx", "-y", "@anthropic-ai/mcp-playwright"] } }, "tools": { "playwright_*": false // Disabled globally }, "agent": { "scraper": { "description": "Web scraping with Playwright MCP", "mode": "primary", "tools": { "playwright_*": true // Enabled only for this agent } } } } ``` ### Usage: ```bash # Regular development (no Playwright) opencode run "fix this bug" # Web scraping (with Playwright) opencode run "grab the pricing table from example.com" --agent scraper ``` The `--agent` flag on `run` lets you specify which agent to use, giving you the dynamic MCP control you're looking for. **Docs references:** - [Per-agent MCP configuration](https://opencode.ai/docs/mcp-servers/#per-agent) - [Agent tools config](https://opencode.ai/docs/agents/#tools) Let me know if this works for your use case!
Author
Owner

@R44VC0RP commented on GitHub (Jan 25, 2026):

Closing as this functionality already exists via custom agents with per-agent tool configuration. See the comment above for the recommended pattern.

@R44VC0RP commented on GitHub (Jan 25, 2026): Closing as this functionality already exists via custom agents with per-agent tool configuration. See the comment above for the recommended pattern.
Author
Owner

@iambpn commented on GitHub (Jan 26, 2026):

Didn't know I can do this. Thanks.

@iambpn commented on GitHub (Jan 26, 2026): Didn't know I can do this. Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7527