Claude Code Tool Search: Defer MCP Tools, Save Context

Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, and full schemas are fetched on demand. It means adding more MCP servers has minimal impact on your context window, and Claude Code imposes no fixed per-server tool cap.
Leave it unset for the default, where all MCP tools are deferred. Set it to true to force deferral through a proxy, false to load everything upfront, or auto to load definitions upfront while they total under 10 percent of the context window. Use auto:N for a custom percentage, such as auto:5.
Set alwaysLoad to true in that server's entry in .mcp.json. Every tool it exposes then loads at session start regardless of the ENABLE_TOOL_SEARCH value. A server can also mark individual tools always-loaded through the tool's metadata, which is better than exempting a whole server when only one tool is needed constantly.
Yes, significantly. When tools are deferred, a server connecting, disconnecting or changing its tool list only appends content and leaves the cache intact. When tools load into the prefix, any change invalidates the cache and the next request re-reads the entire conversation — so an unstable MCP server quietly costs you a full uncached turn each time it reconnects.
Claude Code falls back to loading tools upfront when ANTHROPIC_BASE_URL points at a non-first-party host, on Microsoft Foundry deployments hosted on Azure that reject it server-side, and on Google Cloud Agent Platform models earlier than the Claude 4.5 generation. Setting CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS also keeps it off and cannot be overridden.

Key Takeaway
Claude Code tool search defers MCP tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window. It is on by default on supported models, configured through ENABLE_TOOL_SEARCH, and switched off per server with alwaysLoad.
I connected a sixth MCP server and my sessions got measurably worse before they got better. Not because any single tool was bad — because every one of those servers was publishing its full tool schemas into the system prompt on every request, and the model was reading a catalogue before it read the question.
Tool search is the fix, and it has been the default long enough that most people never see the problem. This post is for the case where you do: when you are running a lot of servers, when you are behind a gateway that silently turns deferral off, or when you want one server's tools present on every turn. It covers the four configuration values, the alwaysLoad escape hatch, the prompt-cache consequence that nobody mentions, and what MCP server authors should do about it.
Claude Code orders each request so that rarely-changing content comes first: the system prompt with its tool definitions, then project context, then the conversation. That ordering is what makes prompt caching work. Tool definitions sit in the very first layer, which means two things at once — they are paid for on every request, and any change to them invalidates everything cached behind them.
So a server with forty verbose tool schemas is not a one-time cost you pay at startup. It is rent, charged on every turn, on a layer where a mid-session reconnect can also cost you the entire cached conversation. Claude Code imposes no fixed per-server tool cap; the practical limit is your context budget, and that limit arrives faster than people expect.
Tool search is enabled by default: MCP tools are deferred and discovered on demand, with only names and server instructions loaded upfront. The environment variable exists for the cases where the default is wrong for your setup.
What each value does:
| Value | Behaviour | When to reach for it |
|---|---|---|
| unset | All MCP tools deferred, with fallbacks for unsupported setups | The default, and correct almost always |
| true | Forces deferral and sends the beta header through proxies | Behind a proxy you know forwards tool_reference blocks |
| auto or auto:N | Loads definitions upfront while they stay under the threshold | A handful of small servers, where a search step is pure latency |
| false | Everything loaded upfront, no deferral at all | Debugging, or a provider that rejects the beta |
# Tool search is ON by default. These override it.
# Threshold mode: load definitions upfront while they total
# under 10% of the context window, defer all of them past that.
ENABLE_TOOL_SEARCH=auto claude
# Same, with your own percentage (N is 0-100).
ENABLE_TOOL_SEARCH=auto:5 claude
# Force deferral even through a proxy. Requests FAIL on proxies
# that do not support tool_reference blocks — that is the trade.
ENABLE_TOOL_SEARCH=true claude
# Load everything upfront, the pre-tool-search behaviour.
ENABLE_TOOL_SEARCH=false claude
# Or put it in the env block of settings.json so it applies
# to every session rather than the one you remembered to flag.Some tools Claude needs on effectively every turn, and making it run a search step first is pure latency for no context saving. The alwaysLoad field exempts a server from deferral entirely, and it is available on every server type. Use it for a small number of tools, because each upfront tool consumes context that would otherwise be available for your actual conversation.
// .mcp.json — exempt ONE server from deferral. Every tool it
// exposes loads at session start regardless of ENABLE_TOOL_SEARCH.
{
"mcpServers": {
"core-tools": {
"type": "http",
"url": "https://mcp.example.com/mcp",
"alwaysLoad": true
}
}
}
// Cost: alwaysLoad makes STARTUP WAIT for that server's tools,
// capped at the standard 5-second connect timeout, because they
// have to be present when the first prompt is built. Other
// servers connect in the background.
//
// A server can also mark a SINGLE tool always-loaded by putting
// "anthropic/alwaysLoad": true in that tool's _meta object.
// To remove the search step itself rather than the deferral:
{
"permissions": { "deny": ["ToolSearch"] }
}Setting alwaysLoad makes startup wait for that server's tools, capped at the standard five-second connect timeout, because they have to be present when the first prompt is built. Other servers connect in the background. A remote server with a valid cached entry supplies its tools from the cache without connecting, so it does not hold startup — which means the flag is much cheaper on a server you have already connected to than on a cold one.
This is the part I did not expect, and it changed how I think about MCP stability. When tools are deferred, a server connecting, disconnecting or changing its tool list only appends new content — it does not disturb anything already cached. When tools are loaded into the prefix, any change to them invalidates the cache and the next request re-reads your entire conversation.
That matters because MCP servers disconnect without you doing anything. A stdio server's process exits, an HTTP session expires, a server reconnects after a transient failure, or a connected server pushes a dynamic tool update that changes its list. With deferral on, none of that costs you the conversation cache. With deferral off, a flaky server is quietly charging you a full uncached turn every time it blinks.
If your cache creation tokens stay high turn after turn and you cannot work out why, check whether tool search is actually active before you look at anything else. A gateway that disabled it plus one unstable stdio server is a combination that reprocesses your whole history on a schedule you never set.
The default is deferral, but Claude Code falls back to upfront loading in several situations, and none of them announce themselves:
Deferral changes what your server should publish. Claude only sees tool names and your server instructions until it decides to search, so the instructions field is doing the job a skill description does — it has to explain when Claude should come looking:
A server can mark a single tool as always-loaded by including the alwaysLoad marker in that tool's metadata object, rather than exempting the whole server. That is the right granularity for a server with one tool Claude needs constantly and thirty it needs occasionally, and it is a much better neighbour than setting the flag at the server level.
These are two different things and it is worth separating them. Deferral is about what loads into the prefix; the ToolSearch tool is how Claude retrieves a deferred definition later. You can deny the tool with a permission rule, which leaves deferral in place but removes Claude's ability to fetch what was deferred — useful when you want the context saving and have made every tool Claude actually needs always-loaded.
For organisations, the controls sit somewhere else again. Managed settings can keep tool search on across an organisation, and managed MCP configuration governs which servers users may connect to at all. If your goal is bounding context cost across a team rather than in your own session, that pair is the lever, not the environment variable.
The rule I use now is simple: leave tool search on, mark the two or three tools you genuinely use every turn as always-loaded, and treat a persistently high cache-creation count as a signal that something in the tool layer is moving. The context saving is the headline, but the reason I care is the cache — deferral is what stops an unreliable MCP server from quietly costing you your conversation history every few minutes.
Sources & further reading