Browse the blog

Claude Code's Code Mode vs CodeCall: Where Should the Script Run?

  • claude-code
  • code-mode
  • codecall
  • mcp
  • frontmcp

Dated article; use the maintained reference for current instructions. Example version: FrontMCP 1.12.2. Technical checks recorded: 2026-11-19. How checks work.

On November 12, 2026, Claude Code 2.1.323 shipped Code Mode, an experimental mode that changes how Claude uses tools. Without it, Claude asks for one tool call, reads the result, and decides on the next one. With it, Claude "writes a piece of JavaScript that makes the tool calls, and Claude Code runs that code in your session." One script can run calls in parallel, feed one result into the next call, and return only the part Claude needs to read.

That's the code-execution pattern for MCP, and FrontMCP has shipped it on the server side since 2025 as CodeCall: the model searches a server's tools, sends one script to codecall:execute, and the server runs it in Enclave, AgentFront's sandbox for code that agents write. (Cloudflare's Code Mode MCP server takes the same server-side route, with a search() and an execute() tool.) Same idea, different place. Code Mode runs the script in Claude Code, on the user's machine. CodeCall runs it in the MCP server, next to the data, for whatever client calls it.

So we ran them side by side: one FrontMCP server, Claude Opus 5.5 in Claude Code 2.1.328, four setups, 20 runs. This post has the numbers, the server (it runs on this page), where each approach wins, and the two things a client-side mode can't bring: the server's own knowledge of its data, and work that outlives a script.

What we found:

  • Same answers. All 12 runs of the first question, in all four setups, named the right five accounts with the right totals.
  • Both cut the work. With plain tool calls, the question took 36.2 seconds and added 29,490 tokens to Claude's context (medians). Code Mode took 24.2 seconds and 8,627 tokens. CodeCall, with Code Mode off, took 26.8 seconds and 9,669 tokens.
  • Only CodeCall kept the data on the server. It sent Claude Code 21 KB. When Claude Code did the join, the server sent it 302 KB.
  • The server's skill decided the vague question. Asked for the accounts "most at risk", Claude named the company's five in all 4 runs where the server shipped its definition, in Code Mode and with CodeCall, and in none of the 4 runs where it didn't.
  • What each costs. AgentScript refused Claude's first script in all 8 CodeCall runs, for using Set, which cost a request each time. Code Mode runs only in Claude Code's terminal, on the Anthropic API, and is experimental.

What Claude Code's Code Mode does

You turn it on with an environment variable, CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1, and confirm once. Claude then gets a REPL tool that runs JavaScript, and Claude Code's tools become async functions inside it: $ for shell commands, edit() for edits, and every connected MCP server's tools by their full names. This is part of a script Claude wrote in one of our runs, reformatted, calling three tools of our server at once:

const [c, i, tk] = await Promise.all([
  tools.mcp__billing__list_customers({ plan: "enterprise" }),
  tools.mcp__billing__list_invoices({ status: "overdue" }),
  tools.mcp__billing__list_tickets({ status: "open", priority: "high" }),
]);

Each call in a script still goes through your permission rules and PreToolUse hooks under the tool's usual name. In auto mode, a classifier reviews the script before it runs, and Anthropic's page warns that it "doesn't see values computed at run time, such as a path taken from search output". A script you wait on stops after ten minutes; in the background it can run for two hours.

It has limits worth reading before you plan around it (requirements):

  • Where: an interactive claude session in a terminal, from the native build. Not claude -p, the Agent SDK, the VS Code panel, the Desktop app or cloud sessions.
  • Which accounts: a Claude subscription or a Console account, directly against the Anthropic API. Not through a gateway, Amazon Bedrock, Google Cloud or Microsoft Foundry, and not with the HIPAA configuration or zero data retention.
  • Which models: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.2.
  • Status: "experimental and off by default. It may change or be removed in any release."

What CodeCall does

