Code Mode: give agents an API in 1k tokens
a day ago
- #AI Agents
- #Code Mode
- #Cloudflare API
- Model Context Protocol (MCP) is the standard for AI agents to use external tools, but adding tools consumes context window space.
- Code Mode reduces context window usage by letting models write code against a typed SDK, executed safely in a Dynamic Worker Loader.
- Cloudflare introduces a new MCP server for its entire API, using Code Mode with just two tools: search() and execute(), consuming only ~1,000 tokens.
- Code Mode reduces input tokens by 99.9% compared to traditional MCP, which would use over 1.17 million tokens for Cloudflare's API.
- The Cloudflare MCP server is open-sourced, allowing developers to use Code Mode in their own MCP servers and AI agents.
- Example use case: An agent protecting an origin from DDoS attacks uses search() and execute() to interact with Cloudflare's API efficiently.
- Cloudflare MCP Server Portals will allow composing multiple MCP servers behind a single gateway with unified auth and access control.