自社プラットフォーム上で構築した社内AIエンジニアリングスタック
Cloudflareは自社プラットフォーム上に内部向けAIエンジニアリングスタックを構築し、R&D組織の93%が活用する大規模な実装と開発速度の向上を実現した。
キーポイント
大規模な社内AIツールの導入実績と数値指標
30日間でR&D組織の93%、計3,683人がAIコーディングツールを活用し、月間2000万件以上のGatewayリクエストと数百億トークンの処理を記録している。
MCPプロトコルを基盤としたアーキテクチャ設計
Internal MCP Agent/Server Rollout Squad(iMARS)が中心となり、エージェントの標準化、コードレビュー、オンボーディング、リポジトリ間の変更伝播を再定義する基盤を整備した。
Cloudflare製品群を活用したセキュリティと実行環境の構築
Accessによる認証、AI Gatewayによる中央集権ルーティングとコスト管理、Workers AIによる推論、Dynamic Workersによるサンドボックス実行など、既存プラットフォームを再構成して安全な環境を提供している。
エンジニアリング生産性への明確な影響と開発フローの再定義
AIツールの普及に伴い、週次マージリクエスト数の4週間移動平均が約5,600件から8,700件超へ増加し、過去最高レベルの開発速度向上が確認されている。
Workers AI上でのKimi K2.5活用とコスト削減効果
1日70億トークン以上のセキュリティ処理をKimi K2.5で実行し、専用モデルより77%の費用削減を実現。CIレビューや低レイテンシ推論など内部ワークロードの拡大も見込む。
単一プロキシWorkerによる中央制御アーキテクチャ
クライアントから直接接続せず単一Workerでルーティングすることで、ユーザー属性追跡、モデルカタログ管理、権限制御を一元化。クライアント設定変更なしで機能拡張が可能。
単一コマンドでのゼロコンフィグ設定と認証フロー
`opencode auth login` 1つのコマンドでDiscoveryエンドポイント経由し、認証情報やプロバイダー設定を自動取得。Cloudflare Access連携によりJWTを発行・付与するシームレスな認証フローを実現。
影響分析・編集コメントを表示
影響分析
Cloudflareの実装事例は、大規模組織が自社プラットフォームを活用してAIエンジニアリングスタックを構築する際の標準的な設計パターンを示している。MCPプロトコルの普及と合わせ、今後は「AI Gateway」や「サンドボックス実行環境」を基盤とした企業内AIインフラ構築が業界標準となる可能性が高い。これにより、セキュリティと開発速度の両立を追求するエンジニアリング組織が増加すると予想される。
編集コメント
Cloudflareは自社プラットフォームを再構成することで、セキュリティと開発速度の両立という企業AI導入の難題を解決する実証ケースを提供している。MCP標準化が進む中、今後は「プラットフォーム内蔵のAIインフラ」を活用する企業が増加し、独自モデル開発から運用基盤構築へ投資重心がシフトすると予想される。
過去30日間で、CloudflareのR&D組織の93%が、自社プラットフォーム上に構築したインフラによって駆動されるAIコーディングツールを使用しました。
11ヶ月前、私たちは大規模なプロジェクトに取り組みました:本格的にAIをエンジニアリングスタック(engineering stack)に統合することです。Cloudflareでエージェント(agents)が有用となるために必要な内部MCPサーバー、アクセスレイヤー(access layer)、AIツールリングを構築する必要がありました。私たちは社内のエンジニアを集め、「iMARS(Internal MCP Agent/Server Rollout Squad)」というタスクフォースを結成しました。この継続的な作業は、CI/CD、ビルドシステム(build systems)、自動化を含む内部ツールリングの多くを管理するDev Productivityチームに引き継がれました。
過去30日間の自社エージェント型AI(agentic AI)の使用状況を表すいくつかの数字を以下に示します:
約6,100人の全従業員のうち、3,683人がAIコーディングツールをアクティブに使用(社内全体で60%、R&D部門で93%)
4,795万回のAIリクエスト
現在295のチームがエージェント型AIツールおよびコーディングアシスタントを活用しています。
月間2,018万回のAI Gatewayリクエスト
AI Gatewayを介してルーティングされた2,413億700万トークン
Workers AIで処理された5,183億トークン
社内における開発者ビロシティ(developer velocity)への影響は明確です:四半期ごとのマージリクエストの増加率をこれほど見たことはかつてありません。

AIツールリングの採用が拡大するにつれて、4週間のローリング平均(rolling average)は週約5,600件から8,700件超に上昇しました。3月23日付の週は10,952件を記録し、第4四半期のベースラインのほぼ2倍に達しました。
MCPサーバーが起点でしたが、チームはすぐにさらに踏み込む必要があることに気づきました:標準をコード化する方法、コードレビューの仕組み、エンジニアのオンボーディングプロセス、そして数千のリポジトリにわたる変更の伝播方法を再考する必要があります。
この記事では、過去11ヶ月間でそれがどのようなものだったか、そして最終的にどこに辿り着いたかを深く掘り下げています。今週出荷・強化している製品と同じ基盤上で内部のAIエンジニアリングスタックが稼働しているため、Agents Weekを締めくくるために現在公開するものです。
The architecture at a glance
エンジニア向けツールレイヤー(OpenCode、Windsurf、およびその他のMCP互換クライアント)には、オープンソースおよびサードパーティのコーディングアシスタントツールが含まれます。

