EdgeFastMCP vs FastMCP
Cloudflare Workers requires the edge-compatibleEdgeFastMCP class:
EdgeFastMCP is optimized for stateless edge environments with no filesystem access. Use
fetch APIs for external data.Step-by-Step Deployment
1
Install Dependencies
Install FastMCP and Zod in your Cloudflare Workers project:
2
Create Your MCP Server
Create
src/index.ts with the EdgeFastMCP import:src/index.ts
The
export default server statement is required for Cloudflare Workers to recognize your handler.3
Configure wrangler.toml
Create a
wrangler.toml configuration file:wrangler.toml
4
Deploy to Cloudflare
Deploy your MCP server with a single command:Your server will be available at:
- MCP endpoint:
https://my-mcp-server.workers.dev/mcp - Health check:
https://my-mcp-server.workers.dev/health
Complete Example
Here’s a full example based onsrc/examples/edge-cloudflare-worker.ts:
src/index.ts
Adding Custom Routes
Access the underlying Hono app to add custom HTTP endpoints:Environment Variables and Secrets
1
Add Environment Variables
Define variables in
wrangler.toml:2
Add Secrets
Use wrangler CLI for sensitive data:
3
Access in Code
TypeScript doesn’t have direct access to
env in EdgeFastMCP. Use Hono middleware:Edge Runtime Limitations
When running on Cloudflare Workers, be aware of these constraints:- No filesystem access: Use KV, R2, or fetch APIs instead
- Stateless by default: Each request is handled independently
- V8 isolates: Limited to JavaScript/TypeScript runtime
- CPU time limits: Maximum 50ms CPU time on free tier, 30s on paid
- Memory limits: 128MB per request
- No long-running connections: Use Durable Objects for websockets
For session state, consider using Cloudflare KV or Durable Objects.
Testing Locally
Test your worker locally before deploying:Monitoring and Logs
View logs and analytics in the Cloudflare dashboard:Next Steps
- Serverless Deployments - Deploy to AWS Lambda, Google Cloud Functions
- Production Checklist - Security and monitoring best practices
- Custom Routes - Learn more about Hono routing