CodeCall is a FrontMCP plugin. With mode: "codecall_only", tools/list shows six tools instead of the server's own: the model finds tools with codecall:search, reads their input and output schemas with codecall:describe, and sends a script to codecall:execute. The script is AgentScript, a subset of JavaScript. Enclave parses it and, before it runs, refuses anything that could reach the host, like eval, fetch, process, globalThis and .constructor, and constructs it doesn't allow, like while loops. Then it runs the script with a deadline and a cap on tool calls. Each callTool() goes through the server's normal call flow, with the caller's credentials, hooks and input validation. Only what the script returns goes back.

To a client, CodeCall's tools are ordinary MCP tools. ChatGPT, Cursor, Claude Desktop, claude -p, the Agent SDK and Claude Code, with Code Mode or without, call codecall:execute like any other tool, with any model that can call one.

The server we tested

A hypothetical billing and support product with 600 customers, 2,400 invoices and 1,800 tickets, generated in billing.data.ts. Eight tools read and change it. One of them, change_plan, is marked destructive, and CodeCall keeps it out of reach with includeTools. The app also has a skill, three jobs and a workflow, which later sections use.

The question we gave Claude: "Which five enterprise customers with an open high-priority ticket owe us the most in overdue invoices? For each, give the overdue total in dollars and their account manager's email." Answering it means joining three lists: 165 enterprise customers, 292 overdue invoices and 241 open high-priority tickets, 138,680 bytes of JSON as the tools return them. Then one lookup per account manager.

The Call tab below sends codecall:execute the script a model would write for it, and shows the five accounts it returns: 484 bytes. Open the Tests tab: its nine tests check every number in this post that comes from the server, in Node and in your browser.

Open
import { App } from "@frontmcp/sdk";
import { CodeCallPlugin } from "@frontmcp/plugin-codecall";
import { billingTools } from "./billing.tools";
import { AtRiskAccounts, CollectionsRun, FindAtRiskAccounts, FlagUrgentTickets, RemindOverdueCustomers } from "./collections";

@App({
  id: "billing",
  name: "Billing and Support",
  tools: billingTools,
  skills: [AtRiskAccounts],
  jobs: [FindAtRiskAccounts, RemindOverdueCustomers, FlagUrgentTickets],
  workflows: [CollectionsRun],
  plugins: [
    CodeCallPlugin.init({
      mode: "codecall_only",
      includeTools: (tool) => !tool.annotations?.destructiveHint,
      vm: { maxSanitizeProperties: 10_000 },
    }),
  ],
})
export class BillingApp {}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

The only difference between the two servers in our runs is the plugins line in billing.app.ts. Without it, the same app lists its 13 tools: the eight above and the five tools FrontMCP adds for jobs and workflows.

Code Mode vs CodeCall: four setups, one question

We asked the question three times in each of four setups: Claude Code with Code Mode on and off, against the server with and without CodeCall. All twelve runs got the five accounts, their totals and their managers right. They got there in different ways.

  • Plain tool calls, Code Mode off and no CodeCall. Claude called the three list tools and get_manager directly. The customer and ticket lists went into its context. The invoice list was too big to show it, so Claude Code saved it to a file, and Claude joined it with jq in the shell, typing the enterprise customers' ids into the command. It never read the server's skill.
  • Code Mode. Claude read the server's skill, fetched the three lists in parallel in one script and kept them in the REPL's variables. Before joining them, it printed a preview of each, up to 4 KB of raw records in all, to learn their shape. A second script joined them, with a Set, and looked up the managers.
  • CodeCall. Claude read the skill, searched and described the four tools, whose output schemas came back with them, and sent a script to codecall:execute. In every run, that first script used Set. AgentScript doesn't have it, so CodeCall refused the script before it ran, and Claude sent it again with a plain object. The lists never left the server.
