Feature Request: Lazy-Loading / On-Demand MCP Tool Registration
Summary
Add support for lazy-loading MCP servers so tools are only registered when needed, rather than loading all tools at conversation start. This would dramatically reduce token consumption for users with multiple MCP servers configured.
Problem
Currently, all configured MCP servers load their tools at conversation start, consuming significant context tokens:
| Server | Tools | Tokens |
|--------|-------|--------|
| notion | 14 | ~30k |
| github | 37 | ~27k |
| atlassian | 22 | ~20k |
| sentry | 18 | ~21k |
| playwright | 22 | ~14.5k |
| serena | 29 | ~20k |
| Total | 142 | ~150k |
Real-world impact: In a typical debugging session, I only used 6 tools (~6.6k tokens) but paid for 150k tokens of tool definitions. That's 95% waste.
Proposed Solution
Option A: Keyword-Triggered Loading (Recommended)
{
"mcpServers": {
"sentry": {
"command": "npx",
"args": ["-y", "@sentry/mcp-server"],
"lazyLoad": {
"enabled": true,
"triggerKeywords": ["sentry", "error", "debug", "issue", "stacktrace"],
"description": "Error tracking and debugging tools"
}
},
"notion": {
"command": "npx",
"args": ["@notionhq/mcp-server"],
"lazyLoad": {
"enabled": true,
"triggerKeywords": ["notion", "document", "wiki", "page"],
"description": "Notion workspace tools"
}
}
}
}
Behavior:
- At conversation start, Claude sees only descriptions of lazy servers (minimal tokens)
- When user mentions "check sentry for errors", Claude recognizes keyword match
- Claude prompts: "I need Sentry tools for this. Enable? [Y/n]"
- On approval, tools are loaded and available for rest of conversation
Option B: Explicit Request Tool
Add a built-in tool:
enable_mcp_server(server: string): void
// Claude can call this when it determines tools are needed
Option C: Category-Based Loading
{
"mcpServerGroups": {
"debugging": ["sentry", "github"],
"documentation": ["notion", "atlassian", "confluence"],
"testing": ["playwright"],
"coding": ["serena", "morph-mcp"]
},
"defaultGroup": "coding"
}
Benefits
- Token Efficiency: 90%+ reduction in base token usage
- Faster Startup: Less tool parsing at conversation start
- Better UX: Users don't need to manually manage MCP configs
- Scalability: Users can install many MCPs without penalty
Alternatives Considered
| Approach | Limitation |
|----------|------------|
| Multiple config profiles | Manual switching, no mid-conversation loading |
| Meta-MCP proxy server | Requires custom development per user |
| Remove unused MCPs | Tedious, loses functionality when needed |
Additional Context
- MCP protocol may need extension for dynamic tool registration
- Could be implemented client-side in Claude Code without protocol changes
- Similar to VS Code's extension activation events
Willingness to Contribute
I'd be happy to help with design discussions or implementation if this moves forward.
---
Environment:
- Claude Code version: Latest
- OS: macOS
- MCP Servers: 8 configured, typically use 2-3 per session
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