Code Execution with MCP: Building More Efficient Agents
engineering blog · source date 2025-11-04 · added 2026-08-07 15:52:43 · updated 2026-08-07 15:52:43 · Open original blog
1
Problems / challenges / motivations
- Loading every MCP tool definition into context burns tokens before the agent does anything.
- Intermediate tool results flow through the model even when the model only needs a filtered summary.
- Tool selection degrades as the tool count grows.
2
Key ideas
- Presents MCP servers as code APIs the agent explores on a filesystem and calls via generated code, rather than as a flat list of tool schemas.
- Progressive disclosure loads only the tool definitions actually needed.
- Intermediate data is filtered in-sandbox before it ever reaches the model.
- Reports cutting one Drive-to-Salesforce workflow from 150k to 2k tokens (98.7%).
3
Why it matters for AI engineering
- "Code Mode" is one of the most-discussed agent-tooling patterns of the period, reframing tool selection as code plus progressive disclosure.
- It is cross-referenced by Cloudflare's Code Mode, later Anthropic advanced-tool-use releases, and much of the skill/tool-learning literature (semantic tool discovery, lazy schema loading).
- Caveat: out-of-window (November 2025). The 98.7% figure is a single-workflow, Anthropic-reported result and savings vary widely by task. Code-as-tools shifts complexity into sandboxing and security rather than eliminating it.
Comments
No comments yet.