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.
gcloud and bq 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 and bq commands (including alpha or beta variants for gcloud)
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
without notice:
gcloud authgcloud configgcloud iam service-accountsgcloud initgcloud survey
The following is a complete list of bq commands aren't supported:
bq initbq pyshellbq shell
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
gcloudorbqcommand 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:
projectis a required parameter for Cloud CLI MCP server requests, and represents the project used to interact with the Cloud CLI Execution API. Note that theprojectparameter is unrelated to the--projector--billing-projectflags that are set in the actualgcloudcommand, or the--project_idand--quota_project_idflags forbqcommands 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
- 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.
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud CLI Execution API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud CLI Execution API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.
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:
-
Make MCP tool calls:
MCP Tool User (
roles/mcp.toolUser)
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 the following tools:
run_gcloud_commandrun_bq_command
To view details of available MCP tools and their descriptions for the Cloud CLI MCP server, see the Google Cloud SDK MCP reference.
Differences between run_bq_command and the BigQuery MCP server
run_bq_command exposes the BigQuery CLI (bq) surface
within the Cloud CLI remote MCP server. The tool can run
BigQuery SQL commands and enable administrative and operational tasks
to be performed through natural language prompts. BigQuery also
provides a separate MCP server for
standard data analysis. Each tool surface is designed for distinct use cases:
run_bq_command: Userun_bq_commandwhen building AI agents for advanced administrative and operational workflows, such as managing slot reservations, scheduling queries, managing table snapshots, or troubleshooting and cancelling jobs.- BigQuery MCP server: Use the BigQuery MCP server when building AI agents that use standard SQL execution tools to drive data analysis, metadata discovery, and data modification.
The following table shows additional differences between the two tool surfaces:
| Feature | BigQuery MCP Server | run_bq_command |
|---|---|---|
| Availability | Generally Available | Preview |
| Usage | Data analysis and data modification | Advanced job and resource administration |
| Target users | Business analysts, data scientists, SQL developers | BigQuery administrators, DBAs, Data platform and DevOps engineers |
| Primary operations | Standard SQL execution (SELECT, INSERT, UPDATE, DELETE), schema exploration, metadata inspection | Query scheduling (using DTS), cancelling runaway jobs, slot and reservation management, dataset IAM policies, table snapshot/clone operations |
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 for run_gcloud_command
The following are sample use cases for run_gcloud_command in the
Cloud CLI remote MCP server:
Resource Provisioning
When a user sends a natural language prompt to the agent, the agent generates
a command using the corresponding MCP tool (run_gcloud_command for gcloud
commands or run_bq_command for bq commands). Cloud CLI
then executes the command.
Sample Prompt:
"Create a new VPC network named my-network in the project
projects/my-project. Then, create a firewall rule allowing
internal TCP traffic on port 8080."
Workflow:
The agent calls the
run_gcloud_commandtool with command"gcloud compute networks create my-network --project=projects/my-project --subnet-mode=auto", "project": "projects/my-project".The agent calls the
run_gcloud_commandtool with command"gcloud compute firewall-rules create allow-internal-8080 --project=projects/my-project --network=my-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/my-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", project: "my-project".
Sample use cases for run_bq_command
The following are sample use cases for run_bq_command in the
Cloud CLI remote MCP server:
Manage datasets in BigQuery
You can also use the MCP server to run queries and manage datasets in BigQuery.
Sample Prompt: "List all datasets in the project
projects/my-project, and then create a new dataset named
my_new_dataset in the US location."
Workflow:
The agent calls the
run_bq_commandtool with command"bq ls --datasets=true --project_id=my-project", "project": "projects/my-project".The agent calls the
run_bq_commandtool with command"bq mk --dataset --location=us --project_id=my-project my_new_dataset", "project": "projects/my-project".
Troubleshoot and cancel long-running jobs
An agent inspects running BigQuery jobs to identify resource bottlenecks, diagnose failed queries, cancel long-running jobs, and extract execution details for performance recommendations.
Sample Prompt:
"Check if there are any long-running or resource-intensive queries currently
executing in project my-data-project. If bqujob_12345 has been running for
over 30 minutes, cancel it and show details."
Workflow:
The agent calls
run_bq_commandwith command"bq ls -j --all --project_id=my-data-project", "project": "projects/my-data-project".The agent inspects the job list and calls run_bq_command with command:
"bq show -j bqujob_12345 --project_id=my-data-project", "project": "projects/my-data-project".The agent calls run_bq_command with command:
"bq cancel bqujob_12345 --project_id=my-data-project", "project": "projects/my-data-project".
Schedule queries
An agent configures scheduled query executions through the BigQuery Data Transfer Service integration in the BigQuery CLI to automate data refreshes.
Sample prompt:
"Schedule a daily query at 06:00 UTC to refresh the daily_sales_summary table
in dataset sales_ds for project my-data-project."
Workflow:
- The agent calls
run_bq_commandwith command:"bq query --project_id=my-data-project --use_legacy_sql=false --destination_table=sales_ds.daily_sales_summary --display_name='Daily Sales Refresh' --schedule='every 24 hours' 'SELECT date, SUM(amount) as total FROM sales_ds.transactions GROUP BY date'", "project": "projects/my-data-project".
Capacity analysis and reservation adjustment
An agent analyzes existing slot reservations across top consuming projects and updates slot assignments to manage compute capacity.
Sample prompt:
"List all BigQuery reservations in region us-central1 for project
my-admin-project and update the slot allocation for the prod-analytics
reservation to 500 slots."
Workflow:
The agent calls run_bq_command with command:
"bq ls --reservation --project_id=my-admin-project --location=us-central1", "project": "projects/my-admin-project".The agent calls run_bq_command with command:
"bq update --project_id=my-admin-project --reservation --slots=500 prod-analytics --location=us-central1", "project": "projects/my-admin-project".
Manage table snapshots and clones
An agent creates point-in-time snapshots of critical production tables, or provisions table clones for development and testing.
Sample prompt:
"Create a table snapshot of production_db.orders named
production_db.orders_snapshot_20260720 in project my-data-project."
Workflow:
The agent calls run_bq_command with command:
"bq cp --project_id=my-data-project --snapshot production_db.orders production_db.orders_snapshot_20260720", "project": "projects/my-data-project".
Dataset access and IAM permission control
An agent inspects dataset access controls and updates dataset permissions to grant or revoke access for specified principals.
Sample prompt:
"Show the current access configuration for dataset finance_ds in project
my-data-project."
Workflow:
The agent calls
run_bq_commandwith command:"bq show --format=prettyjson my-data-project:finance_ds", "project": "projects/my-data-project".The agent updates the access JSON definition and calls
run_bq_commandwith command:"bq update --source=access_update.json my-data-project:finance_ds", "project": "projects/my-data-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.
MCP request routing to Model Armor
Model Armor is available in certain regions. When Model Armor is enabled and you use an MCP server in a jurisdiction that Model Armor doesn't support, the routing behavior of the call might be different for different MCP servers and might break data residency compliance for in-use and in-transit data. For more information about the behavior of individual MCP servers, see Model Armor supported products.Enable Model Armor
You must enable Model Armor APIs before you can use Model Armor.
Console
Enable the Model Armor API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.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:
In the Google Cloud console, 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.
-
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
LOCATIONwith 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
- Read the Google Cloud SDK MCP reference documentation.
- Learn more about Google Cloud MCP servers.