Intelligently disable MCP tools for subagents to prevent context overflow

Resolved 💬 3 comments Opened Feb 26, 2026 by DanielPBak Closed Mar 3, 2026

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:

  1. The subagent's task description — if the task is "search for a file in the codebase," Slack/Discord/Notion tools are irrelevant
  2. The subagent type — an Explore agent only needs filesystem tools, not MCP integrations
  3. Explicit opt-in — allow the parent to specify which MCP servers/tools the subagent needs (e.g., tools: ["grafana"] or exclude_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.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