Skip to content

Feature: Lazy-load MCP tool schemas to reduce context usage #23787

Description

@emreceviz10

Problem

All configured MCP server tool schemas are loaded into context at conversation start, regardless of whether they're used. With multiple MCP servers (e.g., Supabase, GitHub, Context7), this can consume ~25k+ tokens just for tool definitions — over 50% of the initial context budget before the user even sends a message.

This leaves significantly less room for actual conversation, code context, and reasoning — especially in longer sessions where context compression kicks in.

Proposed Solution

Lazy-load MCP tool schemas on demand instead of eagerly loading all of them at conversation start.

How it could work:

  1. At conversation start, Claude receives only a lightweight summary of available MCP servers (name, description, number of tools) — maybe ~200 tokens per server instead of ~5-10k
  2. When Claude determines it needs to use a tool from a specific MCP server, the full tool schemas for that server are loaded into context at that point
  3. Optionally, servers could be marked as "always eager" vs "lazy" in the MCP config for frequently-used servers

Example summary vs full load:

# Summary (~50 tokens)
Supabase MCP: 22 tools for database operations, migrations, edge functions, branches

# Full schema (~8k tokens)  
[all 22 tool JSON schemas with parameters, descriptions, enums...]

Impact

  • Context savings: ~20-25k tokens freed up per conversation for users with 3+ MCP servers
  • Longer effective conversations before context compression
  • Better scaling as users add more MCP servers — cost grows linearly today but would stay nearly flat
  • No functionality loss — all tools remain available, just loaded when needed

Current Workarounds

  • Manually toggling MCP servers on/off per session (tedious)
  • Splitting configs into "always-on" vs "on-demand" groups
  • Accepting the context tax and working with less headroom

None of these are great. The platform should handle this transparently.

Additional Context

Measured in a real project with Supabase + GitHub + Context7 MCP servers configured:

  • Tool definitions: ~25k tokens (~53% of initial context)
  • System instructions: ~15k tokens
  • Project context (CLAUDE.md, git status): ~2.5k tokens
  • Actual conversation: starts with less than half the context available

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions