← Back
Cloudflare
Cloudflare releases @cloudflare/codemode v0.2.1 with MCP barrel export and zero-dependency main entry point
Cloudflare WorkersCloudflare · releasesdkapibreaking-changefeature · developers.cloudflare.com ↗

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 typed codemode.* methods that LLMs can call from generated code
  • openApiMcpServer() — creates search and execute MCP tools directly from OpenAPI specifications, with host-side request proxying and automatic $ref resolution

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:

  • sanitizeToolName and normalizeCode
  • generateTypesFromJsonSchema and jsonSchemaToType
  • DynamicWorkerExecutor for sandboxed execution
  • ToolDispatcher for 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 generateTypes and type imports to @cloudflare/codemode/ai
  • If using MCP servers, explore the new @cloudflare/codemode/mcp export for simplified integration
  • Consider leveraging the new modules option to provide utilities to sandboxed code
  • Upgrade via npm i @cloudflare/codemode@latest and review the updated Code Mode documentation