# Neurouter code mode and Cloudflare Code Mode

> Cloudflare's Code Mode turns MCP tools into a TypeScript API that runs in Workers isolates. How Neurouter's governed Python code mode compares.

Source: https://neurouter.com/compare/cloudflare-code-mode · Last updated: 2026-11-26

Both approaches start from the same observation: instead of calling tools one at a time, let the model write code that calls them. Source for Cloudflare: [Code Mode: the better way to use MCP](https://blog.cloudflare.com/code-mode/), Cloudflare blog post by Kenton Varda and Sunil Pai, published 2025-09-26, checked 2026-11-26. Cloudflare's product may have changed since that post; check its current documentation.

## What the post describes

- MCP tools are converted into a **TypeScript API** with doc comments; the agent sees a tool that runs TypeScript and writes code against that API (part of Cloudflare's Agents SDK).
- The code runs in a sandbox built on **V8 isolates** in Cloudflare Workers, using the **Worker Loader API** to load code on demand; a fresh isolate can be created per snippet.
- The sandbox has **no general internet access**: `fetch()` and `connect()` throw. It reaches MCP servers only through **bindings**, which the post describes as "an already-authorized client interface", so **API keys stay out of the generated code**.
- Claimed benefits: models handle more complex tools as a TypeScript API, chained calls skip passing intermediate results through the model, and isolates start quickly.
- At the time of the post, the Worker Loader API was in **closed beta** for production use, and the whole generated API was loaded into the agent's context.

## How the approaches differ

| | Cloudflare Code Mode (per the 2025-09-26 post) | Neurouter code mode (v0.1 design) |
|---|---|---|
| Language | TypeScript | A restricted Python subset ([docs](https://neurouter.com/docs/code-mode#the-allowed-subset)) |
| Where code runs | V8 isolates on Cloudflare Workers | The Monty interpreter in a separate executor process, self-hosted |
| Credentials | Held outside the sandbox; bindings are pre-authorized | Held by the server; scripts call functions only ([docs](https://neurouter.com/docs/security-model)) |
| Network from the sandbox | No `fetch()`/`connect()` | No network in the language; on Kubernetes, egress denied for the executor ([docs](https://neurouter.com/docs/deployment#helm)) |
| What a call goes through | The binding to the MCP server | The full policy pipeline per inner call: ACL, read-only, policies, rate limits, audit ([docs](https://neurouter.com/docs/code-mode)) |
| Writes | Not covered in the post | Dry run with planned changes; prod writes bound to the plan the user confirmed |
| Tool discovery | Whole API in context (per the post) | `search_tools` returns signatures on demand |
| Measuring the effect | Not covered in the post | Evals run tasks in tool mode and code mode and recommend one ([docs](https://neurouter.com/docs/evals)) |

## When to choose which

- **Choose Cloudflare's Code Mode** if you build agents on Cloudflare's Agents SDK and want TypeScript sandboxes on Cloudflare's platform.
- **Choose Neurouter** if you want code mode for your own API, self-hosted, with each inner call governed and audited, writes dry-run first, and evals that show whether code mode actually helps for your API.
