New MCP Integration
The v0.2.1 release introduces a new @cloudflare/codemode/mcp export that provides two functions for integrating MCP (Model Context Protocol) servers with Code Mode:
codeMcpServer()— wraps existing MCP servers, exposing all upstream tools as typedcodemode.*methods that LLMs can call from generated codeopenApiMcpServer()— creates searchable MCP tools from OpenAPI specifications, with automatic$refresolution and host-side request proxying
Breaking Change: Restructured Exports
Version 0.2.0 moved the following to @cloudflare/codemode/ai:
generateTypesToolDescriptor/ToolDescriptorstypes
The main entry point (@cloudflare/codemode) is now zero-dependency, exporting only core utilities: sanitizeToolName, normalizeCode, generateTypesFromJsonSchema, jsonSchemaToType, DynamicWorkerExecutor, and ToolDispatcher. The ai and zod peer dependencies are now optional.
Sandbox Enhancements
DynamicWorkerExecutor now accepts an optional modules configuration to inject custom ES modules directly into the sandbox. This allows generated code to import utility functions without network calls or external dependencies.
Additionally, DynamicWorkerExecutor now handles code normalization and tool name sanitization internally, eliminating the need for developers to manually call these functions before execution.
Action Items
- Update imports: move
generateTypesand type definitions from@cloudflare/codemodeto@cloudflare/codemode/ai - Remove any manual calls to
normalizeCode()andsanitizeToolName()— these are now handled automatically - Upgrade via
npm i @cloudflare/codemode@latest