---
title: "Code Mode: definition and example | Agent MCP Directory"
description: "Code Mode: A Cloudflare approach where the agent writes code against a typed API instead of calling many tools one by one."
canonical: https://agentmcpdirectory.com/glossary/code-mode
site: "Agent MCP Directory"
last_updated: 2026-11-04
section: "Glossary"
---

# Code Mode: definition and example | Agent MCP Directory

> Code Mode: A Cloudflare approach where the agent writes code against a typed API instead of calling many tools one by one.

Source: https://agentmcpdirectory.com/glossary/code-mode
Site: Agent MCP Directory
Last reviewed: 2026-11-04

# Code Mode

Code Mode: A Cloudflare approach where the agent writes code against a typed API instead of calling many tools one by one, set by portal policy. Example: Portal Code Mode policy can be off, opt\_in, default\_on or enforced. Also in the glossary is document.modelContext: The WebMCP entry point on the document object that holds registerTool, getTools and executeTool.

## Definition

A Cloudflare approach where the agent writes code against a typed API instead of calling many tools one by one, set by portal policy.

## Example, with source

Portal Code Mode policy can be off, opt\_in, default\_on or enforced. ([developers.cloudflare.com](https://developers.cloudflare.com/cloudflare-one/access-controls/ai-controls/mcp-portals/), read 4 November 2026)

## Where it appears on this site

-   [Hosts and gateways compared](https://agentmcpdirectory.com/hosts/)
-   [Tool descriptions and agent success](https://agentmcpdirectory.com/guides/tool-descriptions-and-agent-success/)

## Neighbouring terms

-   [Client ID Metadata Document (CIMD)](https://agentmcpdirectory.com/glossary/client-id-metadata-document/): A JSON file on the client's domain whose HTTPS URL is used as the OAuth client\_id, the recommended MCP registration method.
-   [Confused deputy](https://agentmcpdirectory.com/glossary/confused-deputy/): An attack where a proxy with its own credentials is tricked into acting for someone else; MCP security guidance addresses it for OAuth proxies.
-   [document.modelContext](https://agentmcpdirectory.com/glossary/document-modelcontext/): The WebMCP entry point on the document object that holds registerTool, getTools and executeTool.

Edition

4 November 2026

Method

[How rows are verified](https://agentmcpdirectory.com/method/)

Data

[CSV and JSON](https://agentmcpdirectory.com/data/)

Markdown

[This page as markdown](https://agentmcpdirectory.com/glossary/code-mode/index.md)

## Sources

-   [Source for the Code Mode example](https://developers.cloudflare.com/cloudflare-one/access-controls/ai-controls/mcp-portals/), read 4 November 2026

Last reviewed 4 November 2026
