Deployment

Cloudflare

Deploy your app to Cloudflare Workers and verify the /mcp endpoint.

When you finish this guide, your app serves Streamable HTTP at https://your-worker.workers.dev/mcp (or your custom domain).

Complete the production checklist first.

Prerequisites

  1. Create a Cloudflare account
  2. Install Wrangler: npm i -g wrangler
  3. Log in: wrangler login

Prepare the app for Cloudflare

npx bitmcp create my-app
cd my-app
pnpm install

Add deploy: "cloudflare" to bitmcp.config.ts and add wrangler.jsonc with main set to dist/server.js and nodejs_compat enabled.

Configure bitmcp.config.ts

bitmcp.config.ts
import { defineConfig } from "bitmcp";

export default defineConfig({
  deploy: "cloudflare",
  http: {
    path: "/mcp",
    allowedHosts: ["your-worker.workers.dev"],
  },
});

Use your workers.dev subdomain or custom domain in allowedHosts. When OAuth is enabled, set MCP_URL to your public MCP endpoint. See Authentication.

Set secrets

Generate a production state key:

openssl rand -hex 32

Store it as a Worker secret:

wrangler secret put BITMCP_STATE_KEY

Paste the generated value when prompted. Set MCP_URL with wrangler secret put MCP_URL when OAuth is enabled.

nodejs_compat is required. The scaffold sets it in wrangler.jsonc under compatibility_flags.

Deploy

wrangler deploy

Wrangler runs pnpm build and serves dist/server.js directly.

Verify

curl https://your-worker.workers.dev/health

Expect { "ok": true }. Connect an MCP client to https://your-worker.workers.dev/mcp and call a tool.

Troubleshooting

  • Worker fails to start — Confirm wrangler.jsonc includes "compatibility_flags": ["nodejs_compat"].
  • MRTR or confirmation errors — Run wrangler secret put BITMCP_STATE_KEY and redeploy.
  • Host rejected — Add your workers.dev hostname or custom domain to http.allowedHosts.
  • OAuth metadata wrong — Set MCP_URL to the same public URL clients use to reach /mcp.

Reference

bitmcp build emits dist/server.js, hashed View HTML under dist/ui/, and dist/manifest.json. See Project structure for the full output map.

wrangler.jsonc
{
  "name": "my-app",
  "main": "dist/server.js",
  "compatibility_flags": ["nodejs_compat"],
}