Median of 3 runs (range)Plain tool callsCode ModeCodeCallCode Mode and CodeCall
Correct answers3 of 33 of 33 of 33 of 3
Seconds from prompt to answer36.2 (28.1–44.9)24.2 (24.2–26.4)26.8 (21.6–34.9)23.7 (20.4–24.4)
Model requests7 (6–7)6 (6–7)6 (6–8)6
Tokens the question added to the context29,490 (28,743–30,152)8,627 (8,169–12,044)9,669 (9,330–9,696)8,695 (7,986–10,931)
Input tokens, all requests394,557166,485275,929167,575
Output tokens3,4492,1712,1442,191
Tool calls the server received664 (4–5)4 (3–4)
Bytes the server sent back for them302,106302,10721,022 (19,266–21,026)19,954 (17,536–22,699)

What the numbers say:

  • Code Mode and CodeCall do the same job. Next to plain tool calls, each cut what the question added to Claude's context by two thirds or more, from 29,490 tokens to under 10,000, and each answered faster. Without Code Mode, putting CodeCall on the server took Claude Code from 36.2 seconds to 26.8, and from 29,490 tokens added to its context to 9,669.
  • In Claude Code, Code Mode was a little faster. Its prompt is smaller: the first request of a Code Mode session was 23,127 tokens, against 40,444 without it, because Claude Code's tools are functions inside one REPL tool instead of separate tool definitions. Every request pays for that difference, which is most of the gap in the "all requests" row. It's Claude Code's prompt, not the server's.
  • Only CodeCall kept the data on the server. In both setups without it, the server sent all three lists to Claude Code for every question: 302 KB, each result once as text and once as structuredContent. With CodeCall it sent about 20 KB: codecall:search (5 KB) and codecall:describe (10.7 KB), which a conversation needs once, the refused script's error and the answer.
  • CodeCall's one extra request was the Set refusal. It cost every CodeCall run a request and about 1.8 KB, and it's fixable on FrontMCP's side (below).

Code Mode exists only in Claude Code's terminal. Most clients call a server's tools one at a time, as in the first column. CodeCall is how a server gets the third column's numbers in any of them, without waiting for each client to build a code mode of its own.

More accurate: the server knows what "at risk" means

The first question spelled out its rule. Real questions often don't. So we asked a vaguer one: "Which five of our enterprise accounts are most at risk right now, and who manages each one?" Nothing in the tools says what "at risk" means at this company. A model can write the join; it can't know the rule unless someone tells it, and a client-side mode has nobody to ask.

The server can tell it. collections.ts declares a skill, at-risk-accounts: a description, the four tools it uses, and instructions that define an account at risk and say how to rank them. FrontMCP serves it as an MCP resource, skill://at-risk-accounts/SKILL.md, listed in skill://index.json, and through codecall:searchSkills. The Playground's tests read it both ways.

We asked the vague question against the server with and without the skill, twice each:

"Most at risk", 2 runs eachSkill on the serverRuns that named the company's fiveMedian seconds
Plain tool callsNo0 of 234.6
Code ModeNo0 of 226.3
Code ModeYes2 of 225.4
CodeCallYes2 of 223.7

Without the skill, Claude said what it was doing and chose its own rule: "The billing server has no risk score, so I ranked accounts by how much money is overdue." All four runs without the skill, with Code Mode and without, returned the same five: the five largest overdue balances. Only two of them are at risk by the company's rule. Fernwood Labs, Lumen Studio and Northwind Software have no urgent ticket open, and Northwind Pharma, Brightwater Foods and Meridian Robotics, which do, were missing. With the skill, in every run, Claude read skill://index.json before it touched any data, without being asked, and said where its rule came from: I used the billing server's own "at-risk-accounts" rule.

Code Mode read the same skill as a plain MCP resource, without CodeCall. That's the point of putting it on the server: the definition lives next to the data, and every client that connects gets it.

When the work outlives a script

A script is for one question. Sending reminders to every at-risk account each morning, retrying the ones that fail, and noting it on their tickets is a process, and a terminal session is the wrong place for it: Code Mode stops a script you wait on after ten minutes, or two hours in the background, and it runs only in someone's Claude Code session.

