← Back
Cloudflare
Cloudflare releases codemode v0.2.1 with MCP support and zero-dependency core
Cloudflare WorkersCloudflare · releasefeatureapibreaking-changesdk · developers.cloudflare.com ↗

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 typed codemode.* methods accessible to generated code
  • openApiMcpServer() auto-generates search and execute tools from OpenAPI specs with built-in request proxying and $ref resolution

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:

  • generateTypes and ToolDescriptor types now live in @cloudflare/codemode/ai (previously main entry point)
  • The main @cloudflare/codemode export no longer requires ai or zod as peer dependencies
  • Core utilities like normalizeCode(), sanitizeToolName(), and DynamicWorkerExecutor remain 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 modules object 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.