A New Paradigm for MCP Tool Calling: Code Mode Saves 70% of Tokens, While the Decision Layer Becomes a Liability

Pre-registered evaluation shows code mode saves 70-90% of tokens versus standard MCP, return-shape hints have a huge impact, and decision-layer preprocessing is unconfirmed.
A pre-registered evaluation covering 12 servers, up to 1,958 distractor tools, and three open-weight agents compared two MCP tool-calling paradigms: code mode and decision-layer preprocessing. Results show code mode greatly outperforms standard MCP, cutting token usage by 70-90% while significantly improving utility. The study also found that declaring return-shape hints in code-mode stubs can cause success-rate fluctuations of up to 39.5 percentage points for weaker agents—an effect even larger than adding a router. The core hypothesis—that decision-layer preprocessing can outperform code mode alone—was not confirmed: it yielded only small, insignificant improvements for weak agents and slightly increased cost for the strongest. The team open-sourced the evaluation harness, the fine-tuned 4B tool-selection model, and all evaluation trajectories.
MCP (Model Context Protocol) gateways manage the tool catalogs of language model agents, and there are currently two main paradigms: code mode (the agent writes scripts against tool stubs) and the decision layer (a low-cost router that pre-selects a subset of tools). A pre-registered evaluation covering 12 servers, up to 1,958 distractor tools, and three open-weight agents (Qwen, Gemma, Nemotron) reveals the boundaries of success and failure for these two approaches on a sealed test set.

Code Mode Significantly Outperforms Standard MCP, Cutting Token Usage by 70-90%
The evaluation results show that code mode substantially outperforms standard MCP, reducing token usage by 70% to 90% while significantly improving utility. This means that in tool-calling scenarios, having the agent write code directly to operate tools is far more efficient than traditional tool-description matching.
This finding has direct implications for developers building local AI agents: in resource-constrained environments, code mode can greatly reduce inference costs while improving task completion quality.
MCP (Model Context Protocol) is a protocol proposed and open-sourced by Anthropic to standardize the way language models connect to external tools and data sources. In the traditional MCP paradigm, tools are listed in the system prompt as JSON Schema descriptions, and the agent uses tools by generating structured tool calls (such as a function name plus an argument object). This approach performs well when the number of tools is small, but when the tool catalog expands to hundreds or thousands, the full description of each tool occupies the context window, causing substantial token consumption and increasing the probability that the model selects the wrong tool. Code mode changes the form of interaction: instead of outputting tool calls directly, the agent writes a piece of code against pre-provided tool stubs (i.e., function signatures plus brief documentation), and a runtime executes that code to complete the tool call. In this way, the specific parameters of the tools and the logic for handling returns are expressed in code, and the model only needs to understand the stub signatures, thereby significantly compressing context usage.
Return-Shape Hints: A First-Order Variable in Code Mode
The research reveals an easily overlooked but enormously influential factor: declaring return-shape hints in code-mode stubs. For weaker agents, this single operation can cause success rates to fluctuate by as much as 39.5 percentage points, an effect even larger than adding a router.
Return-shape hints let the agent know in advance the data structure a tool returns, enabling it to write more accurate code. This suggests that in code mode, the clarity of interface design matters more than an additional routing layer.
Return-shape hints refer to explicitly declaring, in the tool stubs of code mode, structural information about the data returned after a successful tool call—for example, the field names, types, and nesting relationships of the returned object, or the element structure of a returned array. Without such hints, the agent can only infer the return value from the tool name and parameter descriptions, making it prone to writing code that makes incorrect assumptions about the returned result—for example, iterating over an object as if it were an array, or accessing a nonexistent field. For less capable models, such inference errors directly lead to runtime exceptions or task failures, so declaring the return shape can greatly reduce trial-and-error costs. Note that return-shape hints differ from the output schema in JSON Schema: the former is aimed at the code writer (the agent) and is presented as human-readable comments or type annotations, while the latter is typically used to validate runtime output. The 39.5 percentage-point fluctuation observed in the study precisely demonstrates that the completeness of interface information is especially critical for weaker models.
Decision-Layer Preprocessing: Hypothesis Unconfirmed, Slightly Costly for Strong Agents
The core hypothesis of the study—that adding a decision layer before code mode can outperform code mode alone—was not confirmed. For weaker agents, the decision layer brought a small, statistically insignificant improvement; for the strongest agent, it instead produced a slight cost increase.
This result challenges the intuition that "more routing layers are always better." The value of the decision layer may be limited to specific scenarios rather than being a universal optimization.
The decision layer is a lightweight routing mechanism: before the agent formally processes a task, a small model or classifier first pre-selects a relevant subset of tools from the full tool catalog based on the user request, and then passes that subset to the downstream agent. Its original design intent is to narrow the search space and reduce the context burden so that the agent does not have to face all tool descriptions. However, routing itself also consumes inference resources and may, due to misjudgment, exclude genuinely useful tools, creating an information bottleneck. The 4B tool-selection model used in the study is an example of such a decision-layer component. Experimental results show that when the agent itself already uses code mode and the stub information is sufficiently clear, the decision layer offers limited benefit, and for strong agents it even slightly increases cost due to the extra routing overhead. This suggests that the applicability conditions for the decision layer are rather stringent: pre-selection may be worthwhile only when the tool catalog is extremely large and the agent is not capable enough to filter on its own.
Open-Sourcing Tools and Models to Advance Community Experimentation
The research team has released the evaluation harness, a fine-tuned 4B tool-selection model, and all evaluation trajectories to support robust community experimentation on local AI privacy and agent architectures.
The release of these resources means developers can reproduce the experiments, verify the conclusions, and build on them to explore MCP tool-calling strategies better suited to their own scenarios.
Practical Takeaways
For teams building MCP agents, the following recommendations are worth considering:
- Prioritize code mode: when the tool catalog is large, code mode delivers significant token savings and utility gains.
- Pay attention to return-shape hints: explicitly declare the return data structure in tool stubs—especially for less capable models, this can greatly improve success rates.
- Add a decision layer with caution: unless there is clear evidence that your agent needs tool pre-selection, the decision layer may simply add cost.
- Leverage open-source resources: use the public evaluation harness and fine-tuned model to quickly validate how different architectures perform in your scenario.
This study provides data-driven guidance for the design of MCP tool calling, and also reminds us that in agent architectures, simple and clear interface design is often more effective than complex routing mechanisms.
Related articles

Gemini 4 Neon Review: Benchmark Scores Rival Carbon, API Pricing and Quota Breakdown
Google Gemini 4 Neon is now live, benchmark scores closely tracking Carbon, API pricing 3/15 at twice Hydrogen's rate. This article compiles Bilibili creator testing: Neon can replace 90% of Carbon scenarios, AntiGravity quota consumption is only one-third of Carbon, plus subscription channel restrictions and 2API ban risks.

Gemini 4 Helium Coming Soon? Signals of Google Loosening Subscription Restrictions
Google team member hints releases will continue; community speculates Gemini 4 Helium (Flash Lite) may be next. Subscription ban controversy gets a response as product lead says "Soon," suggesting restrictions may be lifted. This article covers Gemini developments, OpenAI Coding Agent and risk management, Doubao real-time audio-video API, and compute business dynamics.

AI-Assisted React Development in Practice: Optimizing a Video App and Handling Errors
A 14-year veteran developer demonstrates AI-assisted React video app optimization: compressing video from 80MB to 5MB (~94%) via ImageKit, plus reliable error handling and retry mechanisms. Includes planning, code understanding, and verification methods for working with AI.