The GCP MCP Server enables AI assistants to interact with Google Cloud Platform services through a standardized Model Context Protocol interface. It allows querying cloud resources, managing GCP services, and receiving AI-guided assistance with cloud configurations.
Clone the repository:
git clone https://github.com/yourusername/gcp-mcp-server.git
cd gcp-mcp-server
Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Set up your GCP credentials using one of these methods:
# Using gcloud command
gcloud auth application-default login
# OR by setting environment variable
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
Create your environment configuration:
cp .env.example .env
# Edit .env with your specific settings
Start the MCP server with:
python main.py
Development mode with auto-reload:
python main.py --dev
Using a specific configuration file:
python main.py --config config.yaml
Build and run with Docker:
# Build the image
docker build -t gcp-mcp-server .
# Run the container
docker run -p 8080:8080 -v ~/.config/gcloud:/root/.config/gcloud gcp-mcp-server
The server can be configured through environment variables:
Variable | Description | Default |
---|---|---|
GCP_PROJECT_ID |
Your GCP project ID | Required |
GCP_DEFAULT_LOCATION |
Default region/zone | us-central1 |
MCP_SERVER_PORT |
Server port | 8080 |
LOG_LEVEL |
Logging level | INFO |
service-account.json
in the server directorypip install "mcp[cli]" google-cloud-run
mcp dev gcp_cloudrun_server.py
mcp install gcp_cloudrun_server.py --name "GCP Cloud Run Manager"
Add this to your MCP configuration file to enable GCP Cloud Tools:
"mcpServers": {
"GCP Cloud Tools": {
"command": "uv",
"args": [
"run",
"--with",
"google-cloud-artifact-registry>=1.10.0",
"--with",
"google-cloud-bigquery>=3.27.0",
"--with",
"google-cloud-build>=3.0.0",
"--with",
"google-cloud-compute>=1.0.0",
"--with",
"google-cloud-logging>=3.5.0",
"--with",
"google-cloud-monitoring>=2.0.0",
"--with",
"google-cloud-run>=0.9.0",
"--with",
"google-cloud-storage>=2.10.0",
"--with",
"mcp[cli]",
"--with",
"python-dotenv>=1.0.0",
"mcp",
"run",
"PATH_TO_SERVER_MAIN_FILE"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_SERVICE_ACCOUNT_JSON",
"GCP_PROJECT_ID": "YOUR_GCP_PROJECT_ID",
"GCP_LOCATION": "PREFERRED_GCP_REGION"
}
}
}
The MCP server provides access to these GCP services:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.