Home / Companies / Cloudflare / Blog / Post Details
Content Deep Dive

Code Mode: give agents an entire API in 1,000 tokens

Blog post from Cloudflare

Post Details
Company
Date Published
Author
Matt Carey
Word Count
374
Company Posts That Month
13
Language
English
Hacker News Points
-
Post removed?
No
Summary

Model Context Protocol (MCP) has emerged as a standard for AI agents to utilize external tools, but it faces a challenge where adding more tools limits the space available for tasks in the model's context window. Addressing this issue, Code Mode allows models to write and execute code using a typed SDK, thereby creating a compact plan for tool operations and reducing context window usage. This technique, also explored by Anthropic, has been applied to a new MCP server for the Cloudflare API, which consolidates the API's extensive operations into just two tools: search() and execute(). By using Code Mode, this server significantly reduces token usage by 99.9%, maintaining a fixed footprint regardless of the number of API endpoints. This efficiency is achieved by minimizing the input tokens to around 1,000, compared to over a million tokens without Code Mode. The approach is being open-sourced in the Cloudflare Agents SDK, enabling broader application in other MCP servers and AI agents.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
MCP 10 3,346 363 139 +19%
AI Agents 2 3,583 743 199 -1%
Zero Trust 1 70 30 22 +13%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.