markwkiehl/medium_gcp_mcp_fastapi
If you are the rightful owner of medium_gcp_mcp_fastapi and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This document provides a structured overview of a Model Context Protocol (MCP) server implemented using FastAPI and deployed on Google Cloud Platform's Cloud Run.
medium_gcp_mcp_fastapi
MCP Server via FastAPI & GCP Cloud Run
The complete public article can be found here
This repository provides a template for the deployment of a Model Context Protocol (MCP) Server on Google Cloud Run. Both the Python client and server scripts are included, as well as batch files to fully automate deployment to the Google Cloud Platform.
Quick Start
All of the details on installation of Python, Google CLI & SDK, and Docker can be found in my seven-part article series "Building a Data Platform on GCP". The more recent article "Deploy Your Custom MCP AI Tool to Cloud Run" also includes simple instructions.
The batch files included in my public GitHub repository contain minor updates in response to recent GCP changes, so be sure to use those versions instead of what was published previously.
-
Install prerequisites
- Install Python, Google CLI & SDK, and Docker.
-
Prepare your project folder
- Download a copy of the GitHub repository contents into an empty folder on your PC.
- Do not name this folder the same as either of the Python scripts.
- Expand the contents inside this folder — this folder will become your Python virtual environment.
-
Configure Google Cloud
- Log in to (or create) a Google user account.
- From the Google Admin Console, configure billing.
-
Edit configuration
- Edit the file
gcp_constants.bat.
You must update this file with:- Your Google account email address (
GCP_USER) - Your Google Cloud Billing Account Number (
GCP_BILLING_ACCOUNT)
- Your Google account email address (
- If you are not located in the USA, consider updating:
GCP_REGIONGCP_GS_BUCKET_LOCATION
(See Geography & Regions)
- Edit the file
-
Start Docker
- Run Docker Desktop. This starts the Docker Engine required by the batch file
gcp_6_docker_build.bat.
- Run Docker Desktop. This starts the Docker Engine required by the batch file
-
Run the batch files
- Open a Windows Command Prompt.
- Navigate to the folder where you downloaded the GitHub contents.
- Sequentially execute each batch file:
gcp_1_venv.bat,gcp_2_proj.bat, …gcp_8_bucket_runsvc.bat. - Important: The last batch file,
gcp_8_bucket_runsvc.bat, will output the URL for the Cloud Run service.
Copy that URL and updateapi_mcp_fastapi_client.py.
-
Verify the Cloud Run deployment
- At this point, the Google Cloud Run service will be running your MCP server.
- Open the Cloud Run service URL in a browser to verify functionality using the
/endpoint.
The expected response is:{"status": "ok", "message": "Server is running. See /docs for API schema."}
-
Configure the client script
- Edit
api_mcp_fastapi_client.pywith the Cloud Run service URL created bygcp_8_bucket_runsvc.bat. - If you didn’t capture the URL from the command output, you can find it in the Google Cloud Run Console under Services.
- Edit
-
Run the client
- Execute the script
api_mcp_fastapi_client.py.
- Execute the script