SafetyCard Request a review

gcloud MCP

Google Cloud MCP servers wrapping gcloud CLI, observability, storage

github.com/googleapis/gcloud-mcp · 2026-10-03 · 238728f

Defense-in-depth score

1.0 / 10

As shipped, this server lets the model run almost any gcloud command with the user's full Google Cloud credentials, with no read-only mode, no confirmation, no risk annotations and no timeouts. The only built-in restriction is a short denylist of interactive commands (SSH, serial console), and it is not a strict boundary. The dominant risk is a prompt-injected model deleting resources, changing IAM, or exfiltrating data and tokens unattended; run it only under a narrowly scoped, impersonated service account. The sibling storage server in this repo is safer by default (no overwrite or delete tools unless enabled).

Safest setup

gcloud MCP keeps credentials in gcloud's own store, runs commands without a shell, and logs every call's arguments. Beyond that the defaults are weak: the model can run almost any gcloud command with your full account, with no read-only mode, approval step or time limit. The safest setup puts the boundary in Google Cloud IAM and builds containment around the server.

SetupHowWhat it gives you
A narrowly scoped service accountImpersonate a service account in one project with a read-only or task-specific role and no IAM admin or key-creation permissionsGoogle Cloud itself refuses anything outside that role, including changes to its own access C1
Its own gcloud configurationGive the server a separate gcloud configuration directory that holds only that service accountSettings the model changes stay out of your own gcloud setup, and your personal credentials stay out of reach C6
A command allowlist--config <absolute path> to a JSON file whose allow list names only the command groups the task needsThe model is held to a shorter list of command groups, while the role stays the boundary that holds C3
Per-call approval in your hostSet your MCP host to ask before every run_gcloud_command callA person sees each gcloud command before it runs with your cloud authority C2
Its own container or VMRun the server in a container or VM with no other credentials and outbound access limited to Google Cloud APIsLocal files stay out of reach, data has a narrower path out, and stopping the container ends any gcloud process still running C4
The call logKeep the default info level for LOG_LEVEL and have the host store the server's stderr where the agent can't writeA timestamped record of every command the server ran C9

Approving with confidence

  • Read each prompt and approve calls one at a time; every call uses the same tool, so the gcloud command in the arguments is what tells a list from a delete.
  • Commands that change IAM, gcloud config or components, or copy data to a bucket, are worth a closer look before approving.

Handling data

  • The stderr log holds every command's full arguments unredacted; store it like other sensitive logs.
  • Command output, including tokens or secret values a command prints, goes to the model as is, so treat transcripts like the data the account can read.

Key gaps (5)

  1. The model can change IAM policy for the account it runs as, or mint service-account keys, because no IAM or auth command group is restricted by default (C1-SELFESC). C1 · Identity & least privilege
  2. Every command runs with the user's full ambient gcloud authority across all reachable projects (C1 blast radius L0). C1 · Identity & least privilege
  3. Model-chosen gcloud commands run unsandboxed as the user, with the user's credentials, and can deploy code that executes remotely (C4 blast radius L0). C4 · Code-execution isolation
  4. A hijacked session can leak data and credentials and take irreversible actions in GCP with no human step (C5-WORSTCASE). C5 · Untrusted input blast radius
  5. The model can point gcloud's component manager at an arbitrary repository and install code that then runs as the user with their credentials (C7 blast radius L0; gcloud behaviour inferred). C7 · Third-party extensions

Criteria

C1 Identity & least privilege

0.00 / 1.00

The server runs every gcloud command with whatever account is active in the user's local gcloud installation, passing its full environment to the gcloud process, and nothing in the server narrows that authority. The model can also switch identity per call with global flags such as --impersonate-service-account or --account, and nothing stops it from changing IAM policy, including the policy that governs its own account. The README tells operators to impersonate a limited service account, but that is manual hardening outside the code.

C2 Approval gates

0.00 / 1.00

The server exposes one tool, run_gcloud_command, that covers every read and every write in Google Cloud, with no risk annotations, no dry-run, and no read-only mode, so the host gets no signal to separate a harmless list from a project deletion. There is no server-side confirmation step. A wrongly approved or unapproved call can delete resources, change IAM, or deploy code, much of it irreversibly.

C3 Tool & action scoping

0.25 / 1.00

The tool takes an argument array and runs gcloud without a shell, which rules out shell injection, and it parses each command with gcloud's own linter before checking it against a short default denylist of interactive commands (SSH, serial port, `interactive`, `meta`). Everything else, including IAM, secrets, deletes, deployments and local file copies, is allowed by default. Neither the denylist nor the operator allowlist is a strict boundary. An opt-in allowlist file is available but is off by default.

C4 Code-execution isolation

0.00 / 1.00

Model-written arguments are run by the gcloud CLI as a child process of the server, as the same OS user, with the full environment and no sandbox. gcloud is a general tool: through it the model can copy local files anywhere, run scp, install components, and push code that runs remotely (VM startup scripts, Cloud Build, Cloud Run and Functions deploys) with the user's credentials. Nothing in the server isolates or limits any of this.

C5 Untrusted input blast radius

0.00 / 1.00

Whatever gcloud prints, including log entries, resource metadata, labels and object contents that other people can write, goes back to the model as plain text with no marking of where it came from. The tool description itself contains directives to the model, such as preferring this tool over any other. There is no read-only or no-egress mode, so a hijacked model can read sensitive data, send it out (for example by copying it to an external bucket), and delete resources without any human step.

C6 Memory, context & configuration integrity

0.23 / 1.00

The server keeps no memory and reads no files from the workspace; its only configuration is an absolute-path file chosen by the operator. However, the model can persistently rewrite the user's own gcloud configuration through `gcloud config set`, for example redirecting API endpoints, switching the account, or setting service-account impersonation. Those changes survive the session and silently change every later gcloud call, by the agent and by the human. The only trace is the argument line in the server's stderr log.

C7 Third-party extensions

0.00 / 1.00

The server itself loads no plugins or remote code. But because it exposes the whole gcloud CLI and does not restrict the `components` group, the model can add a component repository at an arbitrary URL and install components from it, which gcloud then runs with the user's credentials. Nothing asks the user, pins versions, or confines what is installed. On package-manager installs of gcloud, the component manager may be disabled.

C8 Secrets & sensitive-data protection

0.05 / 1.00

The server holds no keys of its own and leaves credentials in gcloud's credential store, which is a good start. But nothing keeps credentials or secret values out of the model's context: `gcloud auth print-access-token`, `secrets versions access` and similar commands return their output verbatim, and local credential files can be copied out with `gcloud storage cp`. There is no redaction anywhere; the server logs every command's arguments to stderr, but not outputs, and sends no telemetry.

C9 Audit & traceability

0.38 / 1.00

Each tool call writes a timestamped line to stderr with the full argument list before gcloud runs, and errors are logged. The record lacks the exit code or result, and denied commands are not logged at all. The logs go wherever the host stores the server's stderr, outside the server's control, and the agent's own gcloud access could in principle overwrite local files. There is no actor attribution beyond the tool name.

C10 Limits & kill switch

0.07 / 1.00

The server puts no bounds on its own work: gcloud processes run without a timeout or output-size cap, and calls are not rate- or concurrency-limited. The only limits are gcloud flags like --limit, which the model may choose to use. Streaming commands can run indefinitely, and on shutdown the server closes and exits without killing a running gcloud child.