Feature Request: Agent-Scoped MCP Servers to Prevent Context Window Overflow
Problem
Currently, all MCP servers are loaded at the global level and their tools are
injected into the main agent's context window. This creates context pollution when
multiple MCP servers are configured - the main agent has to process tool descriptions
from all servers, even when only specific tools are needed for a particular task.
As users add more specialized MCP servers (SonarQube, Figma, Jira, etc.), the context
window gets filled with irrelevant tool descriptions, reducing efficiency and making
the system less scalable.
## Proposed Solution
Allow MCP servers to be defined directly in agent configuration files, so specialized
agents only load the tools they actually need.
### Example Configuration
```markdown
---
name: sonar-agent
description: Code quality analysis agent
tools: Glob, Grep, LS, Read, Edit, MultiEdit, Write, TodoWrite
mcpServers:
sonarqube:
command: npx
args: ["-y", "sonarqube-mcp-server@latest"]
env:
SONARQUBE_URL: "https://sonarcloud.io"
SONARQUBE_TOKEN: "..."
SONARQUBE_ORGANIZATION: "..."
excludeGlobalMcp: true
---
# SonarQube Analysis Agent
This agent specializes in code quality analysis.
```
### Benefits
- Clean Context: Main agent only sees general-purpose tools
- Self-Contained Agents: All configuration in one place
- Better Scalability: Add specialized MCP servers without affecting main agent
performance
- Focused Toolsets: Each agent gets only the tools it needs
This would allow users to create many specialized agents with their own MCP servers
without polluting the main agent's context window.
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