Self-Hosted MCP Server Cost Math: EC2 vs Fly.io vs Cloudflare Workers for Coding Agents (2026)
By Eric Bush · July 3, 2026 · 9 min read
Why Self-Hosted MCP Servers Are Becoming the Default
Model Context Protocol servers used to be a curiosity. In 2026 they are the standard way to give Claude Code, Cursor, and Codex access to internal tools — databases, ticketing systems, custom search, deployment pipelines. Many teams start by installing community MCP servers on their laptops, but as soon as more than one developer needs the same tool, self-hosting on a shared endpoint becomes obvious.
The question then is where to host. The three most common answers for coding teams are EC2, Fly.io, and Cloudflare Workers — and they have very different cost profiles.
Sizing an MCP Server for a 20-Developer Team
Realistic load pattern for a mid-sized team's shared MCP server:
- 20 developers, each running 50–100 tool calls per day.
- Peak concurrent load: 3–5 requests/second during working hours.
- Average request duration: 200–800ms (database queries, file reads, ticket lookups).
- Data transfer: 10–50MB per developer per day.
- Uptime requirement: 99.5% during working hours.
That translates to roughly 2,000 requests/day, peaking around 10 requests/second. Any of the three platforms can handle this — the question is what it costs.
AWS EC2 Cost Breakdown
A single t3.small (2 vCPU, 2GB RAM) is more than enough for this workload. Cost breakdown:
- t3.small instance: $16/month on-demand, $10/month on 1-year reserved.
- 20GB EBS gp3 storage: $2/month.
- Data transfer out (public egress): $1–$3/month at 30MB/day.
- Optional ALB or CloudFront: $18–$25/month.
- Total: $30–$50/month.
EC2 is the reliable, predictable option — but you also pay for engineer time on OS updates, security patching, and provisioning.
Fly.io Cost Breakdown
Fly.io deploys containers to their global edge network. For an MCP server:
- 1x shared-cpu-1x machine (256MB RAM): $2.60/month if always-on.
- Scale-to-zero: $0.50–$1.20/month depending on request pattern.
- Bandwidth: 100GB free, then $0.02/GB. For this workload: $0.
- Persistent volume (optional): $0.15/GB/month.
- Total: $3–$7/month.
Fly.io is dramatically cheaper for this size of workload — with the trade-off of a smaller ecosystem and less mature enterprise tooling than AWS.
Cloudflare Workers Cost Breakdown
Workers is a serverless edge platform. For an MCP server:
- Workers Paid plan: $5/month base, includes 10M requests.
- Additional CPU time: $0.02/million CPU ms. For 2,000 requests/day at 500ms average: $6/month.
- KV or R2 storage: $0.50–$5/month depending on data.
- Durable Objects for stateful MCP tools: additional $0.15/GB-month and per-second charge.
- Total: $5–$18/month.
Workers is competitive on cost and unbeatable on cold-start latency (usually under 10ms). The catch: Workers has runtime limitations — no long-running processes, limited CPU time per request, restricted native modules. Not every MCP server ports cleanly.
Side-by-Side Comparison
| Platform | Monthly cost | Cold start latency | Ops complexity |
|---|---|---|---|
| AWS EC2 (t3.small) | $30–$50 | 0ms (always on) | Medium (patching, monitoring) |
| Fly.io | $3–$7 | 0–500ms | Low (managed containers) |
| Cloudflare Workers | $5–$18 | Under 10ms | Low (serverless) |
Beyond Pure Cost: What to Actually Pick
For a shared MCP server serving 20 developers, all three platforms are affordable. The decision depends on other factors:
- Existing infrastructure. If you already run everything on AWS, the operational overhead of adding an EC2 instance is minimal. Fly.io or Workers requires a new deployment pattern.
- MCP server compatibility. Some community MCP servers use Node.js features (long-running child processes, native modules) that Workers cannot support. Fly.io and EC2 are more flexible.
- Security requirements. Enterprise SOC2/HIPAA workloads often mandate specific cloud vendors — check compliance before deciding.
- Global team latency. If your team is spread across three continents, Cloudflare Workers' edge deployment wins on P99 latency.
Scaling Beyond the Small Team
When the team grows above 100 developers, the picture changes. Load ramps to 10K+ requests/day and 30–50 requests/second peaks.
- EC2 at scale: $75–$150/month on t3.medium with autoscaling group. Ops overhead grows.
- Fly.io at scale: $30–$80/month depending on regions. Autoscaling handled by platform.
- Workers at scale: $40–$120/month. Best cost-per-request, and edge deployment reduces P99 latency globally.
Hidden Costs to Watch
- MCP server library dependencies. Some npm packages balloon container size or add cold start latency. Audit dependencies before deploying to serverless platforms.
- Auth infrastructure. If your MCP server needs authenticated access to internal APIs, budget for Vault, AWS Secrets Manager, or similar — often $10–$30/month.
- Log egress. Datadog, Splunk, or CloudWatch charges add up quickly on chatty MCP servers. Budget $5–$20/month for observability.
- Deploy pipeline costs. Github Actions minutes or Fly.io build minutes are usually free at this scale, but if you have many MCP servers, they add up.
Recommendation
- For a team of 20 or under with no existing cloud lock-in, use Fly.io. Cheapest, simplest, no ops overhead.
- For teams already deep in AWS, use EC2. The operational familiarity is worth the $30–$50 premium.
- For global teams or MCP servers with clear serverless-compatible logic, use Cloudflare Workers. Edge deployment wins on latency.
- Always budget observability separately. A cheap MCP server that goes silent for a week costs more than the compute you saved.
Want to calculate exact costs for your project?
Frequently Asked Questions
How much does self-hosting an MCP server cost for a small team?
Between $3 and $50 per month depending on platform. Fly.io is cheapest ($3–$7), Cloudflare Workers is a close second ($5–$18), and AWS EC2 is highest ($30–$50) but offers the most operational familiarity.
Should I use Cloudflare Workers or Fly.io for my MCP server?
Workers if your MCP server has clean serverless-compatible code and your team is globally distributed (edge latency wins). Fly.io if your MCP server uses long-running processes, native modules, or complex Node.js patterns Workers cannot support.
Is EC2 too expensive for MCP hosting?
Not if you already run everything on AWS — the operational familiarity easily justifies the $30–$50/month. If you have no AWS presence, Fly.io or Cloudflare Workers gives you 5–10x cost savings for the same workload.
What are the hidden costs of self-hosting MCP servers?
Authentication infrastructure ($10–$30/month), observability and logging ($5–$20/month), and engineer time for security patching. Budget these separately from raw compute or you will underestimate the true cost.
When should I scale up from a single MCP server instance?
When peak concurrent load exceeds 20 requests/second, or your team exceeds 100 developers using the server actively. Below that, a single instance on any of the three platforms is sufficient.
Related Articles
Running 3 AI Agents on 1 GPU: The Real Cost Math for Self-Hosted Multi-Agent Coding
Three small LLMs serving three AI coding agents on a single 8 GB GTX 1080 — the engineering blueprint a developer published shows how VRAM bookkeeping makes self-hosted multi-agent setups viable on hardware you already own. We unpack the cost trade-offs.
What Is a Self-Hosted OCR Pipeline? Cost Math for AI Coding Agents That Process PDFs
If your AI coding agent ingests PDFs (API docs, contracts, internal manuals), self-hosting OCR can cut document costs 90%+. We explain what a self-hosted OCR pipeline looks like, when it pays off, and how to build one.
How to Choose Between Managed and Self-Hosted LLM Inference for Coding Agents
A total cost of ownership comparison between self-hosted LLM inference (vLLM, TGI on GPUs) and managed APIs (Claude, GPT) for AI coding agents. Includes breakeven analysis by team size and usage volume.