OpenCode MCP and token overhead
Each enabled MCP server in OpenCode adds tool schemas to agent context on every turn—even when no MCP tool is called. That is the main MCP token overhead.
This page answers opencode disable mcp, lazy-load patterns, and when to prefer built-in grep / glob.
Hub: Tokenminning in OpenCode.
Why MCP blows up context
| What loads | When | Cost |
|---|---|---|
| Tool names + JSON schemas | Every agent turn | Input tokens |
| Tool results | When invoked | Input on later turns |
OpenCode MCP docs warn that GitHub MCP and similar broad servers can exceed context limits quickly. Five overlapping servers can dwarf your actual prompt.
Measure before/after with opencode stats when enabling a new server.
Disable MCP servers
Turn off whole servers in opencode.json:
{
"mcp": {
"github": { "enabled": false },
"playwright": { "enabled": false }
}
}Disable MCP tools globally, enable per-agent when needed:
{
"tools": { "my-mcp*": false }
}Per-agent patterns (enable only on Build):
{
"agent": {
"plan": {
"tools": { "github-mcp*": false }
}
}
}Check your OpenCode version’s agent tool permissions for exact syntax.
Lazy-load pattern
Lazy MCP means: default off, enable only for the agent and week you need it.
- Set
"enabled": falseon all non-essential servers - Enable one narrow server for the current task (e.g. Playwright only while debugging UI)
- Run
opencode stats --days 1before and after
Skills already lazy-load full content; MCP does not — schemas are always present until disabled.
Built-in tools vs MCP
For local codebases, prefer:
| Need | Use | Avoid |
|---|---|---|
| Text search | Built-in grep / glob | MCP codebase search |
| Read file | Built-in read | Pasting file in chat |
| GitHub API | MCP only when remote PR/issue data required | MCP for local git status |
One task-specific MCP server beats five general-purpose integrations.
Skills vs MCP
Skills load metadata every turn but full content only when the skill tool runs. Good for occasional workflows.
- Disable
skilltool on Plan if you want zero skill metadata in planning sessions - Use
permission.skillto hide experimental skills
Troubleshooting
Spike after enabling MCP — Schemas attach every turn. Disable globally; enable per-agent.
High input, low tool use — MCP bloat without invocations. Audit enabled servers.
Context overflow with MCP — Combine disable MCP with compaction.