各レイヤーは、当社が使用するCloudflare製品またはツールにマッピングされます:
構築したもの
使用技術
ゼロトラスト認証(Zero Trust authentication)
Cloudflare Access
集中型LLMルーティング、コスト追跡、BYOK(Bring Your Own Key)、ゼロデータ保持制御
AI Gateway
オープンウェイトモデルによるプラットフォーム内推論(On-platform inference with open-weight models)
Workers AI
シングルOAuthを備えたMCPサーバーポータル(MCP Server Portal with single OAuth)
Workers + Access
AIコードレビュアーCI統合(AI Code Reviewer CI integration)
Workers + AI Gateway
エージェント生成コードのサンドボックス実行(Code Mode)
Dynamic Workers
ステートフルで長時間実行されるエージェントセッション(Stateful, long-running agent sessions)
エージェントSDK(Agents SDK)(McpAgent、Durable Objects)
クローン作成、ビルド、テストのための分離環境
Sandbox SDK — エージェントウィークよりGA(General Availability)
耐久性のあるマルチステップワークフロー
Workflows — エージェントウィーク中に10倍にスケール
16,000以上のエンティティ・ナレッジグラフ
Backstage (OSS)
これらのいずれも社内限定のインフラストラクチャではありません。上記にリストされているもの(Backstageを除く)はすべて出荷対象の製品であり、その多くがエージェントウィーク中に大幅なアップデートを受けました。
これを3つの章(アクト)に分けて解説します。
The platform layer — 認証、ルーティング、推論の仕組み(AI Gateway, Workers AI, MCP Portal, Code Mode)
The knowledge layer — エージェントが当社のシステムをどのように理解するか(Backstage, AGENTS.md)
The enforcement layer — 大規模な環境でいかに高品質を維持するか(AI Code Reviewer, Engineering Codex)
Act 1: The platform layer
How AI Gateway helped us stay secure and improve the developer experience
毎日3,600人以上の社内ユーザーがAIコーディングツールを利用している場合、多くのクライアント、ユースケース、役割にわたるアクセスと可視性の問題を解決する必要があります。
すべての基盤となるのはCloudflare Accessであり、これはすべての認証とゼロトラストポリシー(zero-trust policy)の適用を処理します。認証が完了すると、すべてのLLM(大規模言語モデル)リクエストはAI Gatewayを経由してルーティングされます。これにより、プロバイダーキーの管理、コスト追跡、データ保持ポリシーを一元化できます。
image
The OpenCode AI Gateway overview: 688.46k requests per day, 10.57B tokens per day, routing to four providers through one endpoint.
AI Gatewayの分析データは、月次使用量がモデルプロバイダー間でどのように分散されているかを示しています。過去1ヶ月の社内リクエスト量は以下の通りです。
Provider
Requests/month
Share
Frontier Labs (OpenAI, Anthropic, Google)
13.38M
91.16%
Workers AI
1.3M
8.84%
Frontierモデル(Frontier models)は現在、複雑なエージェント型コーディング作業(agentic coding work)の大部分を担っていますが、Workers AIもすでにその構成の重要な部分を占めており、エージェント型エンジニアリングワークロードの増加するシェアを処理しています。
How we increasingly leverage Workers AI
Workers AIは、CloudflareのサーバーレスAI推論プラットフォーム(serverless AI inference platform)であり、グローバルネットワーク上のGPUでオープンソースモデルを実行します。Frontierモデルと比較して大幅なコスト改善があるだけでなく、重要な利点は推論がWorkers、Durable Objects、ストレージと同じネットワーク上に留まることです。クラウド間を跨ぐホップ処理が必要ないため、レイテンシの増加やネットワークの不安定性、管理すべき追加のネットワーク設定を回避できます。
image
Workers AI usage in the last month: 51.47B input tokens, 361.12M output tokens.
2026年3月にWorkers AI上でリリースされたKimi K2.5は、256kコンテキストウィンドウ(context window)、ツール呼び出し(tool calling)、構造化出力(structured outputs)を備えたフロンティア規模のオープンソースモデルです。Kimi K2.5のリリース記事で述べた通り、当社のセキュリティエージェント(security agent)はKimi上で1日あたり70億トークン以上を処理しています。この処理量をミッドティアの独自モデル(proprietary model)で実行した場合、年間約240万ドルのコストが見込まれます。しかしWorkers AI上では、そのコストが77%安くなります。
セキュリティ用途に加え、当社はWorkers AIをCIパイプライン(CI pipeline)内のドキュメントレビューや、数千のリポジトリにわたるAGENTS.mdコンテキストファイルの生成、そしてモデルの最大性能よりも同じネットワーク内でのレイテンシ(same-network latency)が重要となる軽量推論タスク(lightweight inference tasks)に使用しています。
オープンソースモデルが継続的に改善されるにつれ、当社の内部ワークロード(internal workloads)のより大きな割合をWorkers AIが処理すると見込んでいます。
当初から正しく実装できたことの1つ:初日から単一のプロキシWorker(proxy Worker)経由でルーティングすること。当初はクライアントがAI Gatewayに直接接続する方がセットアップは簡単だったかもしれません。しかし、Workerを介して一元化したことで、後からクライアント設定を一切変更することなく、ユーザーごとのアトリビューション(per-user attribution)、モデルカタログ管理、権限の適用(permission enforcement)を追加できました。以下のブートストラップセクションで説明されているすべての機能は、この単一ボトルネック(choke point)が存在したからこそ実現しています。プロキシパターンは、直接接続では得られないコントロールプレーン(control plane)を提供し、後から追加のコーディングアシスタントツールを接続した場合でも、同じWorkerとディスカバリーエンドポイント(discovery endpoint)がそれらを処理します。
仕組み:1つのURLで全てを構成
全体のセットアップは、1つのコマンドから始まります。
opencode auth login https://opencode.internal.domain
そのコマンドは、ユーザーが設定ファイルを一切操作することなく、プロバイダー、モデル、MCPサーバー(MCP servers)、エージェント、コマンド、権限を構成する一連の処理をトリガーします。
image
ステップ1:認証要件の発見。OpenCodeは https://opencode.internal.domain/.well-known/opencode などのURLから設定を取得します。
このディスカバリーエンドポイント(discovery endpoint)はWorkerによって提供され、レスポンスにはOpenCodeの認証方法を指示するauthブロックと、プロバイダー、MCPサーバー(MCP servers)、エージェント、コマンド、デフォルト権限を含むconfigブロックが含まれます。
{
"auth": {
"command": ["cloudflared", "access", "login", "..."],
"env": "TOKEN"
},
"config": {
"provider": { "..." },
"mcp": { "..." },
"agent": { "..." },
"command": { "..." },
"permission": { "..." }
}
}
ステップ2:Cloudflare Access経由の認証。OpenCodeは認証コマンドを実行し、ユーザーはCloudflareでの他のすべての操作に使用するのと同じSSO(Single Sign-On)を介して認証を行います。cloudflaredは署名付きJWT(JSON Web Token)を返します。OpenCodeはこれをローカルに保存し、後続のプロバイダーリクエストのすべてに自動的に付与します。
ステップ3:設定がOpenCodeにマージされます。提供される設定は組織全体の共有デフォルトですが、ローカル設定が常に優先されます。ユーザーは他の人に影響を与えることなく、デフォルトモデルを上書きしたり、独自のエージェントを追加したり、プロジェクトおよびユーザースコープの権限を調整したりできます。
プロキシワーカー(Worker)の内部。このワーカーは単純なHonoアプリケーション(Hono App)で、以下の3つのことを実行します:
共有設定の提供。この設定はデプロイ時に構造化されたソースファイルからコンパイルされ、ワーカーのオリジン用の{baseURL}のようなプレースホルダー値を含みます。リクエスト発生時、ワーカーはこれらを書き換えるため、すべてのプロバイダーリクエストはモデルプロバイダーに直接ではなくワーカーを経由してルーティングされます。各プロバイダーにはパスプレフィックス(/anthropic、/openai、/google-ai-studio/v1beta、Workers AI用の/compat)が割り当てられ、ワーカーはこれを対応するAI Gateway(AI Gateway)ルートに転送します。
AI Gatewayへのリクエストのプロキシ。OpenCodeがPOST /anthropic/v1/messagesのようなリクエストを送信すると、ワーカーはCloudflare Access JWTを検証し、転送前にヘッダーを書き換えます:
削除対象: authorization, cf-access-token, host
追加: cf-aig-authorization: Bearer
cf-aig-metadata: {"userId": ""}リクエストはAI Gatewayに送信され、適切なプロバイダーへルーティングされます。レスポンスはゼロバッファリングでそのまま通過します。クライアント設定のapiKeyフィールドが空なのは、ワーカーがサーバーサイドで実際のキーを注入するためです。ユーザーの端末にはAPIキーが存在しません。
モデルカタログの最新維持。毎時間のcronトリガーがmodels.devから現在のOpenAIモデルリストを取得し、Workers KVストレージ(Workers KV)にキャッシュして、ゼロデータ保持(Zero Data Retention / ZDR)のために各モデルにstore: falseを注入します。新しいモデルは、設定の再デプロイなしでZDRが自動的に適用されます。
匿名ユーザーの追跡。JWT検証後、ワーカーは永続ストレージにD1データベース(D1)、読み取りキャッシュにKVを使用して、ユーザーのメールアドレスをUUIDに変換します。AI Gatewayが確認できるのはcf-aig-metadata内の匿名UUIDのみで、メールアドレスは決して表示されません。これにより、モデルプロバイダーやGatewayログにユーザーの身元を晒すことなく、ユーザーごとのコスト追跡と使用状況分析が可能になります。
コードとしての設定(Config-as-code)。エージェントとコマンドはYAML frontmatter付きのmarkdownファイルとして作成されます。ビルドスクリプトがこれらをOpenCode JSONスキーマに対して検証された単一のJSON設定にコンパイルします。新しいセッションは常に最新バージョンを自動的に取得します。
全体のアーキテクチャはシンプルで、開発者プラットフォームを使用して誰でも簡単にデプロイできます:プロキシワーカー、Cloudflare Access、AI Gateway、そしてすべてを自動的に設定するクライアントアクセス可能なディスカバリーエンドポイントです。ユーザーはコマンドを1つ実行するだけで完了します。手動で設定すべきものはなく、ラップトップにAPIキーを配置する必要もMCPサーバー接続を手動でセットアップする必要もありません。エージェントツールへの変更と、3,000人以上の開発者のコーディング環境に提供される内容の更新は、wrangler deployを実行するだけですぐに反映されます。
MCPサーバーポータル(MCP Server Portal):1つのOAuth、複数のMCPツール
別の記事で、エンタープライズ規模でのMCP(Model Context Protocol)ガバナンスにおける当社の完全なアプローチについて説明しました。そこでは、MCP Server Portals、Cloudflare Access、Code Modeをどのように組み合わせて使用しているかについても触れています。以下は、社内で作成したものの簡易版です。

