DE

Deploy MCP Server to Google Cloud Run

Deploy your MCP server to Google Cloud Run quickly and securely, follow step-by-step instructions to build, containerize, and run your code in the cloud.

Quick Install
npx -y @GoogleCloudPlatform/cloud-run-mcp

Overview

This guide shows how to deploy the MCP (Model Context Protocol) server to Google Cloud Run. The MCP server provides a small HTTP service that implements the Model Context Protocol and can act as a local/lightweight model proxy, adapter, or orchestrator for model providers. Running it on Cloud Run gives you a fully managed, scalable, and secure endpoint without having to manage servers.

Cloud Run makes it straightforward to containerize the MCP server and operate it in production-like environments. This guide walks you through cloning the repository, building a container image (locally or with Cloud Build), pushing it to Google Container Registry (GCR) or Artifact Registry, and deploying to Cloud Run with recommended configuration and security options.

Repository: https://github.com/GoogleCloudPlatform/cloud-run-mcp

Features

  • Minimal HTTP server implementing the Model Context Protocol (MCP)
  • Designed for containerized deployment (Cloud Run-ready)
  • Works with local and remote model providers via configuration
  • Small footprint and fast cold starts suitable for serverless hosting
  • Easy to run for development and scale automatically in production

Installation / Configuration

Prerequisites:

  • Google Cloud project
  • gcloud CLI installed and authenticated
  • Docker (optional, for local builds) or use Cloud Build
  • APIs: Cloud Run, Cloud Build, Artifact/Container Registry enabled

Enable required APIs and set your project and region:

gcloud config set project YOUR_PROJECT_ID
gcloud config set run/region us-central1
gcloud services enable run.googleapis.com cloudbuild.googleapis.com containerregistry.googleapis.com

Clone the repo:

git clone https://github.com/GoogleCloudPlatform/cloud-run-mcp.git
cd cloud-run-mcp

Build and push the container image (option A: Cloud Build — no local Docker required):

export IMAGE=gcr.io/$GOOGLE_CLOUD_PROJECT/mcp-server:latest
gcloud builds submit --tag $IMAGE

Option B: Build locally with Docker and push to GCR:

export IMAGE=gcr.io/$GOOGLE_CLOUD_PROJECT/mcp-server:latest
docker build -t $IMAGE .
docker push $IMAGE

Deploy to Cloud Run (allow unauthenticated for public access or remove flag for private access):

gcloud run deploy mcp-server \
  --image $IMAGE \
  --platform managed \
  --region us-central1 \
  --concurrency 80 \
  --memory 512Mi \
  --allow-unauthenticated

Recommended environment variables (example):

gcloud run services update mcp-server \
  --update-env-vars PORT=8080,LOG_LEVEL=info,MCP_CONFIG=/app/config.yaml

Notes:

  • Cloud Run expects the container to listen on the port provided in the PORT environment variable (default 8080).
  • Use --no-allow-unauthenticated and IAM settings to restrict access for production deployments.

Available Resources

  • GitHub repo: https://github.com/GoogleCloudPlatform/cloud-run-mcp
  • Cloud Run docs: https://cloud.google.com/run/docs
  • Cloud Build docs: https://cloud.google.com/build/docs
  • Container Registry docs: https://cloud.google.com/container-registry or Artifact Registry: https://cloud.google.com/artifact-registry

Common gcloud commands:

ActionCommand
Set projectgcloud config set project PROJECT_ID
Build with Cloud Buildgcloud builds submit –tag IMAGE
Deploy to Cloud Rungcloud run deploy NAME –image IMAGE –region REGION
View logsgcloud logs read –project=PROJECT_ID –limit=50
Update env varsgcloud run services update NAME –update-env-vars KEY=VALUE

Use Cases

  • Development proxy: Run an MCP server in Cloud Run to centralize access to multiple local or hosted model endpoints during development and QA.
  • Multi-provider orchestration: Use the MCP server as a lightweight gateway that routes requests to different model backends (open-source, private, cloud) based on context or configuration.
  • Secure model adapter: Deploy the MCP server inside a private VPC connector and restrict ingress to internal clients, enabling secure communication with private model endpoints.
  • Scalable inference endpoint: Containerize model-forwarding logic or request middleware and let Cloud Run scale it automatically for bursty workloads without manual server management.

Example: deploy a private MCP endpoint for internal apps only

  1. Deploy with authentication required: gcloud run deploy mcp-server –image $IMAGE –no-allow-unauthenticated
  2. Create a service account for callers, grant the Cloud Run Invoker role, and use workload identity or signed tokens from your apps to call the service.

Tips & Best Practices

  • Keep containers minimal (use slim base images) to reduce cold start time.
  • Use Cloud Build for CI/CD builds triggered from GitHub or Cloud Source Repositories.
  • Store secrets (API keys, credentials) in Secret Manager and mount them as environment variables rather than baking into images.
  • Monitor logs and metrics in Cloud Logging and Cloud Monitoring; set alerts for error rates and latency spikes.

Following these steps will get an MCP server running in Cloud Run quickly and with options to secure, scale, and integrate it into your existing infrastructure.