TUNDRA // NEXUS
LOC: SRV1304246| Mission ControlCode Mode: give agents an entire API in 1,000 tokens
š¢ READ | ā± 6 min | š” 8/10 | šÆ AI/DevOps engineers, AI agent developers
TL;DR
Cloudflare introduces Code Mode, a technique for giving AI agents access to entire API schemas using only ~1,000 tokens instead of 1.17 million. Models write executable code instead of specifying separate tools, with safe execution in sandboxed Workers isolates. An open-sourced MCP server provides access to Cloudflare's 2,500+ endpoints with fixed token cost.
Signal
- Code Mode reduces token consumption by 99.9% for the Cloudflare API (1,000 tokens vs 1.17M) by having models write executable code instead of specifying separate tools
- The implementation uses two tools (search/execute) that run JavaScript in a sandboxed Dynamic Worker isolate, eliminating the need for tool definitions for each endpoint
- Open-sourced Code Mode SDK available in Cloudflare Agents, enabling the same pattern for other MCP servers and APIs
What They're NOT Telling You
The approach requires clients to support JavaScript execution in sandboxes, which isn't universally available in all LLM environments yet. Long-term reliability and adoption patterns across different foundation models are still being evaluated, and progressive discovery through code may not provide optimal UX for non-technical workflows.
Trust Check
Factuality ā | Author Authority ā | Actionability ā