Skip to main content
Code mode, aka code execution, builds on top of MCP although this is largely a MCP client (not server) innovation. Adam Azzam put it well:
“MCP standardizes how a client discovers what tools exist, fetches schemas, authorizes access … Once you have capabilities, you choose how to present them to the model, [of which generating TypeScript code, as Cloudflare’s post suggests, is one good option].” That good option falters in many scenarios, despite performing well in others, and so only suits a small subset of AI <> MCP possibilities.

Advantages of code execution

Benefits of code execution:
  1. Enables agents to use context more efficiently by loading tools on demand (Anthropic have shown how MCP code execution slashes token usage in AI agents by 98.7%)
  2. Enables agents to filter data before it reaches the model
  3. Enables agents to execute complex logic in a single step (loops, conditionals, and error handling can be done with familiar code patterns rather than chaining individual tool calls)
  4. Intermediate results stay in the execution environment by default. This way, the agent only sees what you explicitly log or return
  5. Agents can write intermediate results to files, enabling them to resume work and track progress. Agents can also persist their own code as reusable functions.
“LLMs are adept at writing code and developers should take advantage of this strength to build agents that interact with MCP servers more efficiently.” https://www.anthropic.com/engineering/code-execution-with-mcp

Disadvantages of code execution

Note that code execution introduces its own complexity. Running agent-generated code requires a secure execution environment with appropriate sandboxing, resource limits, and monitoring. These infrastructure requirements add operational overhead and security considerations that direct tool calls avoid. The benefits of code execution—reduced token costs, lower latency, and improved tool composition—should be weighed against these implementation costs.

Why code mode doesn’t really matter

Specifically related to Growth Method, our customers are focused on relatively short-term campaign cycles that do not involve large datasets. There is no need to fetch a 10,000 row spreadsheet, for example, where filtering and transforming results in code before returning them to the LLM would be beneficial. Additionally, code execution is not a replacement is a client implementation tweak (and one that could provide a signficant performance and cost improvement). From a Growth Method perspective, if a well-designed MCP client starts using Code Mode (or some equivalent) we do not have to change our MCP implementation.

Resources

Code execution with MCP: Building more efficient agents by Anthropic Code Mode: the better way to use MCP** **by Cloudflare What if you don’t need MCP at all?** **by Mario Zechner Code Mode Isn’t a Critique of MCP by Adam Azzam It’s time to critique MCP** **by Kent C. Dodds https://www.anthropic.com/engineering/advanced-tool-use https://cursor.com/blog/dynamic-context-discovery#4-efficiently-loading-only-the-mcp-tools-needed https://block.github.io/goose/docs/mcp/extension-manager-mcp/