CuratedMCP
Learn/MCP Server Hosting
Advanced · 16 min read

MCP Server Hosting

Self‑Hosted vs Cloud Deployment

Deploy MCP servers to production with confidence. Compare self-hosted Docker, Kubernetes, and cloud platforms like Railway and Fly.io. Includes cost analysis, security considerations, and a step-by-step deployment guide.

Hosting Options Compared

Self-Hosted (Docker)

Intermediate
$50-200/month

Pros

  • Full control over infrastructure
  • Can run on any VPS or local server
  • No vendor lock-in
  • Cost-effective for single servers

Cons

  • Manual updates and maintenance
  • Limited auto-scaling
  • Requires DevOps knowledge
  • You manage security patches

Best for: Small teams, internal tools, cost-conscious projects

Kubernetes (Self-Managed)

Advanced
$100-500/month

Pros

  • Auto-scaling based on demand
  • Service mesh capabilities
  • Multi-zone high availability
  • Industry standard for enterprises

Cons

  • Steep learning curve
  • Complex to set up and maintain
  • Requires dedicated ops team
  • Overkill for small workloads

Best for: Enterprise environments, high-traffic services, teams with Kubernetes expertise

Railway / Fly.io

Easy
$5-100/month

Pros

  • Dead simple deployment (git push to deploy)
  • Automatic scaling and load balancing
  • Global edge deployment (Fly.io)
  • Free tier available

Cons

  • Vendor lock-in
  • Limited customization for advanced users
  • Pricing scales with traffic
  • Community smaller than AWS

Best for: Startups, side projects, rapid prototyping, teams valuing developer experience

AWS ECS

Intermediate
$50-300/month

Pros

  • Deeply integrated with AWS ecosystem
  • Excellent IAM and security controls
  • Can use existing RDS, S3, etc.
  • Enterprise-grade monitoring

Cons

  • Steep learning curve (AWS ecosystem)
  • Pricing can be opaque
  • Vendor lock-in (AWS)
  • Often requires AWS expertise

Best for: Companies already using AWS, enterprises, security-critical applications

Serverless (AWS Lambda / Google Cloud Run)

Easy
$0-50/month

Pros

  • Pay only for execution time
  • Zero infrastructure management
  • Auto-scales to zero
  • Great for intermittent workloads

Cons

  • Cold start latency (Lambda)
  • Limited execution time (15 min for Lambda)
  • Not ideal for long-running processes
  • Resource constraints (memory, disk)

Best for: Webhook handlers, scheduled tasks, APIs with variable load, cost-conscious projects

Deploying Your MCP Server

01

Containerize your MCP server

Package your MCP server as a Docker image.

  • Create a Dockerfile with your MCP server code
  • Minimize the image size (use multi-stage builds)
  • Push to Docker Hub, ECR, or a private registry
02

Choose a hosting platform

Evaluate options based on your team size, budget, and requirements.

  • Assess uptime requirements (99.9% vs 99.99%)
  • Estimate traffic and concurrent connections
  • Consider compliance needs (HIPAA, SOC 2, etc.)
  • Review pricing models and hidden costs
03

Set up environment variables

Configure secrets and API keys securely.

  • Never commit secrets to version control
  • Use environment variable management (AWS Secrets Manager, HashiCorp Vault, 1Password)
  • Rotate secrets regularly
  • Use least-privilege access tokens
04

Configure load balancing & health checks

Ensure your MCP server can handle traffic and recover from failures.

  • Set up health check endpoints (/health or /status)
  • Configure load balancer to remove unhealthy instances
  • Enable auto-restart on failure
  • Monitor response times and error rates
05

Set up monitoring & alerts

Track performance and be notified of issues.

  • Log all requests and errors (stdout/stderr captured by platform)
  • Set up alerting for error rates, latency, or failed health checks
  • Use a tool like Datadog, New Relic, or CloudWatch
  • Create runbooks for common incidents
06

Test end-to-end

Verify your MCP server works in production.

  • Connect Claude Desktop to your production MCP server
  • Test all major features and edge cases
  • Verify authentication and authorization work
  • Perform a quick load test to check scaling

Sample Dockerfile

A production-ready Dockerfile for your MCP server:

# Multi-stage build for minimal image size FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # Production image FROM node:20-alpine WORKDIR /app # Don't run as root RUN addgroup -g 1001 -S nodejs RUN adduser -S nodejs -u 1001 COPY --from=builder --chown=nodejs:nodejs /app . USER nodejs # Health check endpoint HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})" EXPOSE 3000 CMD ["npm", "start"]

Environment Variables Template

Never commit these to version control. Use your platform's secret management:

# Security & Authentication MCP_SERVER_KEY=your-unique-server-key AUTH_TOKEN=your-api-token NODE_ENV=production # Database & External Services DATABASE_URL=postgresql://user:pass@host:5432/dbname API_KEY_GITHUB=ghp_xxx API_KEY_PAGERDUTY=u+xxx SPLUNK_TOKEN=xxx # Monitoring & Logging LOG_LEVEL=info SENTRY_DSN=https://[email protected]/xxx DATADOG_API_KEY=xxx # Server Configuration PORT=3000 WORKERS=4 REQUEST_TIMEOUT=30000

Production Security Checklist

Use HTTPS/TLS for all connections
Implement rate limiting to prevent abuse
Validate and sanitize all inputs
Use short-lived API tokens (rotate frequently)
Implement logging and audit trails
Set up firewall rules and network policies
Keep dependencies updated (automated scanning)
Run security scans (SAST, DAST) in CI/CD
Use minimal base images (official distributions)
Never run containers as root user

Cost Estimation Examples

Scenario 1: Small Team / Internal Tool

Low traffic, infrequent usage, internal users only.

Railway Basic (CPU, memory)$7/month
Total~$7/month

Scenario 2: Production API (Moderate Traffic)

~1,000 requests/day, requires monitoring, backups, and 99.9% uptime.

Fly.io (3 instances in 3 regions)$25-40/month
Database (PostgreSQL)$15-30/month
Monitoring (Datadog)$15-30/month
Total~$55-100/month

Scenario 3: Enterprise (High Traffic & Compliance)

~100,000 requests/day, multi-region, SOC 2 compliance, dedicated support.

AWS ECS (auto-scaled, multi-AZ)$150-300/month
RDS Database (multi-AZ)$100-200/month
Load Balancer & CDN$50-100/month
Monitoring & Logging$100-300/month
Total~$400-900+/month

Railway Quick Start

Deploy in minutes with a git push. Free tier available.

Visit Railway →

Fly.io Global Deployment

Deploy to 30+ regions automatically. Best for low latency.

Visit Fly.io →