CloudflareがAIエージェント向けトークン使用最適化のためCode Mode MCPサーバーを発表
Cloudflareは、AIエージェントが大規模APIと最小限のトークン使用量で対話できるようにする、Code Modeを搭載した新しいModel Context Protocol (MCP)サーバーを発表した。
キーポイント
新MCPサーバーの発表
Cloudflareが、Code Modeを搭載した新しいModel Context Protocol (MCP)サーバーをローンチした。
効率化の目的
このサーバーは、AIエージェントが大規模APIと対話する際のトークン使用量を最小限に抑えることを目的としている。
主な機能と利点
2,500以上のエンドポイントにわたるコンテキストフットプリントの削減、マルチAPIオーケストレーションの改善、LLMエージェントのための安全でコード中心の実行環境の提供を実現する。
影響分析・編集コメントを表示
影響分析
この発表は、AIエージェントが外部APIを効率的かつ安全に利用するためのインフラストラクチャを強化する動きを示している。特に、運用コストの要因となるトークン使用量の最適化は、AIエージェントの実用化とスケーリングにおいて重要な進展と言える。
編集コメント
AIエージェントの実運用におけるコストとセキュリティという現実的な課題に取り組む、実用志向のインフラ発表。今後の類似サービスや業界標準への影響を注視したい。
Cloudflareは、Code Modeを搭載した新しいModel Context Protocol(MCP)サーバーをリリースし、AIエージェントが複雑なAPIにアクセスする方法に大きな進化をもたらしました。これにより、同社の完全なAPIプラットフォームとのインタラクションコストが劇的に削減されています。この新しいアプローチは、MCPエコシステムにおけるエージェントとツールの統合に関する新たな可能性を示しています。
本質的に、MCPは外部ツールやAPIと連携する大規模言語モデル(LLMs)のための新興規格であり、実行中にモデルが呼び出せる構造化されたツールを公開する仕組みを提供します。従来、エージェントに公開される各APIエンドポイントは個別のツール定義として扱われていました。この方式は単純明快ですが、ツール仕様が発生するたびにモデルの限られた入力予算内でトークンを消費するため、コンテキストウィンドウのコストが非常に大きくなり、ユーザーのタスクに関する推論に充てる余地が少なくなってしまうという課題がありました。
CloudflareのソリューションエンジニアであるLuuk Hofman氏は次のように述べています:
そこで私たちは、MCPツールをTypeScript APIに変換し、LLMに対してそれに対してコードを書くよう依頼するアプローチを試みました。
一方、CloudflareのCode Modeはsearch()とexecute()という2つのツールのみを公開し、安全なV8アイソレート(V8 isolate)内でJavaScriptの生成と実行を可能にする型の情報を認識するSDKによって裏付けられています。これにより、エージェントの計画はOpenAPI仕様(OpenAPI spec)に対して複数の操作を調整する小さなコードスニペットにコンパイルされ、すべてのエンドポイント定義をコンテキストに読み込む必要がなくなります。
従来のMCPとCloudflareのCode Mode(出典:Cloudflareブログ記事)
実務への影響は大きく、CloudflareによるとCode Modeは2,500以上のAPIエンドポイントとのインタラクションに必要なトークンフットプリントを、117万トークン以上から約1,000トークンに削減しており、削減率は約99.9%に達します。この固定されたフットプリントはAPIの規模(API surface size)に関係なく維持されるため、エージェントはモデルのコンテキストを枯渇させることなく、大規模で機能豊富なプラットフォーム全体を跨いで動作できます。
CloudflareはRedditでの投稿で次の点を強調しています:
チームは、機能的な精度を損なうことなく、広範なAPIスキーマ(API schemas)を最小限のコンテキストウィンドウに収めるために、専用のエンコーディング戦略を採用しました。
エージェントはまずsearch()を使用して、製品領域、パス、またはメタデータに基づきOpenAPI仕様(OpenAPI spec)を検索します。仕様自体はモデルのコンテキストに入ることはありません。その後、execute()がページネーション(pagination)、条件分岐ロジック、および連鎖的なAPI呼び出しを処理するコードを単一サイクルで実行し、往復オーバーヘッド(round-trip overhead)を削減します。
Cloudflareは実行時のセキュリティとサンドボックス化モデルについても強調しています。サーバーは、ファイルシステムが存在せず、環境変数が公開されず、送信リクエストが明示的なハンドラーによって制御されるDynamic Workerアイソレート(Dynamic Worker isolate)内でユーザー生成コードを実行します。この設計は、信頼できないコードの実行に伴うリスクを軽減しつつ、エージェントの自律性を維持します。
全Cloudflare APIを対象としたこの新しいMCPサーバーは、すでにDNS、Zero Trust、Workers、R2の各サービスにまたがっており、開発者がすぐに統合利用できるようになっています。さらにCloudflareは、サードパーティのMCP実装において同様のパターンを可能にするため、より広範なAgents SDK内にCode Mode SDKをオープンソースとして公開しました。
アナリストや実務家は、Code Modeを、単一のサービス間での単純なインタラクションを超えて広範なマルチAPI自動化へとスケーリングするエージェントワークフロー(agentic workflows)における重要な一歩と見なしている。このパターンは、来年には標準的なMCPサーバー(MCP server)の設計やエージェントフレームワークにも影響を与える可能性があり、業界関係者は本番環境レベルのAIエージェントにおけるコンテキストコスト(context costs)やオーケストレーションの複雑さ(orchestration complexity)と格闘している。
About the Author
Leela Kumili
LeelaはStarbucksのシニアソフトウェアエンジニアであり、スケーラブルなクラウドネイティブシステム(cloud-native systems)や分散プラットフォームの構築において深い専門知識を有している。彼女はRewards Platform全体を通じてアーキテクチャ、納品、運用の卓越性を牽引し、システムの近代化、スケーラビリティの向上、信頼性の強化に向けた取り組みを主導している。
技術的なリーダーシップに加え、Leelaは組織内のAIチャンピオン(AI Champion)としても活動し、LLMベースのツール(LLM-based tools)を活用して開発者の生産性やワークフローを改善する機会を特定し、AI導入のベストプラクティスを確立している。彼女は本番環境対応システムの構築、開発者体験の向上、そしてエンジニアが技術的・戦略的な影響力の両面で成長できるようメンタリングすることに情熱を注いでいる。彼女の興味のある分野には、プラットフォームエンジニアリング(platform engineering)、分散システム、開発者生産性、そして技術的ソリューションとビジネス・プロダクトの目標を結びつけることなどが含まれる。
詳細を表示 / 表示を閉じる
原文を表示
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.
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
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 moreShow less
関連記事
Cloudflareサンドボックスが一般提供開始、AIエージェントに永続的な隔離環境を提供
CloudflareはAIエージェント向けにSandboxesを一般提供開始し、永続的な隔離Linux環境を提供した。資格情報注入やセッション復元機能も実装された。
AIの現実検証:3社がウォレット、住宅、ゲーム構築で学んだこと
シティ、ホームデポ、カプコンの経営陣は、AIエージェントが実験ツールから顧客対応業務へ移行する過程で得た知見を語った。次なる課題は、金銭や創造的出力に関わる際のガバナンスと信頼性の確保である。
アンストロピック「強力なAIモデルはより良い取引を実現し、劣るモデルを使う利用者は気づかない」
アンストロピックは社内市場で69のAIエージェントに取引をさせ、強力なモデルがより良い結果を出した。利用者は劣るモデルの差に気づかず、AIの実取引化は経済格差を拡大させる可能性がある。