How to turn Claude Code's MCP tool search on or off behind an LLM gateway
Claude Code doesn't load every MCP tool definition upfront. Tool search finds and loads tools when they're needed. Until now, pointing ANTHROPIC_BASE_URL at a non-Anthropic host (an LLM gateway or proxy) turned tool search off automatically, so all MCP tools loaded into context at the start. Starting with 2.1.304, released October 19, tool search is on by default behind such hosts too. If the gateway rejects the request with a 400 or 422, Claude Code retries without it. The environment variable table in the docs still describes the old behavior.
To turn it off from the start instead of relying on the retry, set ENABLE_TOOL_SEARCH to false.
ENABLE_TOOL_SEARCH=false claude
To load tools upfront only when their definitions are small, use threshold mode. auto loads them upfront while the definitions total less than 10% of the context window, and auto:N changes that threshold to N%.
ENABLE_TOOL_SEARCH=auto:5 claude
To avoid typing it every time, put it in the env field of settings.json.
{
"env": {
"ENABLE_TOOL_SEARCH": "auto:5"
}
}
With CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS set, tool search stays off whatever you put in ENABLE_TOOL_SEARCH.
Sources
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.