Feature Request: Lazy-Loading / On-Demand MCP Tool Registration

Resolved 💬 8 comments Opened Jan 8, 2026 by dev-punia-altimate Closed Mar 6, 2026

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:

  1. At conversation start, Claude sees only descriptions of lazy servers (minimal tokens)
  2. When user mentions "check sentry for errors", Claude recognizes keyword match
  3. Claude prompts: "I need Sentry tools for this. Enable? [Y/n]"
  4. 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

  1. Token Efficiency: 90%+ reduction in base token usage
  2. Faster Startup: Less tool parsing at conversation start
  3. Better UX: Users don't need to manually manage MCP configs
  4. 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

View original on GitHub ↗

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