Use the Cloud CLI remote MCP server

This document shows you how to use the Cloud CLI remote Model Context Protocol (MCP) server to connect with AI applications including Gemini CLI, ChatGPT, Claude, and custom applications you are developing.

The Cloud CLI remote MCP server provides a secure environment that lets you send natural language prompts to your AI application to execute command-line interface (CLI) commands on your behalf. Only gcloud commands are supported.

The API for this feature is called Cloud CLI Execution.

The Cloud CLI remote MCP server is enabled when you enable the Cloud CLI Execution API.

Model Context Protocol (MCP) standardizes how large language models (LLMs) and AI applications or agents connect to external data sources. MCP servers let you use their tools, resources, and prompts to take actions and get updated data from their backend service.

What's the difference between local and remote MCP servers?

Local MCP servers
Typically run on your local machine and use the standard input and output streams (stdio) for communication between services on the same device.
Remote MCP servers
Run on the service's infrastructure and offer an HTTP endpoint to AI applications for communication between the AI MCP client and the MCP server. For more information about MCP architecture, see MCP architecture.

Google and Google Cloud remote MCP servers

Google and Google Cloud remote MCP servers have the following features and benefits:

  • Simplified, centralized discovery
  • Managed global or regional HTTP endpoints
  • Fine-grained authorization
  • Optional prompt and response security with Model Armor protection
  • Centralized audit logging

For information about other MCP servers and information about security and governance controls available for Google Cloud MCP servers, see Google Cloud MCP servers overview.

Restrictions and Guidelines

Before you begin working with the Cloud CLI remote MCP server, review the following restrictions and guidelines:

Supported commands

The Cloud CLI MCP server doesn't support certain gcloud command groups (and their alpha or beta variants) due to security standards and inapplicability. The following list shows a few example gcloud commands that aren't supported; this list is non-exhaustive and subject to the addition or removal of commands.

  • gcloud auth
  • gcloud config
  • gcloud iam service-accounts
  • gcloud init
  • gcloud survey

Organization policy enforcement

Commands executed through the remote MCP server are run with the permissions of the authenticated caller identity. Standard IAM permissions and Organization Policy Service constraints are strictly enforced against downstream target resources.

Guidelines for agent developers

  • Principal and IAM permissions: The principal that interacts with the Cloud CLI Execution API is the same principal that interacts with Google Cloud APIs during gcloud command execution. Because the Cloud CLI MCP server can call many Google Cloud APIs, we recommend that you follow the security principle of least privilege and assign the minimum required permissions for your use case to the user, agent identity, or service account calling the Cloud CLI MCP server.

  • Selecting projects: project is a required parameter for Cloud CLI MCP server requests, and represents the project used to interact with the Cloud CLI Execution API. Note that the project parameter is unrelated to the --project or --billing-project flags that are set in the actual gcloud command or commands that the Cloud CLI Execution API executes.

    We recommend updating system prompts or skills for your agent so that it selects the correct project for running Cloud CLI MCP server requests.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Cloud CLI Execution API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Cloud CLI Execution API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

Required roles

To get the permissions that you need to use the Cloud CLI MCP server, ask your administrator to grant you the following IAM roles on the project where you want to use the Cloud CLI MCP server:

For more information about granting roles, see Manage access to projects, folders, and organizations.

These predefined roles contain the permissions required to use the Cloud CLI MCP server. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to use the Cloud CLI MCP server:

  • Make MCP tool calls: mcp.tools.call

You might also be able to get these permissions with custom roles or other predefined roles.

Authentication and authorization

The Cloud CLI remote MCP server uses the OAuth 2.0 protocol with Identity and Access Management (IAM) for authentication and authorization. All Google Cloud identities are supported for authentication to MCP servers.

The Cloud CLI remote MCP server doesn't accept API keys.

We recommend that you create a separate identity for agents that are using MCP tools so that access to resources can be controlled and monitored. For more information about authentication, see Authenticate to MCP servers.

Cloud CLI OAuth scopes

OAuth 2.0 uses scopes and credentials to determine if an authenticated principal is authorized to take a specific action on a resource. For more information about OAuth 2.0 scopes at Google, see Using OAuth 2.0 to access Google APIs.

The Cloud CLI remote MCP server has the following OAuth scopes:

Scope URI Description
https://www.googleapis.com/auth/cloud-platform View and manage your data across Google Cloud services.

Configure an MCP client to use the Cloud CLI remote MCP server

AI applications and agents, such as Claude or Antigravity, can instantiate an MCP client that connects to a single MCP server. An AI application can have multiple clients that connect to different MCP servers. If your application isn't listed in the client-specific guidance, then you can use the following information to connect from most applications.

In your AI application, look for a way to add or connect to a remote MCP server. For the Cloud CLI remote MCP server, enter the following information as required:

  • Server name: Cloud CLI remote MCP server
  • Server URL or Endpoint: https://cloudcli.googleapis.com/mcp
  • Transport: HTTP
  • Authentication details: your Google Cloud credentials, your OAuth Client ID and secret, or an agent identity and credentials

Redirect URIs

For web-based applications, and some desktop applications, you must allowlist a redirect URI when you create a client ID and secret for authentication. Redirect URIs are used by the authorization server to send tokens to your application. Your application's documentation should specify the redirect URI that you must use. Custom redirect URIs aren't supported.

For application-specific guidance about setting up and connecting to MCP server, see Client-specific guidance.

