[BUG] Tool Search (ENABLE_TOOL_SEARCH) does not defer HTTP/Streamable HTTP MCP tools — 120K tokens loaded upfront on every session

Resolved 💬 3 comments Opened Mar 28, 2026 by nestorcolt Closed Apr 28, 2026

Environment

  • Claude Code: v2.1.86 (also reproduced on v2.1.85)
  • OS: Linux (WSL2, Ubuntu)
  • Plan: Claude Max
  • Model: Sonnet 4.6 (200K context) and Opus 4.6 (1M context)

MCP Configuration

One HTTP MCP server connecting to a LiteLLM MCP gateway that exposes ~250 tools from 16 upstream servers:

{
  "mcpServers": {
    "gateway-prod": {
      "type": "http",
      "url": "http://<internal-ip>/mcp/",
      "headers": { "Host": "<redacted>", "Authorization": "Bearer ${KEY}" }
    }
  }
}

Problem

ENABLE_TOOL_SEARCH does not defer tools from HTTP transport MCP servers. All ~250 tool schemas are loaded inline into context on every session, consuming 120K tokens (60% of Sonnet 200K context) before the first user message.

Evidence

Without gateway-prod (only stdio MCP + IDE tools):

MCP tools: 290 tokens (0.1%)
Total context: 34k/200k (17%)

With gateway-prod connected (HTTP transport):

MCP tools: 120.2k tokens (60.1%)
Total context: 155k/200k (77%)

After ONE "hey" message: 88% context used, 0% until auto-compact.

Settings confirmed:

// ~/.claude/settings.json
{ "env": { "ENABLE_TOOL_SEARCH": "auto:5" } }
$ env | grep ENABLE
ENABLE_TOOL_SEARCH=auto:5

Feature flags (from .claude.json):

tengu_mcp_tool_search: true
tengu_hawthorn_window: 200000

Reproduction

  1. Configure an HTTP MCP server with 50+ tools
  2. Set ENABLE_TOOL_SEARCH=auto:5 (or true)
  3. Open Claude Code, run /context
  4. Observe: all HTTP MCP tools loaded inline, not deferred
  5. Disable the HTTP server via /mcp, keep only stdio servers
  6. Run /context again — MCP tools drop to <300 tokens (stdio tools ARE deferred)

Expected Behavior

HTTP/Streamable HTTP MCP tools should be deferred behind ToolSearch the same way stdio MCP tools are. The transport type should not affect whether tool schemas are loaded upfront or on-demand.

Impact

  • Sonnet 4.6 (200K) is unusable with any HTTP MCP gateway — 60% context consumed before first message
  • Opus 4.6 (1M) works but wastes 120K tokens per session
  • Users with MCP gateways (LiteLLM, Cloudflare AI Gateway, custom proxies) are disproportionately affected
  • Cost: ~$0.60/session wasted on Opus, Sonnet sessions auto-compact within 2 messages

Possibly Related

  • #30920 — defer_loading=true conflicts with cache_control at API level (may be the root cause — Claude Code silently falls back to full loading for HTTP tools)
  • #25894 — Closed as duplicate of #25440 → #12164, but those are about tools not loading AT ALL, not about deferral
  • #18397, #19560 — Tool search not activating (different symptoms but potentially same root cause for HTTP transport)

Workaround

None for HTTP transport. Only option is to use Opus 1M where 120K is 12% instead of 60%.

View original on GitHub ↗

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