社内ポータルは、Backstage、GitLab、Jira、Sentry、Elasticsearch、Prometheus、Google Workspace、社内Release Managerなど、13の本番環境用MCPサーバーを統合し、182以上のツールを公開しています。これによりアクセスが一元化され、すべてのプロセスが簡素化されました。その結果、すべてのツールへのアクセスを管理するエンドポイントは1つ、Cloudflare Accessのフローも1つというシンプルな構成が実現しています。
各MCPサーバーは同じ基盤の上に構築されています。Agents SDK由来のMcpAgent、OAuth用のworkers-oauth-provider、アイデンティティ管理用のCloudflare Accessです。全体は単一のmonorepo(モノレポ)に収められており、共有の認証インフラストラクチャ、Bazelビルド(Bazel builds)、CI/CDパイプライン(CI/CD pipelines)、Backstage登録用のcatalog-info.yamlを共有しています。新しいサーバーを追加する際は、既存のものをコピーしてラップするAPIを変更するだけです。仕組みの詳細や背後にあるセキュリティアーキテクチャについては、エンタープライズMCPリファレンスアーキテクチャをご覧ください。
Code Mode at the portal layer
MCPはAIエージェントとツールを接続するための適切なプロトコルですが、実用的な問題があります。それは、モデルが作業を開始する前に、すべてのツール定義がcontext window tokens(コンテキストウィンドウトークン)を消費してしまう点です。MCPサーバーとツールの数が増えるにつれてtoken overhead(トークンオーバーヘッド)も増大し、スケールする本番環境ではこれが実際のコストとなります。Code Modeは現在注目されている解決策です。すべてのtool schema(ツールスキーマ)を事前に読み込むのではなく、モデルがcodeを通じてツールを検出し、呼び出す方式です。
当社のGitLab MCPサーバーは当初、34の個別ツール(get_merge_request、list_pipelines、get_file_contentなど)を公開していました。これら34のtool schemas(ツールスキーマ)は、リクエストごとに約15,000トークンのcontext window(コンテキストウィンドウ)を消費していました。200Kのcontext windowにおいて、これは質問をする前に予算の7.5%を消費する計算になります。すべてのリクエスト、すべてのエンジニア、毎日このように積み重なるため、無視できないコストとなります。
MCP Server Portalsは現在、Code Mode proxying(Code Modeプロキシ)をサポートしており、これによりサーバーごとに個別に対応するのではなく、中央でこの問題を解決できます。クライアントにすべてのupstream tool definition(アップストリームツール定義)を公開する代わりに、ポータルはそれらを2つのportal-level tools(ポータルレベルのツール)に集約しています。それがportal_codemode_searchとportal_codemode_executeです。

