cloudrun.sh
Overview
cloudrun.sh is a shell script designed to automate the deployment of the Zoo Animal MCP server to Google Cloud Run in an unauthenticated mode. Its purpose is to deploy the service such that it is publicly accessible without requiring any authentication tokens or identity verification. This enables open, unrestricted HTTP access to the Zoo Animal Query API, facilitating scenarios such as demos, public APIs, or internal testing environments.
The script uses the Google Cloud CLI (gcloud) to perform the deployment with specific flags and options that:
Build the container image from the current source directory.
Deploy the containerized service to a defined region (
europe-west1).Apply custom labels for resource tracking.
Enable unauthenticated access (
--allow-unauthenticated).
This file plays a critical role within the larger Cloud Run Deployment Automation framework, providing a streamlined and repeatable command for deploying the MCP server publicly.
File Content and Explanation
echo "Deploying Cloud Run Endpoint in Unauthenticated Mode"
gcloud run deploy zoo-mcp-server \
--allow-unauthenticated \
--region=europe-west1 \
--source=. \
--labels=dev-tutorial=codelab-gde-medium-open
Script Breakdown
echo "Deploying Cloud Run Endpoint in Unauthenticated Mode"
Outputs a notification message indicating that the deployment will be performed with public access.gcloud run deploy zoo-mcp-server </code>Invokes the Google Cloud Run deployment command targeting a service named zoo-mcp-server.--allow-unauthenticated </code>Configures Cloud Run to allow access to the deployed service without requiring authentication, making the endpoint publicly accessible.--region=europe-west1 </code>Specifies the geographic region where the service will be deployed, ensuring consistent latency and compliance with regional requirements.--source=. </code>Indicates that the container image should be built from the current directory source code, allowing deployment of the latest local changes.--labels=dev-tutorial=codelab-gde-medium-openAttaches metadata labels to the deployment for identification and management purposes in the Google Cloud Console.
Usage
This script is typically executed after initializing the environment and project setup using supporting scripts such as init.sh and set_env.sh. It assumes that the user has appropriate permissions and that the Google Cloud SDK (gcloud) is installed and authenticated.
Example Usage
./cloudrun.sh
This command will:
Print the deployment mode message.Deploy the Zoo MCP server to Cloud Run with public access enabled.
Important Implementation Details
Unauthenticated Access:The core feature of this script is the --allow-unauthenticated flag, which configures Cloud Run to accept requests without any identity tokens. This is crucial for use cases where open access is required.Region Consistency:The deployment region is hardcoded as europe-west1 to maintain consistent deployment locality and performance characteristics. This aligns with environment setup scripts that export the same region variable.Source-based Deployment:Deploying from source (--source=.) triggers Cloud Run to build the container image directly from the local project files, ensuring that the deployed container matches current code.Labeling:Labels are used to tag the deployed service for easier resource management, billing, and auditability within the Google Cloud environment.Idempotency:Running this script multiple times will update the existing Cloud Run service without recreating it from scratch, supporting iterative development and continuous deployment workflows.
Interaction with Other Parts of the System
This deployment script is part of a suite of shell scripts in the deployment automation process:
Depends on environment initialization scripts such as init.sh and set_env.sh which configure project settings, enable required APIs, export environment variables, and authenticate the user.Complements the secure deployment script (cloudrun-secure.sh), which deploys the same service but with authentication enforced.The deployed service exposes the Zoo Animal Query API (Zoo Animal Query API) for querying animal data without access restrictions.Post-deployment, monitoring and operational management can be performed using tools described in Operational Monitoring & Environment Management and Log Retrieval.
Deployment Workflow Diagram
flowchart TD
A[User Executes cloudrun.sh] --> B[Echo Deployment Mode]
B --> C[gcloud run deploy Command]
C --> D[Build Container from Source]
D --> E[Deploy to Cloud Run Service: zoo-mcp-server]
E --> F[Service Deployed with Public Access]
F --> G[API Available Without Authentication]
This flowchart visualizes the straightforward deployment process enabled by cloudrun.sh, emphasizing the public, unauthenticated access mode and source-based container build.
References to Related Topics
For detailed context on deployment automation and environment setup, see Cloud Run Deployment Automation.To understand the implications and configurations of unauthenticated deployments, refer to Unauthenticated Deployment.For secure deployment alternatives requiring authentication, see Secure Deployment.For background on environment setup and required Google Cloud configurations, see Environment Initialization.
This file (cloudrun.sh) encapsulates a minimal yet effective deployment command tailored for public, unauthenticated hosting of the Zoo MCP server on Google Cloud Run, serving as a key component in the overall deployment automation ecosystem.