Reclaim 30–90K context tokens with Claude Code's MCP Tool Search (`ENABLE_TOOL_SEARCH=true`)
Problem solved: Each MCP server registered in Claude Code injects 10–30K tokens of tool descriptions up-front; flipping one env var defers those descriptions until needed, recovering a large slice of the context window.
What
Claude Code 2.1.7+ shipped a native flag: when registered MCP tool descriptions exceed roughly 10% of the context window, they auto-defer and Claude discovers them on demand through an MCPSearch tool. Two-line edit to settings; restart; the boot banner shows "mcp tools (loaded on-demand)" when active. One operator reported context dropping from 93.1K MCP-token usage to 0.429K after switching to the equivalent third-party proxy — the native flag now delivers the same benefit.
Why it matters
Heavy MCP users (Figma, Linear, GitHub, Stripe, dataforseo, Chrome) commonly burn 30–50K tokens on tool descriptions before the first user message. That's a measurable hit to long-session quality. Reclaiming this is a single-line settings change with no functional regression for most setups.
End-to-end
- Upgrade Claude Code to 2.1.7 or later.
- Edit
~/.claude/settings.jsonand add the env block below. - Restart Claude Code.
- Verify on the boot banner: look for
mcp tools (loaded on-demand). - Run
/contextand confirm MCP token cost is near zero until a tool is invoked.
Prompts
{
"env": {
"ENABLE_TOOL_SEARCH": "true"
}
}
Gotchas
On-demand loading doesn't always handle MCP servers that need auth — one operator's Figma MCP failed in this mode and had to be left in the eager-load set. Also: MCP servers that expose unusually long tool descriptions can break the search-driven import path. If a specific MCP misbehaves, run with the flag off for that server and on for the rest.
Tools
- Claude Code 2.1.7 or later
- One or more registered MCP servers