Deploying to Cloudflare Workers
This guide covers deploying a Model Context Protocol server on Cloudflare Workers using the streamable-http transport. This deployment model is advanced difficulty.
Prerequisites
- Cloudflare account
- Wrangler CLI
- OAuth 2.0 credentials or an API key for the server
Deployment Steps
- Prepare your server build. Ensure your MCP server builds cleanly:
npm run build - Write the configuration.
# Deploy to Cloudflare Workers # See full guide for platform-specific commands - Set environment variables. Never bake secrets into container images or deployment configs. Use the platform's secret management system.
- Deploy and verify. After deployment, test the Streamable HTTP endpoint responds with a valid MCP response.
- Configure your client. Add the deployed server URL to your client configuration.
Production Security Checklist
- Serve over HTTPS only — never expose MCP servers on plain HTTP.
- Enforce authentication on every endpoint — no unauthenticated access.
- Set
NODE_ENV=productionto disable debug output. - Apply network egress rules to limit what the server can reach.
- Enable request logging and ship logs to a central SIEM.