
GCP Platform Engineer
io.github.deBilla由 GitHub 账号 deBilla 发布v0.4.0更新于 Oct 24, 2026
Read-only GCP tools for debugging incidents and finding cost savings
概览
只读的 GCP 服务器,让助手查看日志、指标、资源和账单,用于排查故障并发现成本优化空间。
- 可以做什么
- 列出并切换已配置的 GCP 环境,结果会回显所属环境和项目
- 查询日志、获取近期错误并汇总错误分组
- 查询指标、列出告警策略和可用性检查
- 查看成本明细、账单信息以及成本与其他优化建议
- 搜索云资源,并盘点 Compute、Cloud Run、GKE 和 Cloud SQL 实例
- 适用场景
- 适合让助手排查 GCP 故障、盘点资源或在预发与生产项目之间寻找降本机会,同时不赋予其修改基础设施的能力。
- 运行要求
- 本地运行的 Python 3.11+ 进程,通常通过 uvx 或 pipx 启动。需要一个 Google Cloud 项目及 Application Default Credentials(个人登录或服务账号),一次性配置需要 gcloud CLI,并在各项目上具备查看者角色及账单查看权限。环境可通过 TOML 配置文件或 PLATFORM_MCP_ENVIRONMENTS 变量配置;成本明细还需要 BigQuery 账单导出表。
安装
在 SourceWeft 中
- 打开 控制台中的 GCP Platform Engineer,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
platform-mcp
mcp-name: io.github.deBilla/platform-mcp
A read-only Model Context Protocol server that turns an AI agent (Claude Code, Claude Desktop, or any MCP client) into a GCP platform engineer. Point it at your Google Cloud projects and ask it to investigate incidents, take inventory, and surface cost-optimization opportunities — all without any ability to change your infrastructure.
Observation only. No tool in this server mutates state. Combined with a viewer-only identity (below), that gives you a hard, defense-in-depth guarantee that an agent can look but never touch.
What it can do
Typical prompts once it's connected:
- "What are the top error groups in the last 24 hours, and which one is newest?"
- "Which GKE node pools are over-provisioned? Show mean CPU against machine type."
- "Where can I reduce spend in this project?"
Multiple environments
One server can reach several projects. Define them under
PLATFORM_MCP_ENVIRONMENTS (see Configuration) and the agent
picks one from the wording of your prompt:
- "Any errors in staging in the last hour?"
- "Compare Cloud Run services between staging and prod."
Every tool takes an optional environment argument. Omit it and the default
environment is used; pass environment="production" to target another. Names,
any aliases you define, common shorthands (prod, stg, qa, …) and bare
project ids all resolve. An unrecognized name is an error listing the valid
options — a typo can never silently retarget the wrong project.
Each environment carries its own service account, so staging and production are
reached through separate identities from the same process, and every result
echoes back the environment and project it came from.
Requirements
- Python 3.11+
- A Google Cloud project and credentials (your own login, or a service account)
- The
gcloudCLI for the one-time setup
Install
From a checkout, for development:
Check your setup
This checks, for every configured environment, that Application Default Credentials exist, that the read-only service account can be impersonated, that a real API read succeeds, and that the billing export is readable — printing the exact command to fix whatever fails. Run it before reporting a problem.
One-time GCP setup
Run these once per project you want to reach — staging and production each need their own APIs enabled and their own read-only service account.
1. Enable the APIs the tools depend on:
2. Grant read-only access to the identity the server runs as.
For local development with your own login (Application Default Credentials):
The identity needs these viewer roles on the project, plus roles/billing.viewer
on the billing account:
3. (Recommended) Use a dedicated read-only service account instead of your
login. platform-mcp setup does every step below, is safe to re-run, and prints
the config stanza at the end. It ships with the package, so there is nothing to
clone:
Or by hand:
The grant everyone forgets. roles/bigquery.jobUser above only lets the
account start a query; it grants no access to any data. A billing export
almost always lives in a different project, so the account also needs read
on that dataset. Without it get_cost_breakdown returns 403 while every other
tool works, which reads like a bug in the tool rather than a missing grant:
If you lack admin on the billing project, that one line is what to send to
someone who has it. platform-mcp doctor checks it and says which side is
missing.
Then reference it as that environment's impersonate value in
PLATFORM_MCP_ENVIRONMENTS (preferred — no key file), or point at a downloaded
key via GOOGLE_APPLICATION_CREDENTIALS.
Impersonation is performed by whatever identity your ADC resolves to. If your ADC is itself an impersonated service account, that SA — not your user — needs
roles/iam.serviceAccountTokenCreatoron eachplatform-mcp-ro.
Security model
Read-only is enforced by IAM, not by OAuth scope. The server requests the
broad cloud-platform scope and stays read-only purely because it never calls a
mutating API. Do not rely on the code alone — run it under a viewer-only
identity (step 3 above) so the credential itself is incapable of writing,
regardless of what code executes. This gives you two independent layers: the
server doesn't try to write, and the identity couldn't if it did.
With multiple environments this stays per-project: each environment authenticates as its own service account, so a staging identity is never used to reach production. Grant each one viewer-only access to its project alone.
Configuration
The friendliest option is a config file, which keeps project ids and service account emails out of every client config you own:
With that in place, registering the server takes no environment variables at
all. Point PLATFORM_MCP_CONFIG elsewhere to use a different file — a copy
committed to your infrastructure repo, for instance.
Environment variables still work and always win over the file, so an existing setup keeps running unchanged and a one-off override needs no edit:
PLATFORM_MCP_ENVIRONMENTS holds a JSON object; each entry accepts:
A bare string value is shorthand for {"project": "..."}. As JSON inside
.mcp.json the quotes must be escaped; unescaped it reads:
Single-environment mode. If PLATFORM_MCP_ENVIRONMENTS is unset the server
behaves as before, exposing one environment named default:
Register with a client
Claude Code — with a config file in place, this is the whole thing:
Claude Desktop — needs an absolute path to uvx; see
Claude Desktop for the full walkthrough.
Without a config file, add the environment variables from
.mcp.json.example to either form.
Skip the approval prompt
Every tool here is read-only, so approving each call individually adds nothing. Allow the whole server once, in Claude Code settings:
The glob must sit after a literal mcp__<server>__ prefix — an unanchored
pattern like mcp__* is ignored with a warning and approves nothing.
MCP Inspector — for interactive testing:
Claude Desktop
Installing for a teammate who uses Claude Desktop rather than the CLI. It works the same as Claude Code, with one failure mode the CLI does not have.
Claude Desktop does not inherit your shell PATH. It launches from the
Finder, so uvx and anything installed by Homebrew or uv are invisible to it.
A config that says "command": "uvx" fails with ENOENT — the server never
starts, and the error names the command rather than the reason. The command
path must be absolute.
What does not break is credentials. Application Default Credentials are a
file the Google libraries read directly, so gcloud is needed once, in a
terminal, to create that file — not at runtime. The config file is found the
same way, from the home directory, whatever launched the server.
Before you start: the admin grant
Each person impersonates the read-only service accounts, so an admin runs this
once per person, per environment (the platform-mcp setup script does it for
whoever runs it, but not for anyone else):
Without it everything installs fine and doctor fails at the impersonation
step.
1. Install uv (macOS)
An analyst's laptop usually has neither Homebrew nor the Xcode Command Line
Tools, and nothing here needs them. Avoid git, make and the stock
/usr/bin/python3 along the way — they are stubs that pop a dialog offering to
install a gigabyte of developer tooling. uv is a standalone binary:
Typically /Users/<you>/.local/bin/uvx.
2. Install the Google Cloud CLI
The tarball bundles its own Python, so it needs nothing else. Avoid
brew install --cask google-cloud-sdk: Homebrew itself requires the Command
Line Tools. Pick the build for your chip — uname -m prints arm64 for Apple
Silicon, x86_64 for Intel:
3. Authenticate
Log in as yourself. If your ADC is itself an impersonated service account, that account — not you — becomes the identity doing the impersonation, and it will not hold the grant above.
4. Write the config file
See Configuration for every key.
5. Check it worked
Every environment should pass. Fix anything that fails before touching Claude Desktop — a server that cannot authenticate still starts, and then every tool call errors.
6. Edit the Claude Desktop config
Settings → Developer → Edit Config opens it, or edit it directly:
(Settings → Connectors lists hosted connectors; a local server like this one is not added there.)
The file usually already exists and holds your Desktop preferences. Add
mcpServers as one more top-level key — do not replace the file, or you will
lose those settings:
Replace /Users/YOU/.local/bin/uvx with what which uvx printed. On Windows
the path looks like C:\\Users\\YOU\\.local\\bin\\uvx.exe — backslashes doubled
in JSON. @latest makes each launch pick up new releases.
Check it still parses before restarting — a stray comma disables every server, silently. This uses only what ships with macOS:
7. Restart Claude Desktop
Quit it fully (Cmd-Q, not just closing the window) and reopen. Then ask
"list the configured environments" — it should answer from list_environments.
If it does not appear, the logs are in ~/Library/Logs/Claude/
(mcp-server-platform-mcp.log). ENOENT there means the command path is
wrong.
Why not a key file?
You can skip steps 2–3 by pointing GOOGLE_APPLICATION_CREDENTIALS (in the
server's env block) at a downloaded service-account key. Think twice: a key
is a long-lived credential sitting on a laptop, and the production read-only
account can read every log, metric and billing row in that project.
application-default login issues short-lived tokens tied to a person, and
removing one grant revokes that person alone.
Observability
Every tool call appends one JSON line to ~/.local/state/platform-mcp/audit.jsonl:
Free-text arguments are recorded by name only — a Cloud Logging filter can carry
user ids from the logs being searched, and the audit file must not become a
second copy of that. Set PLATFORM_MCP_AUDIT_LOG to another path, or to off.
Diagnostic logs go to stderr (PLATFORM_MCP_LOG_LEVEL to adjust); in stdio
transport stdout carries the protocol, so nothing else may be written there. In
Claude Code, read them with claude --debug=mcp.
For a record that does not depend on this server at all, enable Data Access audit logs in GCP for the read-only service accounts. Token minting already appears in Admin Activity logs without any configuration.
Development
The suite runs against an in-memory MCP client — no network and no GCP
credentials — and covers environment resolution, the tool contract,
annotations, error translation and the audit log. The only subprocess is
bash -n over the packaged setup script, which is skipped where bash is absent.
The setup script lives at src/platform_mcp/scripts/ because it ships as
package data; platform-mcp setup runs it from wherever the package is
installed, so the quickstart needs no checkout.
Notes
- All tools cap result counts and truncate long payloads to stay token-friendly.
- GCP clients are built lazily and cached per environment, so switching between staging and production mid-conversation costs one client construction each.
- Cost recommenders are zonal/regional;
list_cost_recommendationsauto-discovers the locations where you have resources (via Asset Inventory) and fans out, skipping locations and recommenders that are empty or unavailable. It reportsskipped_callsand fails loudly if it cannot discover any location, because "I could not look" and "there is nothing to save" must not look alike. get_cost_breakdownuses parameterized BigQuery queries with a whitelisted set of group-by columns, and filters to the selected environment's project. A billing export covers the whole billing account, so passall_projects=truewhen you want account-wide totals.
License
MIT © 2026 Dimuthu Wickramanayake
来源:README.md,提交 969e4ef
工具
0版本历史
1- v0.4.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分