gcp-mcp-server
Model Context Protocol server for Google Cloud Platform, enabling interaction with Resource Manager, Compute Engine, Cloud Storage, BigQuery, Pub/Sub, and Cloud Logging via natural language.
README
gcp-mcp-server
Model Context Protocol server for Google Cloud Platform. Built on the MCP
Python SDK (mcp>=1.27) using FastMCP, with tools that touch Resource
Manager, Compute Engine, Cloud Storage, BigQuery, Pub/Sub, and Cloud Logging.
Features
- Application Default Credentials (ADC) or explicit service-account JSON auth
- Lazy-constructed Google Cloud SDK clients bound to resolved credentials
- Blocking SDK calls executed in worker threads via
anyio.to_thread.run_sync - Typed tools covering the most common GCP day-to-day operations
- Unit tests that mock the SDK clients end-to-end (no real API calls)
Install
git clone https://github.com/asklokesh/gcp-mcp-server.git
cd gcp-mcp-server
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Requires Python 3.10 or newer.
Authentication
The server resolves credentials in the following order:
- If
GCP_CREDENTIALS_PATHpoints to a service-account JSON file, that file is used. - Otherwise, Application Default Credentials (ADC) are loaded via
google.auth.default().
For ADC, the simplest path is:
gcloud auth application-default login
Or point GOOGLE_APPLICATION_CREDENTIALS at a service-account JSON file.
Environment variables
All settings are optional and use the GCP_ prefix:
| Variable | Description | Default |
|---|---|---|
GCP_DEFAULT_PROJECT_ID |
Project id used when a tool doesn't receive one | unset |
GCP_CREDENTIALS_PATH |
Path to a service-account JSON file | unset (ADC) |
GCP_TIMEOUT |
Default per-request timeout in seconds | 60 |
Claude Desktop configuration
Add an entry like this to your Claude Desktop mcpServers config:
{
"mcpServers": {
"gcp": {
"command": "gcp-mcp",
"env": {
"GCP_DEFAULT_PROJECT_ID": "my-gcp-project",
"GCP_CREDENTIALS_PATH": "/absolute/path/to/service-account.json"
}
}
}
}
If you prefer ADC, omit GCP_CREDENTIALS_PATH and ensure
gcloud auth application-default login was run as the same user that
launches Claude Desktop.
Tools
Resource Manager / IAM
list_projects()- list visible GCP projectsget_project(project_id)- fetch project metadatalist_service_accounts(project_id)- list IAM service accounts via the IAM REST API
Compute Engine
list_instances(project_id?, zone?)- zonal or aggregated instance listget_instance(project_id, zone, name)- single instance detailsstart_instance(project_id, zone, name)- start a VMstop_instance(project_id, zone, name)- stop a VM
Cloud Storage
list_buckets(project_id?)- list buckets in a projectlist_objects(bucket, prefix?, max_results=100)- list blobsget_object_metadata(bucket, name)- fetch blob metadata
BigQuery
list_datasets(project_id?)- list datasetslist_tables(project_id, dataset)- list tablesquery_bigquery(project_id, sql, dry_run=False)- run a query; dry-run returns schema and estimated bytes
Pub/Sub
list_topics(project_id?)- list topicslist_subscriptions(project_id?)- list subscriptionspublish_message(project_id, topic, data, attributes?)- publish a message.datais UTF-8; prefix withbase64:for binary payloads.
Cloud Logging
read_logs(project_id, filter, max_entries=50)- advanced log filter, e.g.resource.type="gce_instance"
Required IAM roles
The caller's principal needs appropriate roles per surface. Minimal recommended roles:
| Surface | Role(s) |
|---|---|
| Resource Manager | roles/resourcemanager.projectViewer, roles/browser |
| IAM | roles/iam.serviceAccountViewer |
| Compute | roles/compute.viewer, roles/compute.instanceAdmin.v1 (for start/stop) |
| Cloud Storage | roles/storage.objectViewer, roles/storage.bucketViewer |
| BigQuery | roles/bigquery.dataViewer, roles/bigquery.jobUser |
| Pub/Sub | roles/pubsub.viewer, roles/pubsub.publisher |
| Cloud Logging | roles/logging.viewer (or roles/logging.privateLogViewer) |
Grant only what the caller actually needs.
Development
Run the test suite:
source .venv/bin/activate
pytest -x --tb=short
Lint:
ruff check src/ tests/
Tests mock each Google Cloud client with unittest.mock, so no real
GCP APIs are called.
Project layout
src/gcp_mcp/
__init__.py # main entry point
auth.py # ADC / service-account credential resolution
clients.py # lazy SDK client construction
config.py # pydantic-settings config (GCP_ env prefix)
exceptions.py # GCPError, AuthenticationError, APIError, NotFoundError
server.py # FastMCP server + @mcp.tool() definitions
tests/ # unit tests with mocked SDK clients
pyproject.toml
requirements.txt
License
MIT.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。