InfoQ

Cloudflare Launches Code Mode MCP Server to Optimize Token Usage for AI Agents

5.5内容质量
Cloudflare Launches Code Mode MCP Server to Optimize Token Usage for AI Agents

TL;DR · AI 摘要

Cloudflare 推出 Code Mode MCP Server,旨在优化 AI Agent 的 Token 使用效率。

核心要点

  • Cloudflare 发布新工具以减少 AI Agent 调用中的 Token 消耗
  • Code Mode MCP Server 专注于代码相关任务的上下文优化
  • 该方案可能降低 LLM 推理成本并提升响应精准度
#Cloudflare#AI Agent#MCP Server#Token Optimization#LLM
打开原文

Cloudflare Launches Code Mode MCP Server to Optimize Token Usage for AI Agents - InfoQ

[BT](http://www.infoq.com/int/bt/ "bt")

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

Enter your e-mail address

Select your country - [x] I consent to InfoQ.com handling my data as explained in this Privacy Notice.

We protect your privacy.

Close

Live Webinar and Q&A: Designing Data Layers for Agentic AI: Patterns for State, Memory, and Coordination at Scale (May 12, 2026)Save Your Seat

Close

Toggle Navigation

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

English edition

[Write for InfoQ](http://www.infoq.com/write-for-infoq/ "Write for InfoQ")

Search

RegisterSign in

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In

or

Don't have an InfoQ account?

Register

  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Logo - Back to homepage

NewsArticlesPresentationsPodcastsGuides

Topics

[Development](http://www.infoq.com/development/ "Development")

  • [Java](http://www.infoq.com/java/ "Java")
  • [Kotlin](http://www.infoq.com/kotlin/ "Kotlin")
  • [.Net](http://www.infoq.com/dotnet/ ".Net")
  • [C#](http://www.infoq.com/c_sharp/ "C#")
  • [Swift](http://www.infoq.com/swift/ "Swift")
  • [Go](http://www.infoq.com/golang/ "Go")
  • [Rust](http://www.infoq.com/rust/ "Rust")
  • [JavaScript](http://www.infoq.com/javascript/ "JavaScript")

Featured in Development

Dany Lepage discusses the architectural journey of porting a hit VR title to seven non-VR platforms. He explains how his team solved the challenges of cross-progression, diverse input paradigms, and maintaining release velocity across Steam, iOS, and PlayStation. Beyond the tech, he shares candid lessons on the "product fit" gap when translating immersive social presence to 2D screens.

![Image 3: From VR to Flat Screens: Bridging the Input and Immersion Gap/presentations/game-vr-flat-screens/en/smallimage/thumbnail-1775637585504.jpg)](http://www.infoq.com/presentations/game-vr-flat-screens)

All in developmentFollow Topic

[Architecture & Design](http://www.infoq.com/architecture-design/ "Architecture & Design")

  • [Architecture](http://www.infoq.com/architecture/ "Architecture")
  • [Enterprise Architecture](http://www.infoq.com/enterprise-architecture/ "Enterprise Architecture")
  • [Scalability/Performance](http://www.infoq.com/performance-scalability/ "Scalability/Performance")
  • [Design](http://www.infoq.com/design/ "Design")
  • [Case Studies](http://www.infoq.com/Case_Study/ "Case Studies")
  • [Microservices](http://www.infoq.com/microservices/ "Microservices")
  • [Service Mesh](http://www.infoq.com/servicemesh/ "Service Mesh")
  • [Patterns](http://www.infoq.com/DesignPattern/ "Patterns")
  • [Security](http://www.infoq.com/Security/ "Security")

Featured in Architecture & Design

Randy Shoup discusses the "Velocity Initiative," a transformation that doubled engineering productivity and modernized eBay’s DORA metrics. He shares the technical playbook used to scale 4,500 services while explaining why even elite engineering execution can’t save a company hampered by waterfall planning, risk aversion, and a "pathological" culture of fear.

![Image 4: Platform Engineering: Lessons from the Rise and Fall of eBay Velocity/presentations/platform-engineering-lessons/en/smallimage/randy-shoup-thumbnail-1775637120944.jpg)](http://www.infoq.com/presentations/platform-engineering-lessons)

All in architecture-designFollow Topic

[AI Infrastructure](http://www.infoq.com/ai-ml-data-eng/ "AI Infrastructure")

  • [Big Data](http://www.infoq.com/bigdata/ "Big Data")
  • [Machine Learning](http://www.infoq.com/machinelearning/ "Machine Learning")
  • [NoSQL](http://www.infoq.com/nosql/ "NoSQL")
  • [Database](http://www.infoq.com/database/ "Database")
  • [Data Analytics](http://www.infoq.com/data-analytics/ "Data Analytics")
  • [Streaming](http://www.infoq.com/streaming/ "Streaming")

Featured in AI, ML & Data Engineering

Mariia Bulycheva discusses the transition from classic deep learning to GNNs for Zalando's landing page. She explains the complexities of converting user logs into heterogeneous graphs, the "message passing" training process, and the technical pitfalls of graph data leakage. She shares how a hybrid architecture solved inference latency, delivering contextual embeddings to a downstream model.

![Image 5: Reimagining Platform Engagement with Graph Neural Networks/presentations/graph-neural-networks/en/smallimage/Mariia-Bulycheva-thumbnail-1775048997053.jpeg)](http://www.infoq.com/presentations/graph-neural-networks)

All in ai-ml-data-engFollow Topic

[Culture & Methods](http://www.infoq.com/culture-methods/ "Culture & Methods")

  • [Agile](http://www.infoq.com/agile/ "Agile")
  • [Diversity](http://www.infoq.com/diversity/ "Diversity")
  • [Leadership](http://www.infoq.com/leadership/ "Leadership")
  • [Lean/Kanban](http://www.infoq.com/lean/ "Lean/Kanban")
  • [Personal Growth](http://www.infoq.com/personal-growth/ "Personal Growth")
  • [Scrum](http://www.infoq.com/scrum/ "Scrum")
  • [Sociocracy](http://www.infoq.com/sociocracy/ "Sociocracy")
  • [Software Craftmanship](http://www.infoq.com/software_craftsmanship/ "Software Craftmanship")
  • [Team Collaboration](http://www.infoq.com/team-collaboration/ "Team Collaboration")
  • [Testing](http://www.infoq.com/testing/ "Testing")
  • [UX](http://www.infoq.com/ux/ "UX")

Featured in Culture & Methods

Celine Pypaert discusses the ubiquitous nature of open-source software and shares a blueprint for securing modern applications. She explains how to prioritize high-risk vulnerabilities using exploitability data, the role of Software Bill of Materials (SBOM), and the importance of bridging the gap between DevOps and Security through clear accountability and automated governance.

![Image 6: Empower Your Developers: How Open Source Dependencies Risk Management Can Unlock Innovation/presentations/open-source-dependencies/en/smallimage/celine-pypaert-thumbnail-1775047335370.jpeg)](http://www.infoq.com/presentations/open-source-dependencies)

All in culture-methodsFollow Topic

DevOps

  • [Infrastructure](http://www.infoq.com/infrastructure/ "Infrastructure")
  • [Continuous Delivery](http://www.infoq.com/continuous_delivery/ "Continuous Delivery")
  • [Automation](http://www.infoq.com/automation/ "Automation")
  • [Containers](http://www.infoq.com/containers/ "Containers")
  • [Cloud](http://www.infoq.com/cloud-computing/ "Cloud")
  • [Observability](http://www.infoq.com/observability/ "Observability")

Featured in DevOps

Docker Extensions boost developer speed but create a "visibility gap" by isolating telemetry. To meet enterprise needs, extensions must act as bridges to centralized platforms. This article details how to use OpenTelemetry, policy-as-code, and encryption to build secure pipelines. Learn to balance developer productivity with the governance required for scalable, compliant observability.

![Image 7: Beyond One-Click: Designing an Enterprise-Grade Observability Extension for Docker/articles/enterprise-grade-observability-extension-docker/en/smallimage/enterprise-grade-observability-extension-docker-thumbnail-1775560652994.jpg)](http://www.infoq.com/articles/enterprise-grade-observability-extension-docker)

All in devopsFollow Topic

[Events](https://events.infoq.com/ "Events")

Helpful links

  • [About InfoQ](http://www.infoq.com/about-infoq "About InfoQ")
  • [InfoQ Editors](http://www.infoq.com/infoq-editors "InfoQ Editors")
  • [Write for InfoQ](http://www.infoq.com/write-for-infoq "Write for InfoQ")
  • [About C4Media](https://c4media.com/ "About C4Media")
  • [Diversity](https://c4media.com/diversity "Diversity")

Choose your language

  • [En](http://www.infoq.com/news/2026/04/cloudflare-code-mode-mcp-server/# "InfoQ English")
  • 中文
  • 日本
  • Fr

![Image 8: InfoQ Architect Certification - image Online InfoQ Architect Certification Join Luca Mezzalira for this 5-week online cohort. Master socio-technical architecture leadership. Register Now.](https://certification.qconferences.com/?utm_source=infoq&utm_medium=referral&utm_campaign=homepageheader_onlinecohortaprmayjun26)![Image 9: QCon AI Boston - image QCon AI Boston Learn how leading engineering teams run AI in production—reliably, securely, and at scale. Early Bird ends April 14.](https://boston.qcon.ai/?utm_source=infoq&utm_medium=referral&utm_campaign=homepageheader_qaiboston26)![Image 10: QCon San Francisco - image QCon San Francisco Learn what's next in AI and software, from teams already doing it. Early Bird ends April 14.](https://qconsf.com/?utm_source=infoq&utm_medium=referral&utm_campaign=homepageheader_qsf26)

[InfoQ Homepage](http://www.infoq.com/ "InfoQ Homepage")[News](http://www.infoq.com/news "News")Cloudflare Launches Code Mode MCP Server to Optimize Token Usage for AI Agents

[Architecture & Design](http://www.infoq.com/architecture-design/ "Architecture & Design")

Designing a Control Plane for Cloud Infrastructure (Webinar Apr 16th)

Cloudflare Launches Code Mode MCP Server to Optimize Token Usage for AI Agents

Apr 16, 2026 2 min read

by

Follow Lead Engineer

#### Write for InfoQ

Feed your curiosity.Help 550k+ global

senior developers

each month stay ahead.Get in touch

Log in to listen to this article

Loading audio

Your browser does not support the audio element.

0:00 0:00

Normal 1.25x 1.5x

Like

Cloudflare has introduced a major evolution in how AI agents access complex APIs by launching a new Model Context Protocol (MCP) server powered by Code Mode, dramatically reducing the cost of interacting with its full API platform. The new approach highlights a new way for agent‑to‑tool integrations in the MCP ecosystem.

At its core, MCP is an emerging standard that lets large language models (LLMs) interface with external tools and APIs by exposing structured tools the model can call during execution. Traditionally, each API endpoint exposed to an agent represented a separate tool definition. While straightforward, this model incurs a significant context window cost every time a tool specification consumes tokens in the model’s limited input budget, leaving less room for reasoning about the user’s task.

Luuk Hofman, Solutions Engineer at Cloudflare, noted:

So we tried: convert MCP tools into a TypeScript API and just ask the LLM to write code against it.

Cloudflare’s Code Mode instead exposes only two tools, search() and execute(), backed by a type‑aware SDK that allows the model to generate and execute JavaScript inside a secure V8 isolate. This compiles an agent’s plan into a small code snippet orchestrating multiple operations against the OpenAPI spec, avoiding the need to load all endpoint definitions into context.

Image 12/filters:no_upscale()/news/2026/04/cloudflare-code-mode-mcp-server/en/resources/1codemode-1775438914205.jpeg)

_Traditional MCP vs Cloudflare Code Mode (Source: Cloudflare Blog Post)_

The practical impact is significant: Cloudflare reports that Code Mode reduces the token footprint of interacting with over 2,500 API endpoints from more than 1.17 million tokens to roughly 1,000 tokens, a reduction of around 99.9%. This fixed footprint holds regardless of API surface size, enabling agents to work across large, feature‑rich platforms without exhausting the model context.

Cloudflare emphasized in a Reddit post:

The team utilized a specialized encoding strategy to fit expansive API schemas into minimal context windows without losing functional precision.

Agents first use search() to query the OpenAPI spec by product area, path, or metadata; the spec itself never enters the model’s context. Then, execute() runs code handling pagination, conditional logic, and chained API calls in a single cycle, cutting round-trip overhead.

Cloudflare emphasized the security and sandboxing model during execution. The server runs user‑generated code in a Dynamic Worker isolate with no file system, no environment variables exposed, and outbound requests controlled via explicit handlers. This design mitigates risks associated with executing untrusted code while preserving agent autonomy.

This new MCP server for the entire Cloudflare API spans DNS, Zero Trust, Workers, and R2 services already and is immediately available for developers to integrate. Cloudflare also open‑sourced a Code Mode SDK within its broader Agents SDK to enable similar patterns in third‑party MCP implementations.

Analysts and practitioners see Code Mode as a key step in scaling agentic workflows beyond simple, single‑service interactions toward broad, multi‑API automation. The pattern may influence both standard MCP server designs and agent frameworks in the coming year, as industry players grapple with context costs and orchestration complexity in production‑grade AI agents.

About the Author

Image 13
Image 13

#### Leela Kumili

Leela is a Lead Software Engineer at Starbucks with deep expertise in building scalable, cloud-native systems and distributed platforms. She drives architecture, delivery, and operational excellence across the Rewards Platform, leading efforts to modernize systems, improve scalability, and enhance reliability. In addition to her technical leadership, Leela serves as an AI Champion for the organization, identifying opportunities to improve developer productivity and workflows using LLM-based tools and establishing best practices for AI adoption. She is passionate about building production-ready systems, enhancing developer experience, and mentoring engineers to grow in both technical and strategic impact. Her interests include platform engineering, distributed systems, developer productivity, and bridging technical solutions with business and product goals.

Show more Show less

#### This content is in the Model Context Protocol (MCP) topic

Follow Topic

##### Related Topics:

Followers: 4085

Follow Topic

Followers: 10197

Follow Topic

Followers: 5862

Follow Topic

Followers: 30

Follow Topic

Followers: 30

Follow Topic

Followers: 39

Follow Topic

Followers: 34

Follow Topic

Followers: 137

Follow Topic

Followers: 280

Follow Topic

Followers: 22

Follow Topic

Followers: 86

Follow Topic

Followers: 9

Follow Topic

* #### Related Editorial

* #### Related Sponsors

  • #### Related Sponsor

![Image 14: Related sponsor icon/filters:no_upscale()/sponsorship/topic/ae9df779-fe62-46d8-a42e-92795ae3c56e/promptfoo-horizontal-logo-1775562471842.png)](http://www.infoq.com/url/f/ac3acfb3-1e82-4ec1-9c7f-90bfe0eb5c3d/)Confidently test, evaluate, and red-team your LLM apps with Promptfoo — catch regressions, benchmark models, and ship high-quality AI features faster; start testing your prompts today. [Learn More](http://www.infoq.com/url/f/8203624c-6df0-4a73-8509-d2054ffc174e/).

Related Content

Apr 09, 2026

Apr 04, 2026

Apr 02, 2026

Apr 01, 2026

Apr 01, 2026

Mar 31, 2026

Mar 29, 2026

Mar 20, 2026

Mar 18, 2026

Related Sponsors

The Model Context Protocol (MCP) defines a standard way for AI systems to interact with tools, data, and services. This article explains MCP’s architecture—hosts, clients, and servers—and how it enables structured, secure integrations between AI models and external systems.

AI agents extend LLMs with tools, APIs, and memory—expanding both capability and risk. This article explores agent architectures, common attack vectors such as prompt injection and agent hijacking, and practical controls for securing autonomous AI systems.

  • Sponsored by

![Image 17: Icon image/filters:no_upscale()/sponsorship/topic/ae9df779-fe62-46d8-a42e-92795ae3c56e/promptfoo-horizontal-logo-1775562471842.png)](http://www.infoq.com/url/f/ac3acfb3-1e82-4ec1-9c7f-90bfe0eb5c3d/)

Related Content

Apr 09, 2026

Apr 04, 2026

Mar 29, 2026

Mar 27, 2026

Mar 27, 2026

Mar 20, 2026

**The InfoQ** Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

Enter your e-mail address

Select your country - [x] I consent to InfoQ.com handling my data as explained in this Privacy Notice.

We protect your privacy.

  • ##### [From VR to Flat Screens: Bridging the Input and Immersion Gap](http://www.infoq.com/presentations/game-vr-flat-screens/ "From VR to Flat Screens: Bridging the Input and Immersion Gap")
  • ##### [Cursor 3 Introduces Agent-First Interface, Moving Beyond the IDE Model](http://www.infoq.com/news/2026/04/cursor-3-agent-first-interface/ "Cursor 3 Introduces Agent-First Interface, Moving Beyond the IDE Model")
  • ##### [Claude Code Used to Find Remotely Exploitable Linux Kernel Vulnerability Hidden for 23 Years](http://www.infoq.com/news/2026/04/claude-code-linux-vulnerability/ "Claude Code Used to Find Remotely Exploitable Linux Kernel Vulnerability Hidden for 23 Years")
  • ##### [Cloudflare Launches Code Mode MCP Server to Optimize Token Usage for AI Agents](http://www.infoq.com/news/2026/04/cloudflare-code-mode-mcp-server/ "Cloudflare Launches Code Mode MCP Server to Optimize Token Usage for AI Agents")
  • ##### [Zendesk Says AI Makes Code Abundant, Shifting the Bottleneck to “Absorption Capacity”](http://www.infoq.com/news/2026/04/zendesk-absorption-capacity/ "Zendesk Says AI Makes Code Abundant, Shifting the Bottleneck to “Absorption Capacity”")
  • ##### [Platform Engineering: Lessons from the Rise and Fall of eBay Velocity](http://www.infoq.com/presentations/platform-engineering-lessons/ "Platform Engineering: Lessons from the Rise and Fall of eBay Velocity")
  • ##### [Platform as a Product: Delivering Value While Balancing Competing Priorities](http://www.infoq.com/news/2026/04/platform-product-deliver-value/ "Platform as a Product: Delivering Value While Balancing Competing Priorities")
  • ##### [Empower Your Developers: How Open Source Dependencies Risk Management Can Unlock Innovation](http://www.infoq.com/presentations/open-source-dependencies/ "Empower Your Developers: How Open Source Dependencies Risk Management Can Unlock Innovation")
  • ##### [Tiger Teams, Evals and Agents: The New AI Engineering Playbook](http://www.infoq.com/podcasts/tiger-teams-evals-agents/ "Tiger Teams, Evals and Agents: The New AI Engineering Playbook")
  • ##### [Google Opens Gemma 4 Under Apache 2.0 with Multimodal and Agentic Capabilities](http://www.infoq.com/news/2026/04/google-gemm4/ "Google Opens Gemma 4 Under Apache 2.0 with Multimodal and Agentic Capabilities")
  • ##### [Google’s TurboQuant Compression May Support Faster Inference, Same Accuracy on Less Capable Hardware](http://www.infoq.com/news/2026/04/turboquant-compression-kv-cache/ "Google’s TurboQuant Compression May Support Faster Inference, Same Accuracy on Less Capable Hardware")
  • ##### [Anthropic Paper Examines Behavioral Impact of Emotion-Like Mechanisms in LLMs](http://www.infoq.com/news/2026/04/anthropic-paper-llms/ "Anthropic Paper Examines Behavioral Impact of Emotion-Like Mechanisms in LLMs")
  • ##### [OpenTelemetry Declarative Configuration Reaches Stability Milestone](http://www.infoq.com/news/2026/04/opentelemetry-declarative-config/ "OpenTelemetry Declarative Configuration Reaches Stability Milestone")
  • ##### [New Rowhammer Attacks on NVIDIA GPUs Enable Full System Takeover](http://www.infoq.com/news/2026/04/rowhammer-attacks-nvidia/ "New Rowhammer Attacks on NVIDIA GPUs Enable Full System Takeover")
  • ##### [Beyond One-Click: Designing an Enterprise-Grade Observability Extension for Docker](http://www.infoq.com/articles/enterprise-grade-observability-extension-docker/ "Beyond One-Click: Designing an Enterprise-Grade Observability Extension for Docker")

**The InfoQ** Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

  • Get a quick overview of content published on a variety of innovator and early adopter technologies
  • Learn what you don’t know that you don’t know
  • Stay up to date with the latest information from the topics you are interested in

Enter your e-mail address

Select your country - [x] I consent to InfoQ.com handling my data as explained in this Privacy Notice.

We protect your privacy.

**May 7 | June 10, 2026 | Online** Architecture decisions are hard to validate while shipping. Join a **5-week online cohort** for **senior engineers, architects, and team leads** to pressure-test real decisions, apply practical frameworks, and work through challenges with a confidential peer group. Facilitated by Luca Mezzalira, Principal Architect at AWS, this cohort helps you: * Pressure-test real decisions. * Apply frameworks to real problems. * Publish on InfoQ.com and earn your certification. **RESERVE YOUR PLACE**

#### Events

May 7, 2026

June 1-2, 2026

June 10, 2026

November 16-20, 2026

#### Follow us on

Youtube 232K FollowersLinkedin 26K FollowersRSS 19K ReadersX 57.1k FollowersFacebook 21K LikesBluesky NewAlexa New

#### Stay in the know

The InfoQ Podcast![Image 18: The InfoQ Podcast Logo - Stay in the know](http://www.infoq.com/podcasts/)Engineering Culture Podcast![Image 19: Engineering Culture Podcast Logo - Stay in the knoww](http://www.infoq.com/podcasts/#engineering_culture)The Software Architects' Newsletter![Image 20: The Software Architects' Newsletter Logo - Stay in the know](http://www.infoq.com/software-architects-newsletter/)

General Feedback [[email protected]](mailto:[email protected]) Advertising [[email protected]](mailto:[email protected]) Editorial [[email protected]](mailto:[email protected]) Marketing [[email protected]](mailto:[email protected])

InfoQ.com and all content copyright © 2006-2026 C4Media Inc.

Privacy Notice, Terms And Conditions, Cookie Policy

Close

[BT](http://www.infoq.com/int/bt/ "bt")