# Cloudflare (/docs/deployment/cloudflare)

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`):

```bash
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):

```bash
pnpm build
# or
xmcp build --cf
```

Then deploy with Wrangler:

```bash
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:

```bash
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](https://developers.cloudflare.com/workers/).
