WhoBuilt

MCP = Mega Context Problem

Apr 25, 2026· 23 min· 23K views·Watch on YouTube

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.

API tools outgrow the context window

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.

Three paths to progressive discovery

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.

Run generated code with guardrails

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.

Prepare APIs and clients for code

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.

Make MCP available in frameworks

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

Show all 10 facts

Related talks