Skip to content
Last Dictionary

code mode

nounAlso: code execution with MCP

In plain wordsA way for AI agents to use tools by writing a short program that calls them, instead of asking for each tool one step at a time.

  1. An approach to tool usetool use, n.: An AI model's ability to reach beyond its own knowledge by operating outside tools — searching the web, running code, using a calculator or an app — and folding the results into its work. in which, instead of issuing one structured tool calltool call, n.: A single request from an AI model to use one of its tools — naming the tool and filling in the details — which the surrounding software then carries out and reports back on. at a time, the model sees its tools (usually those offered by MCP serversMCP server, n.: A small program that makes some service — say a database, a calendar or a company's internal tools — available to any AI assistant that speaks the Model Context Protocol.) as functions in a programming language and writes a short program that uses them, which is then executed in a sandboxsandbox, n.: A sealed-off computer space where an AI agent can run programs and change files without being able to harm the real system, reach private data or contact the outside world unless allowed.. Its originators at Cloudflare reasoned that models are far more fluent in ordinary code, which fills their training data, than in the artificial tool-call format, so they cope better with large or complicated toolsets; and that when calls are chained, intermediate results can stay inside the running program instead of passing through the model's context windowcontext window, n.: How much an AI model can read and keep in view at once: the instructions, the conversation so far and any attached documents. Text that does not fit has to be cut, summarized or left out., which saves tokens and time. Credentials stay in the sandbox and never appear in the generated code. Anthropic described a similar pattern of code executioncode execution, n.: Letting an AI write a small program and actually run it — to do math, analyze a spreadsheet or test its own code — then use the real output instead of guessing. with MCP later in 2025.

    With code mode, the agent fetched 300 tickets, filtered them in a loop and returned only the summary.

Origin

Named by Kenton Varda and Sunil Pai in the Cloudflare blog post 'Code Mode: the better way to use MCP' (26 September 2025), which converted MCP tools into a TypeScript API executed in lightweight V8 isolates.

Related

See also
  • Model Context ProtocolModel Context Protocol, prop. n.: An open standard that lets AI assistants plug into outside apps and data — files, calendars, databases, business software — through one common connector instead of a custom link for every pairing; often likened to a USB-C port for AI.
  • tool usetool use, n.: An AI model's ability to reach beyond its own knowledge by operating outside tools — searching the web, running code, using a calculator or an app — and folding the results into its work.
  • function callingfunction calling, n.: A feature of AI model services that lets the model reply with a neatly formatted request to run one of a program's functions, rather than with ordinary text; the program, not the model, then runs it.
  • code executioncode execution, n.: Letting an AI write a small program and actually run it — to do math, analyze a spreadsheet or test its own code — then use the real output instead of guessing.
  • sandboxsandbox, n.: A sealed-off computer space where an AI agent can run programs and change files without being able to harm the real system, reach private data or contact the outside world unless allowed.
  • progressive disclosureprogressive disclosure, n.: Showing only a short summary first and revealing details when they are actually needed. AI agents use it to avoid filling their limited memory with instructions they may never use.
  • context engineeringcontext engineering, n.: Managing an AI model's reading material: choosing, trimming and arranging the instructions, documents, tool results and memories it is given on every turn, so that it has what the task needs and little else.
Contrast with
  • function callingfunction calling, n.: A feature of AI model services that lets the model reply with a neatly formatted request to run one of a program's functions, rather than with ordinary text; the program, not the model, then runs it.

Sources

  1. Varda, K. & Pai, S. (2025). Code Mode: the better way to use MCP. Cloudflare blog, 26 September 2025. blog.cloudflare.com/code-mode