For more general guidance, see the following resources:

Available tools

The Cloud CLI remote MCP server exposes a single tool:

  • run_gcloud_command

To view details of available MCP tools and their descriptions for the Cloud CLI MCP server, see the Google Cloud SDK MCP reference.

List tools

Use the MCP inspector to list tools, or send a tools/list HTTP request directly to the Cloud CLI remote MCP server. The tools/list method doesn't require authentication.

POST /mcp HTTP/1.1
Host: cloudcli.googleapis.com
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "method": "tools/list",
}

Sample use cases

The following are sample use cases for the Cloud CLI remote MCP server:

Resource Provisioning

When a user sends a natural language prompt to the agent, the agent generates a gcloud CLI command using the MCP tool. Cloud CLI then executes the gcloud CLI command.

Sample Prompt:

"Create a new VPC network named PROD_NETWORK in the project projects/PROJECT. Then, create a firewall rule allowing internal TCP traffic on port 8080."

Workflow:

  1. The agent calls the run_gcloud_command tool with command "gcloud compute networks create PROD_NETWORK --project=projects/PROJECT --subnet-mode=auto", "project": "projects/PROJECT"

  2. The agent calls the run_gcloud_command tool with command "gcloud compute firewall-rules create allow-internal-8080 --project=projects/PROJECT --network=PROD_NETWORK --allow=tcp:8080 --source-ranges=10.0.0.0/8.

Observability & Diagnostics

An agent can inspect environment state and query recent error logs to help troubleshoot issues.

Sample Prompt: "Find the latest 5 error logs for the Compute Engine instance my-web-server in the project projects/PROJECT."

Workflow:

The agent calls the run_gcloud_command tool with command "gcloud logging read \"resource.type=gce_instance AND severity>=ERROR\" --limit=5 --order=DESC" and project "projects/PROJECT".

Optional security and safety configurations

MCP introduces new security risks and considerations due to the wide variety of actions that you can do with the MCP tools. To minimize and manage these risks, Google Cloud offers default settings and customizable policies to control the use of MCP tools in your Google Cloud organization or project.

For more information about MCP security and governance, see AI security and safety.

Use Model Armor

Model Armor is a Google Cloud service designed to enhance the security and safety of your AI applications. It works by proactively screening LLM prompts and responses, protecting against various risks and supporting responsible AI practices. Whether you are deploying AI in your cloud environment, or on external cloud providers, Model Armor can help you prevent malicious input, verify content safety, protect sensitive data, maintain compliance, and enforce your AI safety and security policies consistently across your diverse AI landscape.

When Model Armor is enabled with logging enabled, Model Armor logs the entire payload. This might expose sensitive information in your logs.

Enable Model Armor

You must enable Model Armor APIs before you can use Model Armor.

Console

  1. Enable the Model Armor API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  2. Select the project where you want to activate Model Armor.

gcloud

Before you begin, follow these steps using the Google Cloud CLI with the Model Armor API:

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. Run the following command to set the API endpoint for the Model Armor service.

    gcloud config set api_endpoint_overrides/modelarmor "https://modelarmor.LOCATION.rep.googleapis.com/"

    Replace LOCATION with the region where you want to use Model Armor.

Configure protection for Google and Google Cloud remote MCP servers

To help protect your MCP tool calls and responses you can use Model Armor floor settings. A floor setting defines the minimum security filters that apply across the project. This configuration applies a consistent set of filters to all MCP tool calls and responses within the project.

Set up a Model Armor floor setting with MCP sanitization enabled. For more information, see Configure Model Armor floor settings.

See the following example command:

gcloud model-armor floorsettings update \
--full-uri='projects/PROJECT_ID/locations/global/floorSetting' \
--enable-floor-setting-enforcement=TRUE \
--add-integrated-services=GOOGLE_MCP_SERVER \
--google-mcp-server-enforcement-type=INSPECT_AND_BLOCK \
--enable-google-mcp-server-cloud-logging \
--malicious-uri-filter-settings-enforcement=ENABLED \
--add-rai-settings-filters='[{"confidenceLevel": "MEDIUM_AND_ABOVE", "filterType": "DANGEROUS"}]'

Replace PROJECT_ID with your Google Cloud project ID.

Note the following settings:

  • INSPECT_AND_BLOCK: The enforcement type that inspects content for the Google MCP server and blocks prompts and responses that match the filters.
  • ENABLED: The setting that enables a filter or enforcement.
  • MEDIUM_AND_ABOVE: The confidence level for the Responsible AI - Dangerous filter settings. You can modify this setting, though lower values might result in more false positives. For more information, see Model Armor confidence levels.

Disable scanning MCP traffic with Model Armor

To stop Model Armor from automatically scanning traffic to and from Google MCP servers based on the project's floor settings, run the following command:

gcloud model-armor floorsettings update \
  --full-uri='projects/PROJECT_ID/locations/global/floorSetting' \
  --remove-integrated-services=GOOGLE_MCP_SERVER

Replace PROJECT_ID with the Google Cloud project ID. Model Armor doesn't automatically apply the rules defined in this project's floor settings to any Google MCP server traffic.

Model Armor floor settings and general configuration can impact more than just MCP. Because Model Armor integrates with services like Vertex AI, any changes you make to floor settings can affect traffic scanning and safety behaviors across all integrated services, not just MCP.

What's next