Building an Enterprise AI Engineering Stack with Internal Agents and MCP Infrastructure
cloudflare · Tech · 2026 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.4 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: Enterprise AI engineering infrastructure
Cloudflare needed to make AI coding tools usable and governable across R&D by centralizing authentication, model routing, MCP tool access, repository context, code review, and future cloud agents on its own platform.
Constraints:
- Thousands of engineers needed access without local API keys or manual MCP setup.
- The stack needed per-user attribution, cost tracking, retention controls, and zero-trust authentication.
- Coding agents needed repository-specific context to avoid plausible but wrong changes.
- Security-sensitive reviews needed stronger models while lighter tasks could use cheaper same-network inference.
Architecture
Cloudflare built an internal AI engineering stack using Cloudflare Access, a proxy Worker, AI Gateway, Workers AI, MCP portals, AGENTS.md files, and an AI Code Reviewer. Requests authenticate through Access, route through a Worker that injects provider keys server-side and forwards to AI Gateway, while MCP servers expose internal tools through a unified portal. AGENTS.md files give coding agents repo-specific context, and a GitLab CI review coordinator delegates to specialized review agents.
Diagram confidence: explicit (topology described by the source).
flowchart LR developer[Developer] --> opencode-client[OpenCode Client] opencode-client --> proxy-worker[Proxy Worker] cloudflare-access[Cloudflare Access] --> proxy-worker[Proxy Worker] proxy-worker --> ai-gateway[AI Gateway] ai-gateway --> workers-ai[Workers AI] cloudflare-access --> mcp-portal[MCP Portal] mcp-portal --> mcp-servers[MCP Servers] agents-md-context[AGENTS.md Context] --> ai-code-reviewer[AI Code Reviewer] mcp-servers --> ai-code-reviewer[AI Code Reviewer] ai-code-reviewer --> ai-gateway[AI Gateway]
Components
| Component | Role | Interacts with |
|---|---|---|
Developer |
Cloudflare engineer using AI coding tools. | OpenCode Client |
OpenCode Client |
Local coding assistant client configured by discovery endpoint. | Proxy Worker |
Proxy Worker |
Central control plane for auth, config, provider routing, attribution, and permission enforcement. | Cloudflare Access, AI Gateway |
Cloudflare Access |
Zero-trust authentication and policy enforcement. | Proxy Worker, MCP Portal |
AI Gateway |
Model routing, provider keys, analytics, cost tracking, and retention policy. | Proxy Worker, Workers AI |
Workers AI |
Same-network open-source inference for lower-cost internal workloads. | AI Gateway |
MCP Portal |
Unified access to production MCP servers and internal tools. | Cloudflare Access, MCP Servers |
MCP Servers |
13 production MCP servers exposing internal tools. | MCP Portal, AI Code Reviewer |
AGENTS.md Context |
Repository-specific high-signal instructions for coding agents. | AI Code Reviewer |
AI Code Reviewer |
GitLab CI multi-agent reviewer for quality, security, docs, performance, release impact, and Codex rules. | AI Gateway, AGENTS.md Context, MCP Servers |
Data flow
Developers authenticate with Cloudflare Access. OpenCode sends model requests to a proxy Worker, which validates JWTs, anonymizes user attribution, injects provider credentials, and routes through AI Gateway. Agents use MCP servers and repository AGENTS.md context; merge requests trigger a multi-agent reviewer that posts structured comments.
POST /anthropic/v1/messages, the Worker validates the Cloudflare Access JWT”article, statedWhy this architecture
Cloudflare chose a single proxy Worker and AI Gateway from day one because centralized routing created a control plane for attribution, model catalog management, permission enforcement, and no local API keys. AGENTS.md and MCP portals give agents codebase and tool context, while AI Gateway lets Cloudflare mix frontier models with Workers AI by task.
apiKey field in the client config is empty because the Worker injects the real key server-side. No API keys exist on user machines.”article, statedModels used: Kimi K2.5 · Opus 4.6 · GPT 5.4 · Workers AI open-source models · frontier models
Scale
- 93% of Cloudflare R&D used the AI coding tools in the last 30 days.“
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.”article, stated - 3,683 internal users generated 47.95 million AI requests.“* 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.”article, stated“* 47.95 million AI requests * 295 teams are currently utilizing agentic AI tools and coding assistants. * 20.18 million AI Gateway requests per month”article, stated
- 241.37 billion tokens routed through AI Gateway in the last 30 days.“* 20.18 million AI Gateway requests per month * 241.37 billion tokens routed through AI Gateway * 51.83 billion tokens processed on Workers AI”article, stated
- The MCP portal aggregates 13 production MCP servers with 182-plus tools.“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.”article, stated
- AGENTS.md files were processed for roughly 3,900 repositories.“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.”article, stated
Alternatives considered (roads not taken)
Clients connect directly to AI Gateway.
Rejected because: Direct connection would not provide the later control-plane features.
Agents infer repo instructions from code alone.
Rejected because: They produced plausible but wrong changes without test commands and conventions.
Use frontier models for all workloads.
Rejected because: Workers AI handles cheaper documentation and lightweight tasks where same-network latency matters.
Patterns
model-routing (platform)
AI Gateway routes requests across frontier providers and Workers AI with cost and retention controls.
tool-use-orchestration (mcp)
MCP portals unify 13 production MCP servers and 182-plus tools under one endpoint.
agent-memory (codebase-context)
AGENTS.md provides short, high-signal repository context inside the model window.
Tradeoffs
Control plane
Chose Proxy Worker plus AI Gateway over Direct client-to-provider or direct Gateway setup.
Rationale: The proxy enabled attribution, permissions, model catalog, server-side keys, and future tool expansion.
Model economics
Chose Workers AI for some tasks and frontier models for complex reviews over One model tier everywhere.
Rationale: Capability, cost, and latency differ by workload.
Gotchas (what bit them)
Direct model access is easy but hard to govern later.
Root cause: Clients would own config, attribution, keys, and provider details.
Resolution: Centralize through a proxy Worker and AI Gateway.
Stale agent context can be worse than no context.
Root cause: Repository instructions drift when tests, conventions, or boundaries change.
Resolution: Use AI Code Reviewer to flag AGENTS.md updates when repo changes suggest drift.
Evaluation
Cloudflare measures adoption, requests, token routing, merge-request velocity, reviewer traffic mix, and repository readiness through AGENTS.md coverage.
Metrics: R&D adoption · Internal users · AI requests · Tokens routed · Merge requests · MCP tools · AGENTS.md repositories
Outcomes
- 93% of R&D used the AI coding tools.
- AI Gateway routed 241.37B tokens in 30 days.
- Cloudflare created 13 MCP servers, 182-plus tools, and AGENTS.md context for roughly 3,900 repositories.
The source reports 3,683 internal users, 47.95M AI requests, 241.37B AI Gateway tokens, 51.83B Workers AI tokens, 13 MCP servers, 182+ tools, and ~3,900 repositories.