Intelligently disable MCP tools for subagents to prevent context overflow
Problem
When many MCP servers are connected (Grafana, Linear, Sentry, Slack, Notion, Discord, etc.), their tool definitions consume a large portion of the context window. Subagents spawned via the Task tool inherit all these tool definitions even when the subagent's task doesn't need them. This causes subagents to fail immediately due to context overflow, especially with smaller models like Haiku.
Proposed Solution
When spawning a subagent, Claude Code should intelligently filter which MCP tools are included in the subagent's context based on:
- The subagent's task description — if the task is "search for a file in the codebase," Slack/Discord/Notion tools are irrelevant
- The subagent type — an
Exploreagent only needs filesystem tools, not MCP integrations - Explicit opt-in — allow the parent to specify which MCP servers/tools the subagent needs (e.g.,
tools: ["grafana"]orexclude_tools: ["slack", "discord"])
Impact
This is a significant usability issue for users with multiple MCP servers connected. Subagents become unusable because tool definitions alone can exhaust the context budget, even before the agent starts working. Users are forced to either disconnect MCP servers or avoid subagents entirely.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