AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Oct 27, 2026, 13:00 JST

Claude Code test: 587-token saving costs 4,225 in gateway setup

Send on LINE
Claude Code test: 587-token saving costs 4,225 in gateway setup

3 Key Points

  1. What happened

    In 12 runs on Claude Code 2.1.302, listing 40 tools directly added 587 tokens upfront, while the gateway added 13 — but fetching the gateway's tool list once added 4,225 tokens, about 7.2 times the savings.

  2. Why it matters

    The upfront saving covers tool names only, while the gateway's list carries names, descriptions and schemas together, so the bill lands when the list is fetched and stays in the conversation history.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The test set out to check a design idea seen on X: put all of an organization's MCP servers behind one gateway, so the agent searches through it and enables only the needed tools. MCP here is a standard plug for connecting AI to external tools and data; each MCP server exposes a handful of callable tools. The author could not reach the implementation or scale described in that post from a sandbox, so instead built a small version locally with 40 tools — one real and 39 decoys with similar names — and measured token flow across four conditions.

The result inverted the author's expectation. Directly listing 40 tools added 587 tokens upfront (about 15.051 per tool), but that upfront figure covers names only, because descriptions are fetched just before a call. The gateway's list, by contrast, is a single JSON string carrying names, descriptions and schemas, which is why fetching it once added 4,225 tokens for 10,862 bytes across 40 entries. The extra fetch also added a turn, and the gateway's cumulative reused input reached about 182k versus about 139k for the direct method.

What did hold up was tool selection: with 39 look-alike decoys, the AI never called one, and even without any instruction on how to use the gateway, it reached the two-step list-then-invoke path in all three runs. The author is careful to note the limits — one sandbox, one server, 40 tools, one model, and three runs per condition — and that the list cost should shrink per call in jobs that call tools many times, a case not yet measured.

FAQ
What is a gateway in this context?
It is a setup that shows the AI only two tools — list_capabilities to fetch the tool list and invoke to call a named tool — instead of exposing all 40 tools directly.
Did the gateway actually save tokens overall?
No. Upfront input dropped from 587 extra tokens to 13, but one list fetch added 4,225 tokens, and the gateway also used 5 turns versus 4 for the direct method in all 12 runs.
Did adding 39 decoy tools confuse the AI?
No. In the 12 runs, the AI never called a decoy, and in all three direct-40 runs it named the real tool in one shot without reading descriptions.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleChatGPT tells locked-out Instagram user to email 404 Media