ポータルレイヤーでこれを行うことの利点は、クリーンにスケールできる点です。Code Modeがない場合、新しいMCPサーバーを追加するたびにすべてのリクエストにschema overhead(スキーマオーバーヘッド)が追加されます。ポータルレベルのCode Modeを採用すれば、ポータルの背後に接続するサーバーが増えいても、クライアントが確認できるツールは依然として2つのままです。つまり、context bloat(コンテキストの肥大化)が抑えられ、token cost(トークンコスト)が削減され、全体としてよりクリーンなアーキテクチャが実現します。
Act 2: The knowledge layer
Backstage: そのすべてを支えるナレッジグラフ
iMARSチームが実際に有用なMCPサーバー(Model Context Protocol Server)を構築する前に、私たちはより根本的な問題を解決する必要がありました。それは、サービスやインフラストラクチャに関する構造化データです。エージェントには、コードベース外のコンテキストを理解する必要があります。具体的には、どのリソースのオーナーが誰か、サービス間の依存関係はどうか、ドキュメントはどこに保管されているのか、そして各サービスがどのデータベースと通信しているのかといった情報です。
サービスカタログとして、Spotifyによって当初開発されたオープンソースの内部開発者ポータル「Backstage」を運用しています。これはセルフホスティングされています(念のため、Cloudflareの製品上ではありません)が、以下のような情報を追跡しています。
2,055のサービス、167のライブラリ、122のパッケージ
スキーマ定義付きの228のAPI
45のドメインに跨る544のシステム(プロダクト)
1,302のデータベース、277のClickHouseテーブル、173のクラスター
オーナーシップマッピングが設定された375のチームと6,389人のユーザー
サービスが依存するデータベース、Kafkaトピック、クラウドリソースを結ぶ依存関係グラフ
Backstage MCPサーバー(13のツール)はMCPポータルを通じて利用可能であり、エージェントはコーディングセッションを離れることなく、サービスのオーナー確認、依存関係のチェック、関連するAPI仕様書の検索、Tech Insightsスコアの取得を行うことができます。
この構造化データがなければ、エージェントは盲目で作業することになります。眼前のコードを読むことはできますが、その周囲のシステム全体を見渡すことができないからです。このカタログは、個々のリポジトリをエンジニアリング組織のつながったマップに変換します。
AGENTS.md:数千のリポジトリをAI対応へ準備する
ロールアウト初期、私たちは同じ失敗パターン(failure mode)を繰り返し目にしていました。コーディングエージェントが妥当そうに見える変更を生成するものの、結局はリポジトリに対して誤っていたのです。通常の問題はローカルコンテキストでした。モデルが正しいテストコマンドやチームの現在の規約、あるいはコードベースのどの部分がアクセス不可領域なのかを知っていなかったためです。これがAGENTS.mdへの取り組みを後押ししました。各リポジトリに配置される短く構造化されたファイルで、コーディングエージェントに対してコードベースの実際の動作を伝え、チームにそのコンテキストを明示させるものです。
AGENTS.mdの例
GitLabインスタンス全体でAGENTS.mdファイルを生成するシステムを構築しました。これらのファイルはモデルのコンテキストウィンドウに直接配置されるため、短くかつ情報密度の高い(high-signal)状態を維持したかったのです。典型的なファイルは以下のようになります。
# AGENTS.md
## Repository
- Runtime: cloudflare workers
- Test command: `pnpm test`
- Lint command: `pnpm lint`
## How to navigate this codebase
- All cloudflare workers are in src/workers/, one file per worker
- MCP server definitions are in src/mcp/, each tool in a separate file
- Tests mirror source: src/foo.ts -> tests/foo.test.ts
## Conventions
- Testing: use Vitest with `@cloudflare/vitest-pool-workers` (Codex: RFC 021, RFC 042)
- API patterns: Follow internal REST conventions (Codex: API-REST-01)境界線
gen/内の生成ファイルは編集しないconfig/を更新せずに新しいバックグラウンドジョブ(background jobs)を導入しない
依存関係
- 依存先: auth-service, config-service
- 被依存先: api-gateway, dashboard
エージェントがこのファイルを読み込む際、リポジトリ(repository)をゼロから推測する必要はありません。コードベースの構成方法、従うべき規約、適用されるEngineering Codex(エンジニアリングコデックス)のルールを把握しています。
大規模な生成方法
ジェネレーターパイプラインは、Backstageサービスカタログ(Backstage service catalog)からエンティティメタデータ(entity metadata:所有権、依存関係、システム間関係)を取得し、リポジトリ構造を分析して言語、ビルドシステム(build system)、テストフレームワーク(test framework)、ディレクトリレイアウト(directory layout)を検出します。その後、検出したスタックを関連するEngineering Codex(エンジニアリングコデックス)の基準にマッピングします。高性能なモデルが構造化ドキュメントを生成し、システムは所有チームがレビューして推敲できるようマージリクエスト(merge request)をオープンします。
現在までに約3,900のリポジトリ(repositories)をこの方法で処理しました。最初のパスは必ずしも完璧ではなく、特にポリグロットリポジトリ(polyglot repos:複数言語を混在させたリポジトリ)や特殊なビルド環境の場合にはそうでしたが、それでもそのベースラインはエージェントにすべてをゼロから推測させるよりもはるかに優れていました。
最初のマージリクエスト(merge request)はブートストラップ問題(bootstrap problem)を解決しましたが、これらのファイルを最新に保つことも同様に重要でした。古いAGENTS.mdは、ファイルがない状態よりも悪影響を及ぼす可能性があります。私たちはAIコードレビュアー(AI Code Reviewer)でこのループを閉じました。これはリポジトリの変更がAGENTS.mdの更新を示唆している場合にフラグを立てることができます。
アクト3:適用レイヤー(enforcement layer)
AIコードレビュアー(AI Code Reviewer)
Cloudflareのすべてのマージリクエスト(MR)にはAIコードレビューが適用されます。統合は簡単です:チームはパイプラインに単一のCIコンポーネント(CI component)を追加するだけで、それ以降すべてのMRが自動的にレビューされます。
GitLabのセルフホスティングソリューション(self-hosted solution)をCI/CDプラットフォーム(CI/CD platform)として使用しています。レビュアーは、チームがパイプラインに組み込むGitLab CIコンポーネントとして実装されています。MR(merge request)がオープンまたは更新されると、CIジョブはマルチエージェントレビューコーディネーター(multi-agent review coordinator)を起動してOpenCodeを実行します。コーディネーターはリスクティア(risk tier:trivial、lite、full)でMRを分類し、専門的なレビューエージェントに委任します:コード品質、セキュリティ、コデックス準拠、ドキュメント、パフォーマンス、リリース影響です。各エージェントはモデルアクセスのためにAIゲートウェイ(AI Gateway)に接続し、中央リポジトリからEngineering Codexルールを取得し、コードベースのコンテキストとしてリポジトリのAGENTS.mdを読み取ります。結果は
原文を表示
In the last 30 days, 93% of Cloudflare’s R&D organization used AI coding tools powered by infrastructure we built on our own platform.
Eleven months ago, we undertook a major project: to truly integrate AI into our engineering stack. We needed to build the internal MCP servers, access layer, and AI tooling necessary for agents to be useful at Cloudflare. We pulled together engineers from across the company to form a tiger team called iMARS (Internal MCP Agent/Server Rollout Squad). The sustained work landed with the Dev Productivity team, who also own much of our internal tooling including CI/CD, build systems, and automation.
Here are some numbers that capture our own agentic AI use over the last 30 days:
3,683 internal users actively using AI coding tools (60% company-wide, 93% across R&D), out of approximately 6,100 total employees
47.95 million AI requests
295 teams are currently utilizing agentic AI tools and coding assistants.
20.18 million AI Gateway requests per month
241.37 billion tokens routed through AI Gateway
51.83 billion tokens processed on Workers AI
The impact on developer velocity internally is clear: we’ve never seen a quarter-to-quarter increase in merge requests to this degree.
image
As AI tooling adoption has grown the 4-week rolling average has climbed from ~5,600/week to over 8,700. The week of March 23 hit 10,952, nearly double the Q4 baseline.
MCP servers were the starting point, but the team quickly realized we needed to go further: rethink how standards are codified, how code gets reviewed, how engineers onboard, and how changes propagate across thousands of repos.
This post dives deep into what that looked like over the past eleven months and where we ended up. We're publishing now, to close out Agents Week, because the AI engineering stack we built internally runs on the same products we’re shipping and enhancing this week.
The architecture at a glance
The engineer-facing tools layer (OpenCode, Windsurf, and other MCP-compatible clients) include both open-source and third-party coding assistant tools.
image
Each layer maps to a Cloudflare product or tool we use:
What we built
Built with
Zero Trust authentication
Cloudflare Access
Centralized LLM routing, cost tracking, BYOK, and Zero Data Retention controls
AI Gateway
On-platform inference with open-weight models
Workers AI
MCP Server Portal with single OAuth
Workers + Access
AI Code Reviewer CI integration
Workers + AI Gateway
Sandboxed execution for agent-generated code (Code Mode)
Dynamic Workers
Stateful, long-running agent sessions
Agents SDK (McpAgent, Durable Objects)
Isolated environments for cloning, building, and testing
Sandbox SDK — GA as of Agents Week
Durable multi-step workflows
Workflows — scaled 10x during Agents Week
16K+ entity knowledge graph
Backstage (OSS)
None of this is internal-only infrastructure. Everything (besides Backstage) listed above is a shipping product, and many of them got substantial updates during Agents Week.
We’ll walk through this in three acts:
The platform layer — how authentication, routing, and inference work (AI Gateway, Workers AI, MCP Portal, Code Mode)
The knowledge layer — how agents understand our systems (Backstage, AGENTS.md)
The enforcement layer — how we keep quality high at scale (AI Code Reviewer, Engineering Codex)
Act 1: The platform layer
How AI Gateway helped us stay secure and improve the developer experience
When you have over 3,600+ internal users using AI coding tools daily, you need to solve for access and visibility across many clients, use cases, and roles.
Everything starts with Cloudflare Access, which handles all authentication and zero-trust policy enforcement. Once authenticated, every LLM request routes through AI Gateway. This gives us a single place to manage provider keys, cost tracking, and data retention policies.
image
The OpenCode AI Gateway overview: 688.46k requests per day, 10.57B tokens per day, routing to four providers through one endpoint.
AI Gateway analytics show how monthly usage is distributed across model providers. Over the last month, internal request volume broke down as follows.
Provider
Requests/month
Share
Frontier Labs (OpenAI, Anthropic, Google)
13.38M
91.16%
Workers AI
1.3M
8.84%
Frontier models handle the bulk of complex agentic coding work for now, but Workers AI is already a significant part of the mix and handles an increasing share of our agentic engineering workloads.
How we increasingly leverage Workers AI
Workers AI is Cloudflare's serverless AI inference platform which runs open-source models on GPUs across our global network. Beyond huge cost improvements compared to frontier models, a key advantage is that inference stays on the same network as your Workers, Durable Objects, and storage. No cross-cloud hops to deal with, which cause more latency, network flakiness, and additional networking configuration to manage.
image
Workers AI usage in the last month: 51.47B input tokens, 361.12M output tokens.
Kimi K2.5, launched on Workers AI in March 2026, is a frontier-scale open-source model with a 256k context window, tool calling, and structured outputs. As we described in our Kimi K2.5 launch post, we have a security agent that processes over 7 billion tokens per day on Kimi. That would cost an estimated $2.4M per year on a mid-tier proprietary model. But on Workers AI, it's 77% cheaper.
Beyond security, we use Workers AI for documentation review in our CI pipeline, for generating AGENTS.md context files across thousands of repositories, and for lightweight inference tasks where same-network latency matters more than peak model capability.
As open-source models continue to improve, we expect Workers AI to handle a growing share of our internal workloads.
One thing we got right early: routing through a single proxy Worker from day one. We could have had clients connect directly to AI Gateway, which would have been simpler to set up initially. But centralizing through a Worker meant we could add per-user attribution, model catalog management, and permission enforcement later without touching any client configs. Every feature described in the bootstrap section below exists because we had that single choke point. The proxy pattern gives you a control plane that direct connections don't, and if we plug in additional coding assistant tools later, the same Worker and discovery endpoint will handle them.
How it works: one URL to configure everything
The entire setup starts with one command:
opencode auth login https://opencode.internal.domain
That command triggers a chain that configures providers, models, MCP servers, agents, commands, and permissions, without the user touching a config file.
image
Step 1: Discover auth requirements. OpenCode fetches config from a URL like https://opencode.internal.domain/.well-known/opencode.
This discovery endpoint is served by a Worker and the response has an auth block telling OpenCode how to authenticate, along with a config block with providers, MCP servers, agents, commands, and default permissions:
{
"auth": {
"command": ["cloudflared", "access", "login", "..."],
"env": "TOKEN"
},
"config": {
"provider": { "..." },
"mcp": { "..." },
"agent": { "..." },
"command": { "..." },
"permission": { "..." }
}
}
Step 2: Authenticate via Cloudflare Access. OpenCode runs the auth command and the user authenticates through the same SSO they use for everything else at Cloudflare. cloudflared returns a signed JWT. OpenCode stores it locally and automatically attaches it to every subsequent provider request.
Step 3: Config is merged into OpenCode. The config provided is shared defaults for the entire organization, but local configs always take priority. Users can override the default model, add their own agents, or adjust project and user scoped permissions without affecting anyone else.
Inside the proxy Worker. The Worker is a simple Hono app that does three things:
Serves the shared config. The config is compiled at deploy time from structured source files and contains placeholder values like {baseURL} for the Worker's origin. At request time, the Worker replaces these, so all provider requests route through the Worker rather than directly to model providers. Each provider gets a path prefix (/anthropic, /openai, /google-ai-studio/v1beta, /compat for Workers AI) that the Worker forwards to the corresponding AI Gateway route.
Proxies requests to AI Gateway. When OpenCode sends a request like POST /anthropic/v1/messages, the Worker validates the Cloudflare Access JWT, then rewrites headers before forwarding:
Stripped: authorization, cf-access-token, host
Added: cf-aig-authorization: Bearer <API_KEY>
cf-aig-metadata: {"userId": "<anonymous-uuid>"}
The request goes to AI Gateway, which routes it to the appropriate provider. The response passes straight through with zero buffering. The apiKey field in the client config is empty because the Worker injects the real key server-side. No API keys exist on user machines.
Keeps the model catalog fresh. An hourly cron trigger fetches the current OpenAI model list from models.dev, caches it in Workers KV, and injects store: false on every model for Zero Data Retention. New models get ZDR automatically without a config redeploy.
Anonymous user tracking. After JWT validation, the Worker maps the user's email to a UUID using D1 for persistent storage and KV as a read cache. AI Gateway only ever sees the anonymous UUID in cf-aig-metadata, never the email. This gives us per-user cost tracking and usage analytics without exposing identities to model providers or Gateway logs.
Config-as-code. Agents and commands are authored as markdown files with YAML frontmatter. A build script compiles them into a single JSON config validated against the OpenCode JSON schema. Every new session picks up the latest version automatically.
The overall architecture is simple and easy for anyone to deploy with our developer platform: a proxy Worker, Cloudflare Access, AI Gateway, and a client-accessible discovery endpoint that configures everything automatically. Users run one command and they're done. There’s nothing for them to configure manually, no API keys on laptops or MCP server connections to manually set up. Making changes to our agentic tools and updating what 3,000+ people get in their coding environment is just a wrangler deploy away.
The MCP Server Portal: one OAuth, multiple MCP tools
We described our full approach to governing MCP at enterprise scale in a separate post, including how we use MCP Server Portals, Cloudflare Access, and Code Mode together. Here's the short version of what we built internally.
image
Our internal portal aggregates 13 production MCP servers exposing 182+ tools across Backstage, GitLab, Jira, Sentry, Elasticsearch, Prometheus, Google Workspace, our internal Release Manager, and more. This unifies access and simplifies everything giving us one endpoint and one Cloudflare Access flow governing access to every tool.
Each MCP server is built on the same foundation: McpAgent from the Agents SDK, workers-oauth-provider for OAuth, and Cloudflare Access for identity. The whole thing lives in a single monorepo with shared auth infrastructure, Bazel builds, CI/CD pipelines, and catalog-info.yaml for Backstage registration. Adding a new server is mostly copying an existing one and changing the API it wraps. For more on how this works and the security architecture behind it, see our enterprise MCP reference architecture.
Code Mode at the portal layer
MCP is the right protocol for connecting AI agents to tools, but it has a practical problem: every tool definition consumes context window tokens before the model even starts working. As the number of MCP servers and tools grows, so does the token overhead, and at scale, this becomes a real cost. Code Mode is the emerging fix: instead of loading every tool schema up front, the model discovers and calls tools through code.
Our GitLab MCP server originally exposed 34 individual tools (get_merge_request, list_pipelines, get_file_content, and so on). Those 34 tool schemas consumed roughly 15,000 tokens of context window per request. On a 200K context window, that's 7.5% of the budget gone before asking a question. Multiplied across every request, every engineer, every day, it adds up.
MCP Server Portals now support Code Mode proxying, which lets us solve that problem centrally instead of one server at a time. Rather than exposing every upstream tool definition to the client, the portal collapses them into two portal-level tools: portal_codemode_search and portal_codemode_execute.
image
The nice thing about doing this at the portal layer is that it scales cleanly. Without Code Mode, every new MCP server adds more schema overhead to every request. With portal-level Code Mode, the client still only sees two tools even as we connect more servers behind the portal. That means less context bloat, lower token cost, and a cleaner architecture overall.
Act 2: The knowledge layer
Backstage: the knowledge graph underneath all of it
Before the iMARS team could build MCP servers that were actually useful, we needed to solve a more fundamental problem: structured data about our services and infrastructure. We need our agents to understand context outside the code base, like who owns what, how services depend on each other, where the documentation lives, and what databases a service talks to.
We run Backstage, the open-source internal developer portal originally built by Spotify, as our service catalog. It's self-hosted (not on Cloudflare products, for the record) and it tracks things like:
2,055 services, 167 libraries, and 122 packages
228 APIs with schema definitions
544 systems (products) across 45 domains
1,302 databases, 277 ClickHouse tables, 173 clusters
375 teams and 6,389 users with ownership mappings
Dependency graphs connecting services to the databases, Kafka topics, and cloud resources they rely on
Our Backstage MCP server (13 tools) is available through our MCP Portal, and an agent can look up who owns a service, check what it depends on, find related API specs, and pull Tech Insights scores, all without leaving the coding session.
Without this structured data, agents are working blind. They can read the code in front of them, but they can't see the system around it. The catalog turns individual repos into a connected map of the engineering organization.
AGENTS.md: getting thousands of repos ready for AI
Early in the rollout, we kept seeing the same failure mode: coding agents produced changes that looked plausible and were still wrong for the repo. Usually the problem was local context: the model didn't know the right test command, the team's current conventions, or which parts of the codebase were off-limits. That pushed us toward AGENTS.md: a short, structured file in each repo that tells coding agents how the codebase actually works and forces teams to make that context explicit.
What AGENTS.md looks like
We built a system that generates AGENTS.md files across our GitLab instance. Because these files sit directly in the model's context window, we wanted them to stay short and high-signal. A typical file looks like this:
# AGENTS.md
Repository
- Runtime: cloudflare workers
- Test command:
pnpm test - Lint command:
pnpm lint
How to navigate this codebase
- All cloudflare workers are in src/workers/, one file per worker
- MCP server definitions are in src/mcp/, each tool in a separate file
- Tests mirror source: src/foo.ts -> tests/foo.test.ts
Conventions
- Testing: use Vitest with
@cloudflare/vitest-pool-workers(Codex: RFC 021, RFC 042) - API patterns: Follow internal REST conventions (Codex: API-REST-01)
Boundaries
- Do not edit generated files in
gen/ - Do not introduce new background jobs without updating
config/
Dependencies
- Depends on: auth-service, config-service
- Depended on by: api-gateway, dashboard
When an agent reads this file, it doesn't have to infer the repo from scratch. It knows how the codebase is organized, which conventions to follow and which Engineering Codex rules apply.
How we generate them at scale
The generator pipeline pulls entity metadata from our Backstage service catalog (ownership, dependencies, system relationships), analyzes the repository structure to detect the language, build system, test framework, and directory layout, then maps the detected stack to relevant Engineering Codex standards. A capable model then generates the structured document, and the system opens a merge request so the owning team can review and refine it.
We've processed roughly 3,900 repositories this way. The first pass wasn't always perfect, especially for polyglot repos or unusual build setups, but even that baseline was much better than asking agents to infer everything from scratch.
The initial merge request solved the bootstrap problem, but keeping these files current mattered just as much. A stale AGENTS.md can be worse than no file at all. We closed that loop with the AI Code Reviewer, which can flag when repository changes suggest that AGENTS.md should be updated.
Act 3: The enforcement layer
The AI Code Reviewer
Every merge request at Cloudflare gets an AI code review. Integration is straightforward: teams add a single CI component to their pipeline, and from that point every MR is reviewed automatically.
We use GitLab's self-hosted solution as our CI/CD platform. The reviewer is implemented as a GitLab CI component that teams include in their pipeline. When an MR is opened or updated, the CI job runs OpenCode with a multi-agent review coordinator. The coordinator classifies the MR by risk tier (trivial, lite, or full) and delegates to specialized review agents: code quality, security, codex compliance, documentation, performance, and release impact. Each agent connects to the AI Gateway for model access, pulls Engineering Codex rules from a central repo, and reads the repository's AGENTS.md for codebase context. Results are
関連記事
「Built with Opus 4.6 Claude Code」ハッカソンの受賞者発表
Anthropicは「Built with Opus 4.6 Claude Code」ハッカソンの受賞チームを発表し、Claude CodeとOpus 4.6を活用した実装事例を紹介しました。
パーソナルAIのための「ヘッドレス化」の普及
マット・ウェブ氏は、パーソナルAIがGUI操作よりAPI経由のヘッドレスサービスと連携する方が高速で安定し、ユーザー体験も向上するため、今後ヘッドレス化が普及すると予測する。
Arcade.devツールがLangSmith Fleetに統合
LangSmith FleetはArcade.devと提携し、7,500以上のエージェント最適化ツールを単一の安全なゲートウェイを通じて提供する。