FrontMCP has jobs and workflows for that. collections.ts declares three jobs, find-at-risk-accounts, remind-overdue-customers (with three attempts) and flag-urgent-tickets, and a workflow, collections-run, that runs the first and then the other two in parallel, each step's input built from the first step's result. FrontMCP adds execute_workflow and the other job tools to the server by itself. CodeCall hides them from tools/list like every other tool, and a script can call them:

Open

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

The run found 17 at-risk accounts, sent 21 reminders and flagged 17 tickets, all on the server. Pass background: true and the call returns a runId at once, which a signed-in caller polls with get_workflow_status. Add trigger: "schedule" with a cron expression and the workflow runs on a schedule, with no model and no client connected. A script that worked once becomes the server's own process.

What CodeCall refused

CodeCall's checks are on the server, so they hold whatever the client is and whatever the user allowed. Three of them came up:

  • Set, in every CodeCall run. AgentScript has no Set, Map, RegExp or Promise, and codecall:execute's description doesn't say so: its BLOCKED: line names loops, eval and fetch. Claude reached for Set each time, got illegal_access with the line and the name, and rewrote the script. Nothing had run. Listing the missing globals in the description would save that request, and we've filed it with FrontMCP. The Call tab below sends such a script:
Open

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

  • The size of a tool's result. Under CodeCall's default secure preset, a script may receive at most 2,000 values from a tool, counting every array item and object key. The 292 overdue invoices, with their lines, hold 5,549, so the script ended with Tool handler return value exceeds maximum properties (2000). That's why billing.app.ts sets vm: { maxSanitizeProperties: 10_000 }. The error doesn't name the tool, and the option's description doesn't say it counts tool results, so we filed that too. A test in the Playground keeps the default and shows the error.
  • change_plan, from a script and from a client. includeTools keeps destructive tools away from CodeCall, so a script that calls change_plan gets ACCESS_DENIED, and a client that calls it by name gets Tool "change_plan" not found. In the Code Mode runs, change_plan was one of the 13 tools the server listed, and our mcp__billing permission rule allowed all of them: there, what a script may call is the user's setting, and the server can't tell a script's call from anyone else's.

Pros and cons

Code Mode in Claude CodeCodeCall in a FrontMCP server
Where the script runsIn Claude Code, on the user's machineIn the MCP server, in Enclave
ClientsClaude Code 2.1.323 or later, interactive, in a terminalAny MCP client
ModelsOpus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2, on the Anthropic APIAny model that can call a tool
What a script can reachClaude Code's tools, your files and shell, and every connected MCP serverThe tools of one server that CodeCall may use
LanguageJavaScriptAgentScript: no Set, Map, RegExp, while or fetch
Who decides what a script may callThe user: permission rules and hooksThe server: includeTools, authorities, the sandbox's limits
What's checked before a script runsIn auto mode, a classifier reads the script; it doesn't see values computed at run timeEnclave refuses anything outside AgentScript; each call's real arguments then go through the server's rules
Variables between scriptsKept: in our runs, a second script joined lists the first had fetchedNone: each script starts fresh
Where the data goesEvery tool result goes to the client: 302 KB a question hereOnly what the script returns: 484 bytes, after about 16 KB of discovery
How long a script may run10 minutes, or 2 hours in the background3.5 seconds by default; jobs and workflows for longer work
What it takesAn environment variableA plugin on the server
StatusExperimentalReleased

Code Mode's strengths: it needs nothing from the server, so it works with every MCP server today. One script can mix your shell, your files and several servers. It runs real JavaScript: no Code Mode script failed in our runs. Its variables stay between scripts, so Claude can look at a result before it decides what to do with it. And in Claude Code, the two setups with Code Mode on were the fastest we ran, about 24 seconds.

Its limits: only Claude Code's terminal, on the Anthropic API, with four models, and it's experimental. Every tool result travels to the user's machine. The user's permission rules decide what a script may call, so the server's owner has no say.

CodeCall's strengths: one server change serves every client and every model. The data stays on the server, and the server decides what a script may call, with the same authorities and hooks as any call. codecall:describe gives the model each tool's output schema: in our runs, Claude wrote its script from those and never looked at raw records. And it comes with the rest of FrontMCP: skills and workflows.

