Cloudflare

Cloudflare Workers support in xmcp uses a Cloudflare-native bundle and Wrangler for local dev and deploy.

For the complete documentation index, see llms.txt. Markdown variants of every page are available by appending .md to the URL.

Cloudflare Workers support is built into xmcp with the --cf flag. The easiest path is to bootstrap a project that includes Wrangler and the Cloudflare build pipeline.

Keep @xmcp-dev/compiler installed as a development dependency in the build environment. It is only needed to produce the Worker bundle and is not part of the deployed runtime.

Create a new project

Start with create-xmcp-app and the Cloudflare flag (you can also pass --cloudflare when cloning an example with --example):

Code
npx create-xmcp-app@latest my-xmcp-app --cloudflare

This initializes a Workers-ready setup and wires the following defaults:

  • xmcp build --cf for production builds
  • xmcp dev --cf alongside wrangler dev for local development
  • wrangler deploy for deployment

Build and deploy with the CLI

Build a Cloudflare Workers bundle and emit worker.js (plus wrangler.jsonc if you don’t already have a Wrangler config):

Code
pnpm build
# or
xmcp build --cf

Then deploy with Wrangler:

Code
pnpm deploy
# or
npx wrangler deploy

The first deploy prompts you to log in to your Cloudflare account. Once deployed, the Worker serves your configured endpoint, /mcp by default, on your workers.dev subdomain, along with a /health check route.

Local development

Run the watcher and Wrangler together:

Code
pnpm dev

This runs xmcp dev --cf (to rebuild the Worker output) and wrangler dev to serve it locally.

Learn more about deploying Workers in the Cloudflare Workers documentation.