Anthropic Recommends Code Execution for Efficient AI Agents, Acknowledging Model Context Protocol's Limitations
The Model Context Protocol (MCP), an open standard for connecting AI agents to external systems, is facing renewed scrutiny as its creator, Anthropic, has published an article advocating for code execution as a more efficient approach. Initially positioned to simplify agent-tool integration, MCP has been criticized by the developer community for inherent design flaws, including excessive context consumption, reduced model efficacy, and the absence of critical features such as OAuth and progressive tool discovery. Developers noted a proliferation of observability and tooling layers for MCP, disproportionate to actual product development utilizing the protocol, echoing past concerns seen in early Web3 infrastructure. Key issues identified include tool definition overloading context windows and intermediate tool results continually consuming additional tokens, leading to increased costs and latency—with one example demonstrating a 98.7% reduction in token usage (from 150,000 to 2,000 tokens) when moving to a code-based approach.
Anthropic’s new guidance, titled “Code execution with MCP, building more efficient agents,” suggests that agents write code (e.g., TypeScript) to interact with MCP servers as code APIs rather than relying on direct tool calls. This method allows agents to load only necessary tools, filter and transform data within a secure execution environment before passing results to the model, and manage state and privacy more effectively. Benefits include enhanced data security by keeping sensitive information out of the model’s context and improved tool composition through deterministic logic and reusable functions. This shift validates earlier findings from companies like Cloudflare, which implemented a similar ‘code mode’ for agent interactions, and underscores a growing consensus within the engineering community that robust software engineering principles, rather than solely LLM-centric designs, are crucial for scalable and efficient AI agent development.