Skip to Content

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 loadsWhenCost
Tool names + JSON schemasEvery agent turnInput tokens
Tool resultsWhen invokedInput 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.

  1. Set "enabled": false on all non-essential servers
  2. Enable one narrow server for the current task (e.g. Playwright only while debugging UI)
  3. Run opencode stats --days 1 before 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:

NeedUseAvoid
Text searchBuilt-in grep / globMCP codebase search
Read fileBuilt-in readPasting file in chat
GitHub APIMCP only when remote PR/issue data requiredMCP 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 skill tool on Plan if you want zero skill metadata in planning sessions
  • Use permission.skill to 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.

Last updated on