Cloudflare releases codemode v0.2.1 with MCP support and zero-dependency core
New MCP Integration
The latest release introduces a dedicated @cloudflare/codemode/mcp export that provides two MCP server wrappers:
codeMcpServer()wraps existing MCP servers and exposes all upstream tools as typedcodemode.*methods accessible to generated codeopenApiMcpServer()auto-generatessearchandexecutetools from OpenAPI specs with built-in request proxying and$refresolution
This makes it easier to integrate Code Mode with MCP-based tool ecosystems and gives LLMs first-class typed access to external APIs.
Dependency Reduction & Reorganization
A breaking change in v0.2.0 reorganizes the package to reduce unnecessary dependencies:
generateTypesandToolDescriptortypes now live in@cloudflare/codemode/ai(previously main entry point)- The main
@cloudflare/codemodeexport no longer requiresaiorzodas peer dependencies - Core utilities like
normalizeCode(),sanitizeToolName(), andDynamicWorkerExecutorremain dependency-free
The main entry point now exports six core functions and classes focused on code execution and type generation without requiring optional AI/validation libraries.
Sandbox Enhancement & Internal Improvements
DynamicWorkerExecutor gains two significant improvements:
- Custom modules: Pass a
modulesobject to inject custom ES modules into the sandbox, enabling generated code to import utility functions or polyfills - Automatic normalization: The executor now handles code normalization and tool name sanitization internally—no need to call these utilities separately
Migration Guide
Update your imports if using generateTypes:
// Old
import { generateTypes } from "@cloudflare/codemode";
// New
import { generateTypes } from "@cloudflare/codemode/ai";
Upgrade with npm i @cloudflare/codemode@latest and review the Code Mode documentation for complete API details.