-
Book Overview & Buying
-
Table Of Contents
Agentic Coding with Claude Code
By :
Cloudflare first introduced in a blog post (https://blog.cloudflare.com/code-mode/). CodeMode, an execution model designed to change how agents interact with MCP tools.
The idea addresses drawbacks discussed earlier regarding MCP, particularly context bloat and increased latency caused by multiple LLM calls.
Instead of using MCP in the usual way, Cloudflare suggests taking all tool definitions, tool interfaces, and tool implementations from MCP and converting them into a TypeScript API. Rather than allowing the LLM to choose which tool to call through tool calling, the LLM is asked to generate code that uses the TypeScript API.

Figure 4.40 – Cloudflare Code Mode replacing tool calls with code execution
In this model, the LLM generates the entire code that needs to be executed. The generated code includes multiple tool calls implemented as function invocations. That code is then executed once inside a sandbox.
This approach reduces the number of round trips...