-
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
MCP servers often expose many tools, but agents typically need only a subset. Currently, enabling an MCP loads all its tools into the context window, adding significant token overhead.
Example: The chrome-devtools MCP provides 26 tools (~17k tokens). A UI preview agent might only need 4 of them (~1.5k tokens).
Proposed Solution
Add includeTools and/or excludeTools to MCP configuration:
{
"mcp": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest"],
"includeTools": ["navigate_page", "take_screenshot", "new_page", "list_pages"]
}
}
}Or with glob patterns:
{
"mcp": {
"github": {
"includeTools": ["create_*", "list_*"],
"excludeTools": ["*_dangerous_*"]
}
}
}Per-Agent Override
Combined with per-agent MCP enabling, this allows fine-grained control:
{
"mcp": {
"chrome-devtools": {
"enabled": false,
"includeTools": ["navigate_page", "take_screenshot", "new_page", "list_pages"]
}
},
"agent": {
"ui-preview": {
"mcp": {
"chrome-devtools": { "enabled": true }
}
}
}
}Prior Art
Amp recently shipped this feature: Lazy-load MCP with Skills
Their implementation uses a companion mcp.json file per skill. The approach proposed here integrates with OpenCode's existing centralized config pattern.
Benefits
- Token savings: Load only needed tools (17k → 1.5k in the chrome-devtools example)
- Reduced confusion: LLM sees only relevant tools
- Backward compatible: No
includeTools= all tools (current behavior)
Related Issues
- Reduce token overhead: Task tool injects all subagent descriptions into system prompt #7269 - Subagent list filtering (complementary - filters subagents, not MCP tools)
- [FEATURE]: Provider/Model-specific MCP servers #6024 - Provider/model-specific MCPs (complementary - when to load MCPs)
- [FEATURE]: Tool call descriptions as skills #7362 - Tool descriptions as skills (similar goal, different approach)
Contribution
Happy to submit a PR for this if the approach is acceptable. We're tracking this in aidevops and can implement a workaround in the meantime, but native OpenCode support would be cleaner.