Deployment guide1-minute readEN · DE · IT

Deploy AnythingMCP on Google Cloud Run

Deploy AnythingMCP as a serverless container on Google Cloud Run with Cloud SQL for PostgreSQL. Scalable, pay-per-use MCP gateway.

HCBy HelpCode teamUpdated 1 min read Open source on GitHub

No credit card · 7-day trial · Self-host alternative available

  • 7-day free trial
    No credit card required
  • GDPR & SOC 2 ready
    EU data residency, audit logs
  • Open-source on GitHub
    Source-available BSL-1.1
  • Works with ChatGPT, Claude, Gemini
    Any MCP-compatible client

Summary

Deploy AnythingMCP as a serverless container on Google Cloud Run with Cloud SQL for PostgreSQL. Scalable, pay-per-use MCP gateway.

Why Google Cloud Run?

Cloud Run lets you run containers without managing servers. Combined with Cloud SQL for PostgreSQL, it provides a scalable, pay-per-use deployment. HTTPS is handled automatically — no reverse proxy needed.

This is more advanced than VM-based deployments. You cannot run setup.sh on Cloud Run, so you must build the image, push it, and configure environment variables manually.

Prerequisites

  • A GCP account with billing enabled
  • gcloud CLI installed and authenticated
  • Docker installed locally
gcloud config set project YOUR_PROJECT_ID
gcloud config set run/region europe-west1

gcloud services enable \
  run.googleapis.com \
  sqladmin.googleapis.com \
  artifactregistry.googleapis.com \
  cloudbuild.googleapis.com

Set Up Cloud SQL

gcloud sql instances create anythingmcp-db \
  --database-version=POSTGRES_16 \
  --tier=db-f1-micro \
  --region=europe-west1

gcloud sql databases create anythingmcp --instance=anythingmcp-db

gcloud sql users create amcp \
  --instance=anythingmcp-db \
  --password=YOUR_DB_PASSWORD

Note the instance connection name (e.g. project-id:europe-west1:anythingmcp-db).

Build and Push the Image

git clone https://github.com/HelpCode-ai/anythingmcp.git
cd anythingmcp

# Option A: Build locally
docker build -t europe-west1-docker.pkg.dev/YOUR_PROJECT_ID/anythingmcp/app:latest .
docker push europe-west1-docker.pkg.dev/YOUR_PROJECT_ID/anythingmcp/app:latest

# Option B: Build with Cloud Build
gcloud builds submit --tag europe-west1-docker.pkg.dev/YOUR_PROJECT_ID/anythingmcp/app:latest

Generate Secrets

Since setup.sh cannot run on Cloud Run, generate secrets manually:

JWT_SECRET=$(openssl rand -hex 32)
ENCRYPTION_KEY=$(openssl rand -hex 16)
NEXTAUTH_SECRET=$(openssl rand -hex 32)

Deploy to Cloud Run

gcloud run deploy anythingmcp \
  --image=europe-west1-docker.pkg.dev/YOUR_PROJECT_ID/anythingmcp/app:latest \
  --allow-unauthenticated \
  --port=4000 \
  --min-instances=1 \
  --max-instances=5 \
  --memory=512Mi \
  --cpu=1 \
  --set-env-vars="NODE_ENV=production" \
  --set-env-vars="DATABASE_URL=postgresql://amcp:YOUR_DB_PASSWORD@localhost:5432/anythingmcp" \
  --set-env-vars="JWT_SECRET=$JWT_SECRET" \
  --set-env-vars="ENCRYPTION_KEY=$ENCRYPTION_KEY" \
  --set-env-vars="NEXTAUTH_SECRET=$NEXTAUTH_SECRET" \
  --set-env-vars="MCP_AUTH_MODE=oauth2" \
  --add-cloudsql-instances=YOUR_PROJECT_ID:europe-west1:anythingmcp-db

--min-instances=1 avoids cold starts. The Cloud SQL proxy uses a Unix socket, so localhost works in the DATABASE_URL.

Custom Domain (Optional)

gcloud run domain-mappings create \
  --service=anythingmcp \
  --domain=mcp.example.com \
  --region=europe-west1

Follow the DNS instructions in the output. SSL is provisioned automatically.

Limitations

  • Stateless — Cloud Run instances are ephemeral. All data must be in Cloud SQL.
  • Cold starts — Use --min-instances=1 to mitigate (small cost).
  • No setup.sh — All config is via environment variables at deploy time.
  • Costs — Cloud Run charges per request + vCPU time. Cloud SQL has a fixed monthly cost.

Updating

git pull
docker build -t europe-west1-docker.pkg.dev/YOUR_PROJECT_ID/anythingmcp/app:latest .
docker push europe-west1-docker.pkg.dev/YOUR_PROJECT_ID/anythingmcp/app:latest
gcloud run deploy anythingmcp \
  --image=europe-west1-docker.pkg.dev/YOUR_PROJECT_ID/anythingmcp/app:latest \
  --region=europe-west1

Existing env vars and Cloud SQL connections are preserved across redeployments.

Was this guide helpful?

Ready to ship

Ship MCP to your stack in 60 seconds.

Spin up AnythingMCP on managed Cloud or self-host it on your infrastructure. Free for 7 days, no credit card.

Related guides