Carey traces the shift from tools bundled into individual agents to shared MCP servers. Giving an agent every API endpoint can overwhelm its context: Cloudflare’s OpenAPI spec was 2.3 million tokens, or about 1.1 million when converted into tools. Splitting the API into 16 product servers reduced the load but left gaps in coverage across roughly 2,500 endpoints.
MCP = Mega Context Problem
Speaker
Matt Carey, who works on MCP and agents at Cloudflare, explains how to give agents access to large APIs without overwhelming their context, at an AI Engineer talk.
Carey argues agents need to discover tools as they need them, instead of loading everything at once. A CLI lets an agent inspect commands and parameters, but requires shell access. Tool search can load relevant tools on demand, while Cloudflare’s Code Mode lets a model write code against types generated from the API spec.
Carey says agents had not widely adopted Code Mode partly because running untrusted code can expose secrets, access files, or consume resources. Cloudflare runs generated code in isolated Workers and can restrict network access, including allowing requests only to selected domains. In a demo, an agent listed workers with read-only access to the Cloudflare API.
Carey expects code generation to become a compact way for agents to combine API actions, supported by isolated execution environments such as WorkerD, Deno, and Pydantic Monty. He says services will need rate limits to handle scripts that make many requests. On the client side, he anticipates programmatic tool calling, reusable scripts, more MCP clients, and stateless agent loops.
Carey predicts MCP will become lightweight middleware built into major TypeScript frameworks. He describes a future where developers can expose APIs over MCP with a setting, potentially including a thousand APIs in one Next.js app. He says the remaining work is making the SDK small enough to fit into framework bundles.
Takeaways
- Expose tools progressively so large APIs do not overwhelm an agent’s context window.
- Generate concise types from the API spec so agents can write code against the service.
- If you run agent-generated code, isolate it and set explicit limits on secrets and network access.
- Add rate limits and resource controls because generated scripts can make many API calls.
- Consider making MCP a framework-level option so existing APIs are easier to expose to agents.
Mentioned in this talk
Search inside this talk
What was claimed 10
- works atMatt Carey works at
Cloudflare
“We work on agents at Cloudflare.”
0:15inWhy Eval++ Is the Next Great Compute PrimitiveYouTube Verified3 sources· Talk, Web· archived
- built
Cloudflare built Code Mode
“Cloudflare published [a] blog post last summer. Instead of doing a static search tool ... how can we let the agent write code against our API?”
YouTube Verified2 sources· Talk, Web· archived
- metricOpenAPI: Cloudflare's spec: 2.3 million tokens
“The OpenAPI spec is 2.3 million tokens.”
YouTube Unverified1 source· Talk
- uses
Cloudflare uses OpenAPI
“The OpenAPI spec is 2.3 million tokens.”
YouTube Unverified1 source· Talk
- metric
Cloudflare: About 2,600 API endpoints
“I think we're actually at about 2,600 API endpoints now.”
YouTube Unverified1 source· Talk
- featureMCP: Can expose APIs as tools without loading all tools into context at once.
“These can be exposed over MCP. We just shouldn't be dumping loads of tools into context.”
YouTube Unverified1 source· Talk
- uses
“You can generate it from OpenAPI specs.”
YouTube Unverified1 source· Talk
- feature
Cloudflare Workers: Runs generated code in an isolated, programmable environment with configurable access guardrails.
“A worker is a little isolate in V8.”
YouTube Unverified1 source· Talk










