# [Video Response] What Cloudflare's code mode misses about MCP and tool calling

Source: https://www.youtube.com/watch?v=0bpYCxv2qhw
Recap page: https://rapidrecap.app/video/0bpYCxv2qhw
Generated: 2025-10-19T11:32:50.727+00:00

---
## Quick Overview

Cloudflare's Code Mode for agents, which converts Model Context Protocol (MCP) tools into TypeScript APIs, is superior to traditional MCP because it leverages the LLM's extensive training on real-world code, leading to more deterministic and reliable tool execution, especially when chaining multiple tool calls, by allowing the LLM to write and execute code directly within a secure sandbox environment.

**Key Points:**
- Agents using Code Mode (converting MCP tools to TypeScript APIs) handle many more tools and more complex tasks effectively compared to traditional MCP.
- The superiority stems from LLMs having enormous amounts of real-world TypeScript training data, unlike the contrived examples in traditional tool calls.
- Code Mode shines when agents need to string together multiple calls because the output of each tool call feeds directly into the LLM's neural network, avoiding the waste of time, energy, and tokens associated with parsing string outputs.
- The traditional MCP approach requires the LLM to output text/JSON which must be copied over as input for the next step, leading to inefficiencies, whereas Code Mode allows the LLM to write and execute code directly in a sandbox.
- Cloudflare Workers use V8 Isolates for secure sandboxing, which are far more lightweight than containers, allowing for rapid creation and destruction of execution environments for each tool call.
- The dynamic nature of Code Mode means the LLM decides the sequence of tool calls and how to handle intermediate outputs, leading to less brittle plans than the fixed sequence required by traditional MCP.
- The speaker agrees with the article's premise that MCP is useful for uniformity but argues that the complexity of real-world tasks exposes flaws in the traditional string-based output method.

![Screenshot at 00:15: The video displays the Cloudflare blog title 'Code Mode: the better way to use MCP' which introduces the core topic of replacing traditional MCP abstractions with code-based tool execution.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-00-15.png)

**Context:** The video analyzes the Cloudflare article titled "Code Mode: the better way to use MCP," which argues against using the Model Context Protocol (MCP) as the primary abstraction layer for LLM tool calling. The presenter discusses how current agents often use MCP to expose tools, but Cloudflare is advocating for a 'Code Mode' approach where tools are presented as TypeScript APIs, allowing the LLM to generate and execute code directly within a sandboxed environment.

## Detailed Analysis

The speaker reviews the Cloudflare article arguing that MCP is the wrong abstraction, noting that most agents use MCP by exposing 'hooks' to the LLM, often by converting tools into TypeScript APIs. The results are striking: agents are better at handling complex tasks when tools are presented as TypeScript APIs rather than raw text calls, likely because LLMs have seen vast amounts of real-world TypeScript code in their training data. The article highlights that Code Mode excels when chaining multiple tool calls because the output of one call feeds directly back into the LLM's neural network, minimizing wasted tokens and latency, unlike traditional MCP where the output is a string that needs parsing and re-feeding. The article also points out that the traditional MCP approach forces the LLM to write code to call MCP, which is inferior to having the LLM write code to call the underlying APIs directly. The speaker agrees that while MCP provides uniformity, the real world is messy, and the determinism offered by Code Mode (using V8 Isolates for lightweight sandboxing) is superior to the inherent non-determinism when stringing together many tool calls via traditional MCP.

### Critique of Traditional MCP

- Agents handle more complex tasks with TypeScript APIs than raw text tool calls
- LLMs are better trained on real-world TypeScript than contrived tool call examples.

### Code Mode Advantage

- Output of tool calls feeds directly into the LLM's neural network, avoiding token waste and latency from string parsing/re-feeding.

### Tool Calling Analogy

- Making an LLM perform tasks via tool calling is compared to putting Shakespeare through a month-long Mandarin class and asking him to write a play.

### MCP Uniformity vs. Code Mode

- Although MCP offers uniformity, complex real-world tasks lead to non-deterministic outputs when using string-based MCP calls.

### Sandboxed Execution

- Code execution happens in a secure sandbox powered by V8 Isolates, which are far more lightweight than containers, allowing for on-demand creation/destruction of execution environments.

### Execution Flow

- The Code Mode diagram shows the LLM generating TypeScript, invoking the API via the sandbox, and receiving the final result directly back, contrasting with Traditional MCP's repetitive loop of string input/output.

![Screenshot at 00:01: The presenter begins discussing the Cloudflare article titled 'MCP is the wrong abstraction'.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-00-01.png)
![Screenshot at 00:11: The title screen for the Cloudflare blog post 'Code Mode: the better way to use MCP' is displayed.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-00-11.png)
![Screenshot at 00:34: The article text highlights the experiment: converting MCP tools into TypeScript APIs and asking the LLM to write code to call those APIs instead.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-00-34.png)
![Screenshot at 00:45: Text overlay shows the striking result: 'We found agents are able to handle many more tools, and more complex tools...'.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-00-45.png)
![Screenshot at 01:11: A diagram illustrates the traditional MCP flow where the LLM output must be processed externally before the next step.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-01-11.png)
![Screenshot at 01:44: A diagram contrasts the 'Traditional MCP' flow with the 'Code Mode' flow, showing Code Mode executing code dynamically in a sandbox.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-01-44.png)
![Screenshot at 02:53: The article section 'What's wrong with this?' argues that LLMs have seen real-world code but not many contrived tool calls.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-02-53.png)
![Screenshot at 03:07: The article section 'But MCP is still useful, because it is uniform' is shown, setting up the counter-argument.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-03-07.png)
![Screenshot at 06:10: The presenter emphasizes that the traditional approach wastes tokens and time by passing intermediate results as strings back to the LLM.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-06-10.png)
![Screenshot at 10:10: The presenter notes the opportunity to gain benefits by avoiding sequential intermediate steps when using Code Mode.](https://ss.rapidrecap.app/screens/0bpYCxv2qhw/00-10-10.png)