Its limits: AgentScript is a subset, and Claude tripped on it in every run. The default limits are small for big lists. A script reaches one server's tools, and each script starts fresh: a second one can't reuse what the first fetched. And the six meta-tools are a fixed cost: 18,145 bytes in tools/list, more than this server's own 13 tools (11,328 bytes). On a server with a handful of small tools, a plain tools/list is cheaper.

Use both

They don't compete for the same spot. With Code Mode on and CodeCall on the server, Claude called codecall:search, codecall:describe and codecall:execute from its REPL, like any other MCP tool. That setup matched Code Mode on its own, 23.7 seconds and 8,695 tokens added to the context, while the server sent 19,954 bytes instead of 302,107. Code Mode kept Claude Code's side lean, and CodeCall kept the lists on the server.

Setting it up

Everything in this post is in one @App: the tools, the skill, the jobs, the workflow and the plugin. FrontMCP serves the skill, adds the job and workflow tools, and wires CodeCall to all of them:

npm install @frontmcp/sdk@1.12.2 @frontmcp/plugin-codecall@1.12.2
billing.app.ts
@App({
  id: "billing",
  name: "Billing and Support",
  tools: billingTools,
  skills: [AtRiskAccounts],
  jobs: [FindAtRiskAccounts, RemindOverdueCustomers, FlagUrgentTickets],
  workflows: [CollectionsRun],
  plugins: [
    CodeCallPlugin.init({
      mode: "codecall_only",
      includeTools: (tool) => !tool.annotations?.destructiveHint,
      vm: { maxSanitizeProperties: 10_000 },
    }),
  ],
})
export class BillingApp {}

To hand it to Claude Code users with its skills, build it as a program with frontmcp build --target cli. Its install -p claude command writes a Claude Code plugin with the server entry and each skill as a SKILL.md, and install -p codex does the same for Codex. Over HTTP, any client connects to it as to any MCP server.

What we measured, and what we didn't

  • The runs. November 19, 2026, on one Apple-silicon MacBook running macOS 26.6.2 and Node 24.22.1: FrontMCP 1.12.2, @frontmcp/plugin-codecall 1.12.2 and Enclave 2.19.2; Claude Code 2.1.328, native build, with Claude Opus 5.5 (--model opus). Three runs of each setup for the first question, two for the "at risk" question.
  • Each run was a new interactive session in an empty folder, started with --strict-mcp-config and only the billing server, over HTTP on the same machine, with --setting-sources project,local so no plugins or hooks of ours loaded, and --allowedTools mcp__billing. Sessions started in auto mode. A small program typed the prompt and waited for the answer in the session's transcript.
  • What we counted. Model requests and tokens come from the transcript's usage fields. "Tokens the question added" is the input of the last request minus the input of the first. Seconds run from the prompt to the answer, as the transcript records them. Bytes are response bodies, counted by a proxy between Claude Code and the server. A correct answer names the five accounts in order, with their totals and their managers' emails. Every run's numbers are in the JSON record.
  • What we didn't. Cost; other models and clients; a server across a network, where every extra round trip would add latency (all four setups talked to localhost); runs at scale. Three runs show the spread, not a distribution. The data and the question are ours, chosen to need a join, and a hypothetical company's.
  • What's checked on every build. Every number that comes from the server, the 138,680 bytes, the 484-byte answer, both catalogs, the refusals and the workflow, is pinned by the Playground's tests, in Node and in the browser. The model runs are a record of one day, and a later Claude Code, model or FrontMCP release can change them.

Try it

The server above runs on this page: edit a tool or the script in the Playground and the tests show what changed. Letting the Model Write Code with CodeCall teaches CodeCall step by step, Teaching the Model Skills covers skills, and Chaining Jobs into Workflows covers workflows. If you use Claude Code, turn on Code Mode too: they work together.

Report a docs issue. Site usage and privacy.