Overview
Deploy your MCP server to the cloud for remote access via HTTP/SSE transport. This enables:- Access from anywhere (not just localhost)
- Integration with web applications
- Multi-user support
- Always-available analytics
Deployment Options
Fly.io (Recommended)
Why Fly.io:- Built-in MCP support (
fly mcp wrap) - Automatic HTTPS
- Global edge network
- Free tier available
- Install flyctl
- Wrap your MCP server
- Deploy
- Get your endpoint
Other Platforms
Railway, Render, Heroku:- Use HTTP/SSE transport
- Expose port 8080
- Set environment variables
- Enable HTTPS
Transport: SSE vs STDIO
STDIO (Local Only)
Pros:- ✅ Fast, low latency
- ✅ Simple setup
- ❌ Only works on localhost
- ❌ Can’t be accessed remotely
SSE (Remote-Ready)
Pros:- ✅ Works over HTTP/HTTPS
- ✅ Accessible from anywhere
- ✅ Web-compatible
- ⚠️ Slightly higher latency
- ⚠️ May have cold starts
- Deploying to cloud platforms
- Building web applications
- Multi-user scenarios
- Remote access needed
Authentication
API Key via Headers
In Surfa Platform
The platform automatically handles authentication when you add your MCP with headers:Cold Start Handling
Remote MCPs may “sleep” after inactivity. The Surfa platform handles this automatically:
Total wait time: Up to 27 seconds for cold starts.
To avoid cold starts:
- Keep machines always-on (costs more)
- Use health check pings
- Accept the retry delay
Testing Your Deployment
1. Test with curl
2. Test in Surfa Platform
Configure
- Name: “My Remote MCP”
- Transport: SSE
- Endpoint:
https://your-mcp.fly.dev/sse - Headers:
{"Authorization": "Bearer sk_live_your_key"}
CORS Configuration
If accessing from web apps, enable CORS:Security Best Practices
Always use HTTPS
Always use HTTPS
Never expose API keys over HTTP. Use HTTPS in production.
Validate API keys
Validate API keys
Check API keys on every request. Reject invalid keys immediately.
Rate limit
Rate limit
Prevent abuse by limiting requests per IP or API key.
Log access
Log access
Track all API requests for auditing and debugging.
Rotate keys
Rotate keys
Regularly rotate API keys and revoke old ones.
Troubleshooting
502 Bad Gateway
502 Bad Gateway
Cause: Machine is starting (cold start)Solution:
- Wait for retry logic to complete
- Check Fly.io logs:
fly logs - Verify machine is running:
fly status
401 Unauthorized
401 Unauthorized
Timeout
Timeout
Cause: Server not responding after 27 secondsSolution:
- Increase timeout in Surfa platform
- Check machine is running:
fly status - Configure always-on if needed
Tools not discovered
Tools not discovered
Cause: MCP server not returning toolsSolution:
- Verify
/sseendpoint is correct - Check
initializerequest works - Test
tools/listmanually with curl - Review server logs for errors
Next Steps
Test Connection
Learn how to test your MCP connection
Claude Desktop Setup
Connect Claude Desktop to your remote MCP
API Reference
Complete API documentation
GitHub Repository
View source and contribute