New MCP Barrel Export
The release introduces a new @cloudflare/codemode/mcp entry point that provides two key functions for integrating with Model Context Protocol servers:
codeMcpServer()— wraps existing MCP servers by converting all upstream tools into typedcodemode.*methods that LLMs can call from generated codeopenApiMcpServer()— createssearchandexecuteMCP tools directly from OpenAPI specifications, with host-side request proxying and automatic$refresolution
This enables seamless integration between Code Mode and MCP-based tool systems, allowing agents to leverage existing MCP infrastructure.
Breaking Changes and Dependency Restructuring
v0.2.0 introduced a breaking change: generateTypes and the ToolDescriptor/ToolDescriptors types have moved from the main entry point to @cloudflare/codemode/ai. Import paths need to be updated accordingly.
The main @cloudflare/codemode entry point is now zero-dependency, with ai and zod becoming optional peer dependencies. The main export now provides only core utilities:
sanitizeToolNameandnormalizeCodegenerateTypesFromJsonSchemaandjsonSchemaToTypeDynamicWorkerExecutorfor sandboxed executionToolDispatcherfor RPC-based tool dispatching
Enhanced Sandbox Control
Developers can now inject custom ES modules into the execution sandbox via the modules option on DynamicWorkerExecutor. This allows sandbox code to import utilities and helpers without network access or external dependencies.
Additionally, DynamicWorkerExecutor now handles code normalization and tool name sanitization internally, eliminating the need for manual preprocessing before execution.
Action Items
- Update import paths: move
generateTypesand type imports to@cloudflare/codemode/ai - If using MCP servers, explore the new
@cloudflare/codemode/mcpexport for simplified integration - Consider leveraging the new
modulesoption to provide utilities to sandboxed code - Upgrade via
npm i @cloudflare/codemode@latestand review the updated Code Mode documentation