Per-agent and per-session MCP server toggles to control context budget
Problem
When a session has many MCP servers connected (PostHog, Gmail, Google Calendar, Slack, Google Drive, Firecrawl, etc.), the tool definitions consume a huge chunk of context — even with deferred loading, the tool names and descriptions are still present.
In my setup, ~232 MCP tools cost ~120-150k tokens of static overhead. When I dispatch a subagent on haiku (200k context), there's only 10-50k tokens left for actual work. The agent hits compact_boundary and produces hallucinated summaries instead of code.
Current workarounds
- Agent
tools:allowlist — works but is all-or-nothing. Listing only built-in tools implicitly drops all MCP tools. There's no way to say "keep PostHog but drop Gmail and Slack."
ENABLE_CLAUDEAI_MCP_SERVERSenv var — single binary switch for all cloud connectors. Can't selectively enable one.
- Shell aliases that set/unset the env var before launching
claude— clunky, requires restarting the session to change.
Proposed solution
1. Per-agent MCP server exclusion (agent frontmatter)
---
name: implementer
model: haiku
tools: Read, Grep, Glob, Bash, Edit, Write
excludeMcpServers: ["PostHog", "Gmail", "Slack", "Google Calendar"]
---
Or the inverse — an include list:
---
name: analytics-agent
model: sonnet
includeMcpServers: ["PostHog"]
---
This lets the orchestrating parent keep full MCP access while subagents only get what they need.
2. Per-session MCP server toggles (runtime)
A way to toggle individual MCP servers on/off without restarting the session. Could be:
/configswitches:/config mcp.gmail enabled=false- A
/mcpcommand:/mcp disable Gmail - Settings in
settings.jsonthat are hot-reloadable
Use case
I run an orchestrator pattern where Opus coordinates and dispatches haiku/sonnet subagents. The orchestrator needs all MCP tools available for planning. The implementation subagents need only filesystem tools. The analytics agent needs only PostHog. Today I can't express this — it's either "all tools" or "only built-in tools."
Granular MCP server toggles at both the agent and session level would let users control their context budget precisely, which is especially important for smaller-context models like haiku.
Environment
- Claude Code CLI on Linux (WSL2)
- ~232 MCP tools from 7 cloud connectors
- 121 registered skills
- Subagents on haiku (200k context) are most affected
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