Deploy to Cloudflare Workers
TL;DR
# One-time: log innpx wrangler login
# Every deploymcify deploy cloudflareThe CLI bundles your config for the Workers runtime, generates
dist/cloudflare/wrangler.toml, then runs wrangler deploy. The
result is a worker at https://<your-name>.<account>.workers.dev/mcp.
Prerequisites
- A Cloudflare account.
- Either:
CLOUDFLARE_API_TOKENset in your shell, or- having run
npx wrangler loginonce.
--account-id <id>flag, orCLOUDFLARE_ACCOUNT_IDenv var, if your token doesn’t have it embedded.
Command
mcify deploy cloudflare [options]| Flag | Default | What it does |
|---|---|---|
--config <path> | ./mcify.config.ts | Path to your mcify config. |
--project-name <n> | config.name | Worker name (also the subdomain). |
--account-id <id> | from token | Cloudflare account id, only needed if the token doesn’t include it. |
--compatibility-date <d> | 2026-01-01 | Workers compatibility date. |
--dry-run | off | Generate wrangler.toml and the bundle, but skip wrangler deploy. |
What gets generated
dist/cloudflare/├── wrangler.toml # name, main, compatibility_date, nodejs_compat└── worker.js # bundled runtime + your configIf dist/cloudflare/wrangler.toml already exists, mcify does not
overwrite it — your edits (custom routes, KV bindings, secrets)
survive every redeploy.
Setting secrets
The runtime reads env vars at boot. On Workers those come from
wrangler secret:
npx wrangler secret put MCIFY_AUTH_TOKEN # the runtime's bearer tokennpx wrangler secret put KHIPU_API_KEY # whatever your tools needFor non-secret config you can put [vars] in wrangler.toml. Avoid
that for anything sensitive — use secret put.
Bundle size limits
Cloudflare Workers reject bundles larger than:
- 1 MB on the free tier.
- 10 MB on the paid plan.
mcify warns you before pushing if you cross 1 MB and errors out at 10 MB. If you hit it, options are:
- Move heavy deps into runtime imports the bundler can tree-shake.
- Switch to
mcify deploy flyorrailway— both run a real Node process with no size cap.
Custom routes
After your first deploy, edit wrangler.toml:
routes = [ { pattern = "mcp.example.com/*", zone_name = "example.com" }]Then mcify deploy cloudflare again. mcify won’t overwrite the file.
CI/CD
Drop-in workflow: .github/workflows-templates/deploy-cloudflare.yml
Required repo secrets:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_ID
Troubleshooting
Authentication error [code: 10000] — your CLOUDFLARE_API_TOKEN
is missing the right permissions. The token needs at least:
Account.Workers Scripts:Edit and Account.Workers Routes:Edit.
bundle is larger than 1 MB — see the bundle size section above.
Worker boots but /mcp returns 500 — check wrangler tail while
hitting the endpoint. Usually a missing secret (MCIFY_AUTH_TOKEN)
or a tool that imports a Node-only module (use nodejs_compat or
swap the dep).
Cold start feels slow — Workers cold start is ~1ms; if it feels slower it’s almost always your tool’s first outbound call (DNS, TLS to a third-party API).