Per-Agent MCP Server Scoping for Sub-Agents

Resolved 💬 3 comments Opened Jan 4, 2026 by seanxiong1989 Closed Jan 4, 2026

Problem

MCP tool definitions are loaded into EVERY context (main agent + all sub-agents spawned via Task()).

With many tools across multiple MCP servers, this consumes 15-20% of context capacity before any conversation begins.

The current architecture prevents building a "lightweight orchestrator + heavy specialist" pattern where:

  • Main agent has minimal tools (~5%) and routes to sub-agents
  • Sub-agents load only their domain-specific tools

Current Behavior

# Main agent has ALL tools loaded (e.g., 100+ tools)
Task(subagent_type="DatabaseExpert", prompt="...")
# DatabaseExpert sub-agent ALSO has ALL tools loaded (inherits from main)

Desired Behavior

# Main agent has minimal tools
Task(
    subagent_type="DatabaseExpert",
    mcp_servers=["sql-tools", "bigquery"],  # Only load these for this sub-agent
    prompt="..."
)
# DatabaseExpert has only relevant tools, not all 100+

Proposed Solutions

Option A: Per-agent mcp_servers in agent definition files:

# ~/.claude/agents/database-expert.md
---
name: "DatabaseExpert"
mcp_servers: ["sql-tools", "bigquery"]
---

Option B: mcp_servers parameter in Task() tool:

Task(
    subagent_type="DatabaseExpert",
    mcp_servers=["sql-tools"],  # Override for this sub-agent
    prompt="..."
)

Option C: Lazy tool loading - tools declared but definitions only sent when sub-agent is spawned with that server.

Impact

  • 60-90% reduction in sub-agent context overhead
  • Enables true multi-agent architectures with specialized tools
  • Better separation of concerns
  • Supports scaling to larger toolboxes without linear context growth

Workarounds Attempted

  • --strict-mcp-config only affects the starting session, not sub-agents
  • Profile switching requires manual session restarts
  • No way to scope tools dynamically based on agent type

Use Case

I have 6 MCP servers with ~150 total tools. Even for simple "hello" conversations, 22% of context is consumed by tool definitions. As my toolbox grows, this overhead will become prohibitive.

View original on GitHub ↗

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