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
Wow this feature is requested a lot!
ENABLE_TOOL_SEARCH works pretty darn well for a beta - try it!
I've had this same frustration and had some shower thoughts:
Instead of explicit keywords, we could leverage a) Skills; b) plugins; c) the fact there's already a LLM available.
So a MCP does not be loaded in full into the context; it seems like it should be possible to instead load a MCP as a plugin that exposes skills/slash commands (?). When a MCP is first initialized, Claude could feed its individual tool definitions into Haiku and have it generate a skill definition with a summarized front matter. (And maybe regenerate automatically when the checksum of the long tool description changes.)
Assuming that long form skill definitions aren't preserved across compactions (since they can always be reloaded), this should alleviate the immediate pain point in a fairly simple way that fits the CC of doing things. Then down the line someone smarter than me can look into say whether there's a point in making "MCP skills" use forked contexts or not.
We(me and Agents) implemented a similar pattern in our multi-agent system running on EC2. Instead of keyword triggers, we use Claude's native tool_choice="auto" for intent classification:
- If
stop_reason == "tool_use"→ Work mode (initialize LSP, memory, tracing, load full toolset) - Else → Chat mode (respond directly, skip heavy initialization)
We also segment tools by agent role:
- Worker agent: bash, file write, LSP (full access)
- Codebase agent: file read, LSP (read-only verification)
- Research agent: web_fetch, web_search only
Each agent only sees the tools it needs for its job. This naturally solves the token bloat problem - a verification pass doesn't load 40 tools when it only needs 3.
I'm updating with this native approach now. Thanks.
Guys MCPSearch is live, as of a few days ago!
This is basically what https://github.com/smart-mcp-proxy/mcpproxy-go does at proxy level - BM25 search means only relevant tools get sent to the model per query instead of loading everything upfront. Went from ~54K to under 1K tokens in practice.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.