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
- Create a Cloudflare account
- Install Wrangler:
npm i -g wrangler - Log in:
wrangler login
Prepare the app for Cloudflare
npx bitmcp create my-app
cd my-app
pnpm installAdd 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
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 32Store it as a Worker secret:
wrangler secret put BITMCP_STATE_KEYPaste 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 deployWrangler runs pnpm build and serves dist/server.js directly.
Verify
curl https://your-worker.workers.dev/healthExpect { "ok": true }. Connect an MCP client to https://your-worker.workers.dev/mcp and call a tool.
Troubleshooting
- Worker fails to start — Confirm
wrangler.jsoncincludes"compatibility_flags": ["nodejs_compat"]. - MRTR or confirmation errors — Run
wrangler secret put BITMCP_STATE_KEYand redeploy. - Host rejected — Add your
workers.devhostname or custom domain tohttp.allowedHosts. - OAuth metadata wrong — Set
MCP_URLto 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.
{
"name": "my-app",
"main": "dist/server.js",
"compatibility_flags": ["nodejs_compat"],
}