Code Mode: turning MCP tools into TypeScript APIs cut agent context from 150k to 2k tokens

blaizedsouza · x · 2026-12-01

Cloudflare's Code Mode approach converts MCP tools into a TypeScript API and has the LLM write code to call them, executed in a sandbox with results filtered before reaching the model. Context drops from 150,000 to 2,000 tokens on the first turn (98.7% less), agents handle far more and more complex tools, and multi-step chains no longer waste tokens relaying intermediate outputs. Includes a 7-rule playbook: tools → files → execution → filter → response.

Original post →

More from coding & agent

coding & agent channel →