tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > MCP Protocol > Deploying an MCP Server to Cloud Run

Deploying an MCP Server to Cloud Run

Author: Venkata Sudhakar

Local stdio-based MCP servers work during development but cannot be shared across teams or scaled to handle production traffic. Google Cloud Run is the ideal deployment target for MCP servers: it is serverless, scales to zero when idle, and provides HTTPS endpoints out of the box. Once deployed, any ADK agent anywhere can connect to the MCP server URL using SseServerParameters without needing to run the server locally.

The deployment process has three steps: write a Dockerfile to containerise the FastMCP server, deploy to Cloud Run using gcloud, and update the ADK agent to connect via the Cloud Run HTTPS URL. Cloud Run handles TLS termination, auto-scaling, and health checks. Add an Authorization header to authenticate agents against the deployed server.

The below example shows the complete files needed to containerise and deploy a ShopMax India MCP server to Cloud Run, and the agent code to connect to it.


Create a Dockerfile to containerise the MCP server,


Build, push, and deploy to Cloud Run,


Connect an ADK agent to the deployed Cloud Run MCP server,


It gives the following output,

ShopMax India Product Catalogue:
1. Lenovo IdeaPad (Laptop) - Rs 45,000 | 42 units in stock
2. LG 43-inch 4K (TV)     - Rs 35,000 | 15 units in stock
3. Redmi Note 13 (Phone)  - Rs 18,000 | 120 units in stock

All products are available for immediate dispatch!

Cloud Run scales the MCP server to zero when no agents are connected, making it cost-effective for low-traffic periods. Set minimum instances to 1 in the Cloud Run configuration if your agents cannot tolerate cold start latency (typically 2-3 seconds for a Python container). Use Cloud Run's built-in IAM authentication instead of the custom API key pattern for tighter Google Cloud integration: set --no-allow-unauthenticated on deploy and pass a Google-signed ID token in the Authorization header from the ADK agent. Store the MCP_API_KEY in Google Cloud Secret Manager and inject it at deploy time using --set-secrets MCP_API_KEY=shopmax-mcp-key:latest.


 
  


  
bl  br