Choosing Between FastMCP and EdgeFastMCP
Feature Comparison
Built-in authentication for EdgeFastMCP is planned for a future release. Both FastMCP and EdgeFastMCP use Hono internally, so there’s no technical barrier—EdgeFastMCP was simply written before OAuth was added to FastMCP.In the meantime, use Hono middleware:
Quick Start
1. Install Dependencies
2. Create Your Server
src/index.ts
3. Configure Wrangler
wrangler.toml
4. Deploy
Edge Runtime Differences
When running on edge runtimes:1
Stateless by Default
Each request is handled independently. Use external storage (KV, D1, R2) for persistence.
2
No Filesystem Access
Use fetch APIs for external data instead of reading files.
3
V8 Isolates
Fast cold starts and efficient resource usage. Your code runs in isolated V8 contexts.
4
Global Deployment
Automatic distribution to edge locations worldwide for minimal latency.
Complete Example
Here’s a complete example from the FastMCP repository:src/examples/edge-cloudflare-worker.ts
Custom Routes on Edge
You can access the underlying Hono app to add custom HTTP routes:Using Cloudflare Bindings
Access Cloudflare Workers bindings (KV, D1, R2) in your tools:- KV Storage
- D1 Database
- R2 Storage
Local Development
Test your edge server locally with Wrangler:Deployment Best Practices
1
Use Environment Variables
Store secrets in Wrangler secrets, not in code:Access in your code:
2
Enable Caching
Use Cache API for expensive operations:
3
Monitor Performance
Use Cloudflare Analytics to monitor:
- Request rates
- CPU time
- Response times
- Error rates
4
Set Resource Limits
Configure limits in
wrangler.toml:Limitations
Next Steps
Custom Routes
Learn how to add custom HTTP routes to your edge server
Streaming
Implement streaming responses in your tools