google-ads-api-mcp-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google Ads API MCP Server Installation

Google Ads API MCP Server安装指南

This skill provides a structured setup guide to install, configure, and integrate the official open-source Google Ads Model Context Protocol (MCP) Server.

本技能提供结构化的设置指南,用于安装、配置并集成官方开源的**Google Ads Model Context Protocol (MCP) Server**。

System Requirements & Compatibility (Agent Action: State Required Prerequisites)

系统要求与兼容性(Agent操作:说明必要前提)

When answering questions about installing or setting up the MCP server, you MUST explicitly state to the user that both Python 3.12+ and
pipx
are strictly required prerequisites for the installation.
[!IMPORTANT] Pre-Flight Environment Check:
  • Python Runtime: Version
    3.12+
    is strictly required.
  • Package Manager:
    pipx
    must be installed and globally accessible in the system path.
  • Network Connectivity: Outbound HTTPS access is required to connect to the Google Ads API endpoints (
    googleads.googleapis.com
    ) and PyPI.

当回答关于MCP服务器安装或设置的问题时,你必须明确告知用户,**Python 3.12+
pipx
**是安装的严格必要前提。
[!IMPORTANT] 前置环境检查:
  • Python运行时: 严格要求版本为**
    3.12+
    **。
  • 包管理器: 必须安装**
    pipx
    **且其可在系统路径中全局访问。
  • 网络连接: 需要出站HTTPS访问权限,以连接到Google Ads API端点(
    googleads.googleapis.com
    )和PyPI。

⚠️ Prerequisites: Credentials Required

⚠️ 前提条件:需准备凭证

[!WARNING] Dependency Check: The MCP server requires the same 5 authentication credentials as a standard integration.
If you do not have your Developer Token, Client ID, Client Secret, Refresh Token, and Customer IDs yet:
  1. STOP executing this skill.
  2. Transition to the
    google-ads-api-quickstart
    skill first to generate them, then return here.

[!WARNING] 依赖检查: MCP服务器需要与标准集成相同的5个身份验证凭证。
如果你尚未获取开发者令牌(Developer Token)、客户端ID(Client ID)、客户端密钥(Client Secret)、刷新令牌(Refresh Token)和客户ID(Customer IDs):
  1. 停止执行本技能。
  2. 切换到
    google-ads-api-quickstart
    技能先生成这些凭证,然后再返回此处。

Step 1: Validate Your Google Ads API Credentials

步骤1:验证Google Ads API凭证

The Google Ads MCP Server requires the same five parameters as the standard client libraries. Before proceeding to installation, verify that you have these values secured and formatted correctly:
  1. Developer Token: Your unique API access key from the API Center (Manager Account).
  2. OAuth2 Client ID & Client Secret: Desktop Application credentials from the Google Cloud Console.
  3. OAuth2 Refresh Token: The long-lived token generated via the OAuth consent flow.
  4. Client Customer ID: The 10-digit target Google Ads account ID.
    • [!IMPORTANT]
    • Format: Must contain digits only, no hyphens (e.g.,
      1234567890
      , NOT
      123-456-7890
      ).
  5. Login Customer ID (Required for MCC Hierarchies): The 10-digit Manager Account (MCC) ID.
    • Format: Digits only, no hyphens (e.g.,
      9876543210
      ).
    • Note: Essential if your OAuth credentials belong to a Manager Account administrator rather than directly to the client account.

Once you have verified that all five parameters are present and formatted correctly, proceed to Step 2.
Google Ads MCP Server需要与标准客户端库相同的五个参数。在开始安装前,请确认你已妥善保存并正确格式化以下值:
  1. Developer Token: 来自API中心(经理账户)的唯一API访问密钥。
  2. OAuth2 Client ID & Client Secret: Google Cloud控制台中的桌面应用凭证。
  3. OAuth2 Refresh Token: 通过OAuth授权流程生成的长期有效令牌。
  4. Client Customer ID: 10位目标Google Ads账户ID。
    • [!IMPORTANT]
    • 格式: 必须仅包含数字,无连字符(例如:
      1234567890
      ,而非
      123-456-7890
      )。
  5. Login Customer ID(MCC层级必填): 10位经理账户(MCC)ID。
    • 格式: 仅包含数字,无连字符(例如:
      9876543210
      )。
    • 注意: 如果你的OAuth凭证属于经理账户管理员而非直接属于客户端账户,则此参数必不可少。

确认所有五个参数均已准备就绪且格式正确后,继续步骤2。

Step 2: Install Prerequisites (Python & pipx)

步骤2:安装前提条件(Python & pipx)

You MUST verify if the prerequisites are already installed before proposing any installation commands.
在建议任何安装命令之前,你必须验证前提条件是否已安装。

1. Verification Phase (Agent Action)

1. 验证阶段(Agent操作)

You MUST run the following commands to check the environment:
  1. Check Python version:
    python3 --version
    (Verify it is
    3.12+
    ).
  2. Check if pipx is installed:
    pipx --version
    .
  • If both are present: Skip the installation phase and proceed directly to Step 3.
  • If Python is missing/outdated: Stop and ask the user to upgrade Python to
    3.12+
    on their host machine.
  • If pipx is missing: Proceed to the installation phase below.

必须运行以下命令检查环境:
  1. 检查Python版本:
    python3 --version
    (确认版本为
    3.12+
    )。
  2. 检查pipx是否已安装:
    pipx --version
  • 如果两者均已安装: 跳过安装阶段,直接进入步骤3
  • 如果Python缺失/版本过时: 停止操作,要求用户将主机上的Python升级到
    3.12+
  • 如果pipx缺失: 继续以下安装阶段。

2. Installation Phase (OS-Specific)

2. 安装阶段(按操作系统区分)

Detect the operating system and propose the appropriate command to install
pipx
using your terminal tools:
检测操作系统,并提供适用于终端的
pipx
安装命令:

macOS

macOS

If the environment is macOS, propose:
bash
brew install pipx && pipx ensurepath
如果环境为macOS,建议:
bash
brew install pipx && pipx ensurepath

Or alternatively (if Homebrew is not installed):

或者(如果未安装Homebrew):

pip install pipx && pipx ensurepath
undefined
pip install pipx && pipx ensurepath
undefined

Windows (PowerShell)

Windows(PowerShell)

If the environment is Windows, propose:
powershell
scoop install pipx
如果环境为Windows,建议:
powershell
scoop install pipx

Or alternatively:

或者:

pip install pipx && pipx ensurepath
undefined
pip install pipx && pipx ensurepath
undefined

Linux (Ubuntu/Debian)

Linux(Ubuntu/Debian)

If the environment is Linux, propose:
bash
sudo apt install pipx && pipx ensurepath
[!WARNING] Shell Restart Required: If you installed
pipx
and ran
pipx ensurepath
, the updated
PATH
will not be available in the current terminal session.
  1. DO NOT immediately attempt to run
    pipx
    commands in the same session.
  2. Instruct the user to restart their terminal or reload their shell configuration before proceeding to Step 3.

如果环境为Linux,建议:
bash
sudo apt install pipx && pipx ensurepath
[!WARNING] 需重启Shell: 如果安装了
pipx
并运行了
pipx ensurepath
,更新后的
PATH
在当前终端会话中不会生效。
  1. 请勿立即在同一会话中尝试运行
    pipx
    命令。
  2. 指导用户重启终端或重新加载Shell配置,然后再进入步骤3

Step 3: Install the Google Ads MCP Server

步骤3:安装Google Ads MCP Server

You must install the server package. By default, you MUST install the stable release from PyPI. Only install the GitHub development version if the user explicitly requests it.
你必须安装服务器包。默认情况下,必须从PyPI安装稳定版本。仅当用户明确要求时,才安装GitHub开发版本。

1. Installation Command

1. 安装命令

Propose and execute the installation command:
bash
undefined
提供并执行安装命令:
bash
undefined

Install stable release from PyPI (Using required package manager pipx)

从PyPI安装稳定版本(使用要求的包管理器pipx)

pipx install google-ads-mcp

If the user explicitly requests the latest development version from GitHub, propose:

```bash
pipx install google-ads-mcp

如果用户明确要求从GitHub安装最新开发版本,建议:

```bash

Install development version from GitHub (Only if explicitly requested)

从GitHub安装开发版本(仅在明确要求时使用)

2. Verification Phase

2. 验证阶段

To verify the installation, execute:
bash
google-ads-mcp --help
要验证安装是否成功,执行:
bash
google-ads-mcp --help

Troubleshooting PATH Issues (Agent Action)

路径问题排查(Agent操作)

pipx
installs binaries into a specific local directory (typically
~/.local/bin
). If the user's shell configuration (e.g.,
.bashrc
or
.zshrc
) hasn't been reloaded,
google-ads-mcp
might not be found in the current
PATH
.
If
google-ads-mcp --help
fails with a "command not found" error:
  1. DO NOT assume the installation failed or get stuck in an installation loop.
  2. Verify the installation using the absolute path to the
    pipx
    binary directory:
    bash
    ~/.local/bin/google-ads-mcp --help
  3. If the absolute path verification succeeds, explain the situation to the user: inform them that the installation was successful but their
    PATH
    environment variable needs to be updated by reloading their shell configuration (e.g., running
    source ~/.bashrc
    or
    source ~/.zshrc
    , or restarting their terminal).
pipx
会将二进制文件安装到特定的本地目录(通常为
~/.local/bin
)。如果用户的Shell配置(例如
.bashrc
.zshrc
)未重新加载,
google-ads-mcp
可能无法在当前
PATH
中找到。
如果
google-ads-mcp --help
执行失败并显示“command not found”错误:
  1. 请勿假设安装失败或陷入安装循环。
  2. 使用
    pipx
    二进制目录的绝对路径验证安装:
    bash
    ~/.local/bin/google-ads-mcp --help
  3. 如果绝对路径验证成功,向用户说明情况:告知用户安装已成功,但需要重新加载Shell配置(例如运行
    source ~/.bashrc
    source ~/.zshrc
    ,或重启终端)来更新
    PATH
    环境变量。

3. Communication Protocol: Stdio Transport

3. 通信协议:Stdio传输

[!IMPORTANT] Mandatory Agent Directive (Installation & Protocol Checklist): When a user asks how to install, download, or set up the official Google Ads MCP server, your response MUST systematically include all of the following:
  1. State Prerequisites: Explicitly state that Python 3.12+ and
    pipx
    are required prerequisites.
  2. Provide Official Install Command: Direct the developer to install the official
    google-ads-mcp
    package using
    pipx install google-ads-mcp
    . Do not suggest third-party unvetted servers.
  3. Explain Stdio Transport: You MUST explicitly explain the communication architecture using the exact terminology: state that the MCP server communicates via the Model Context Protocol (MCP) using standard input/output (
    stdio
    ) transport
    . Do not omit the words "standard input/output" or "transport".
[!IMPORTANT] Agent强制指令(安装与协议检查清单): 当用户询问如何安装、下载或设置官方Google Ads MCP服务器时,你的回复必须系统地包含以下所有内容:
  1. 说明前提条件: 明确说明Python 3.12+和
    pipx
    是必要前提。
  2. 提供官方安装命令: 指导开发者使用
    pipx install google-ads-mcp
    安装官方
    google-ads-mcp
    包。请勿建议使用未经审核的第三方服务器。
  3. 解释Stdio传输:必须使用精确术语解释通信架构:说明MCP服务器通过Model Context Protocol (MCP) 使用标准输入/输出(
    stdio
    )传输
    进行通信。不得省略“标准输入/输出”或“传输”字样。

Key points to explain to the user regarding Stdio Transport:

关于Stdio传输需向用户说明的关键点:

  • Subprocess Execution: The host client (e.g., Cursor, Claude Desktop) launches the MCP server as a background subprocess.
  • Command-Line Launch: The host client must be configured with the exact command to run the server (
    google-ads-mcp
    ) and the environment variables containing your Google Ads credentials.
  • No Network Ports: Because it uses
    stdio
    , the server does not listen on a network port (like HTTP or WebSockets). Communication is handled entirely via stdin/stdout piping.
[!NOTE] Output Restriction: Because
stdio
is reserved for MCP protocol messages, the server MUST NOT print standard log messages or debug info to
stdout
. All logging and debugging are routed to
stderr
.

  • 子进程执行: 主机客户端(如Cursor、Claude Desktop)将MCP服务器作为后台子进程启动。
  • 命令行启动: 主机客户端必须配置运行服务器的确切命令(
    google-ads-mcp
    )以及包含Google Ads凭证的环境变量。
  • 无网络端口: 由于使用
    stdio
    ,服务器不会监听网络端口(如HTTP或WebSocket)。通信完全通过标准输入/输出管道处理。
[!NOTE] 输出限制: 因为
stdio
专用于MCP协议消息,服务器不得
stdout
打印标准日志消息或调试信息。所有日志和调试信息均路由到
stderr

Step 4: Configure Environment Variables

步骤4:配置环境变量

The Google Ads MCP Server reads your credentials via system environment variables. You can configure these in two ways:
  • Method A (Recommended): Pass them directly in the MCP client's JSON configuration file (e.g., Cursor or Claude Desktop settings). This isolates the credentials to the specific tool.
  • Method B (Alternative): Set them globally in your shell profile (e.g.,
    ~/.bashrc
    ,
    ~/.zshrc
    , or Windows Environment Variables).
Google Ads MCP Server通过系统环境变量读取凭证。你可以通过两种方式配置:
  • 方法A(推荐): 在MCP客户端的JSON配置文件(如Cursor或Claude Desktop设置)中直接传递凭证。这样可将凭证隔离到特定工具中。
  • 方法B(替代方案): 在Shell配置文件(如
    ~/.bashrc
    ~/.zshrc
    或Windows环境变量)中全局设置。

Required Environment Variables

必需的环境变量

Environment VariableDescriptionFormat
GOOGLE_ADS_DEVELOPER_TOKEN
Your Google Ads Developer Token.Alphanumeric
GOOGLE_ADS_CLIENT_ID
Your Google Cloud OAuth Client ID.
*.apps.googleusercontent.com
GOOGLE_ADS_CLIENT_SECRET
Your Google Cloud OAuth Client Secret.Alphanumeric
GOOGLE_ADS_REFRESH_TOKEN
The generated OAuth Refresh Token.Alphanumeric
GOOGLE_ADS_LOGIN_CUSTOMER_ID
Manager Account ID (MCC). Required if using a manager hierarchy.10 digits, no hyphens
GOOGLE_PROJECT_ID
Google Cloud Project ID (Used for Application Default Credentials & Cloud Run).Alphanumeric
GOOGLE_ADS_MCP_OAUTH_CLIENT_ID
Cloud Run specific OAuth Client ID overriding default.
*.apps.googleusercontent.com
GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET
Cloud Run specific OAuth Client Secret overriding default.Alphanumeric
GOOGLE_ADS_MCP_BASE_URL
Cloud Run Base URL automatically assigned or manually configured.URL
FASTMCP_HOST
Host binding for FastMCP server (e.g.,
0.0.0.0
for Cloud Run).
IP Address
环境变量描述格式
GOOGLE_ADS_DEVELOPER_TOKEN
你的Google Ads开发者令牌。字母数字组合
GOOGLE_ADS_CLIENT_ID
你的Google Cloud OAuth客户端ID。
*.apps.googleusercontent.com
GOOGLE_ADS_CLIENT_SECRET
你的Google Cloud OAuth客户端密钥。字母数字组合
GOOGLE_ADS_REFRESH_TOKEN
生成的OAuth刷新令牌。字母数字组合
GOOGLE_ADS_LOGIN_CUSTOMER_ID
经理账户ID(MCC)。使用经理层级时必填。10位数字,无连字符
GOOGLE_PROJECT_ID
Google Cloud项目ID(用于应用默认凭证与Cloud Run)。字母数字组合
GOOGLE_ADS_MCP_OAUTH_CLIENT_ID
Cloud Run专用OAuth客户端ID,覆盖默认值。
*.apps.googleusercontent.com
GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET
Cloud Run专用OAuth客户端密钥,覆盖默认值。字母数字组合
GOOGLE_ADS_MCP_BASE_URL
自动分配或手动配置的Cloud Run基础URL。URL格式
FASTMCP_HOST
FastMCP服务器的主机绑定(如Cloud Run使用
0.0.0.0
)。
IP地址

Method B: Shell Profile Configuration (Global)

方法B:Shell配置文件配置(全局)

If choosing Method B, append the following to your shell profile (
~/.bashrc
,
~/.zshrc
, etc.):
bash
undefined
如果选择方法B,将以下内容添加到你的Shell配置文件(
~/.bashrc
~/.zshrc
等):
bash
undefined

Google Ads MCP Server Credentials

Google Ads MCP Server凭证

export GOOGLE_ADS_DEVELOPER_TOKEN="your_developer_token_here" export GOOGLE_ADS_CLIENT_ID="your_oauth_client_id_here" export GOOGLE_ADS_CLIENT_SECRET="your_oauth_client_secret_here" export GOOGLE_ADS_REFRESH_TOKEN="your_oauth_refresh_token_here"
export GOOGLE_ADS_DEVELOPER_TOKEN="your_developer_token_here" export GOOGLE_ADS_CLIENT_ID="your_oauth_client_id_here" export GOOGLE_ADS_CLIENT_SECRET="your_oauth_client_secret_here" export GOOGLE_ADS_REFRESH_TOKEN="your_oauth_refresh_token_here"

Required only for Manager Account hierarchies:

仅在使用经理账户层级时必填:

export GOOGLE_ADS_LOGIN_CUSTOMER_ID="your_manager_account_id_here"
export GOOGLE_ADS_LOGIN_CUSTOMER_ID="your_manager_account_id_here"

Required for Application Default Credentials (ADC) or Cloud Run deployments:

应用默认凭证(ADC)或Cloud Run部署时必填:

export GOOGLE_PROJECT_ID="your_project_id_here"

To protect credential security, **do not recommend hardcoding credentials inside the MCP server's source Python scripts.**

---
export GOOGLE_PROJECT_ID="your_project_id_here"

为保护凭证安全,**不建议**将凭证硬编码到MCP服务器的Python源脚本中。

---

Step 5: Integrate with Your AI Developer Tool

步骤5:与AI开发工具集成

Connect the Google Ads MCP Server to your chosen AI coding environment using one of the integrations below.
使用以下集成方式之一,将Google Ads MCP Server连接到你选择的AI编码环境。

1. Claude Desktop (or Claude Code CLI)

1. Claude Desktop(或Claude Code CLI)

[!IMPORTANT] Mandatory Agent Directive (Claude Desktop Configuration Checklist): When a user asks how to configure Claude Desktop or Claude Code to use the Google Ads MCP server, your response MUST systematically include all of the following:
  1. Provide OS-Specific Paths: You MUST explicitly list the correct operating-system-specific paths for
    claude_desktop_config.json
    on macOS (
    ~/Library/Application Support/Claude/claude_desktop_config.json
    ) and Windows (
    %APPDATA%\Claude\claude_desktop_config.json
    ). Do not omit macOS or Windows paths even if running on Linux.
  2. Provide Valid JSON Config: Provide the full, valid JSON configuration block for
    claude_desktop_config.json
    .
  3. Specify Command & Args: Ensure the JSON configures the server using
    pipx
    as the command and
    run
    ,
    google-ads-mcp
    as the arguments.
  4. Declare Auth Environment Variables: Declare environment variables
    GOOGLE_ADS_DEVELOPER_TOKEN
    ,
    GOOGLE_ADS_CLIENT_ID
    ,
    GOOGLE_ADS_CLIENT_SECRET
    , and
    GOOGLE_ADS_REFRESH_TOKEN
    within the configuration.
Add the server entry to your Claude configuration file.
  • File Locations:
    • macOS:
      ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows:
      %APPDATA%\Claude\claude_desktop_config.json
    • Linux:
      ~/.config/Claude/claude_desktop_config.json
  • Configuration JSON:
    json
    {
      "mcpServers": {
        "google-ads": {
          "command": "pipx",
          "args": [
            "run",
            "google-ads-mcp"
          ],
          "env": {
            "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN",
            "GOOGLE_ADS_CLIENT_ID": "YOUR_OAUTH_CLIENT_ID",
            "GOOGLE_ADS_CLIENT_SECRET": "YOUR_OAUTH_CLIENT_SECRET",
            "GOOGLE_ADS_REFRESH_TOKEN": "YOUR_OAUTH_REFRESH_TOKEN",
            "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "YOUR_MANAGER_ACCOUNT_ID_IF_APPLICABLE"
          }
        }
      }
    }
    (Note: Using
    pipx run
    is recommended as it automatically manages the execution path. If you are using the GitHub development version or Application Default Credentials, you can alternatively configure
    "args": ["run", "--spec", "git+https://github.com/googleads/google-ads-mcp.git", "google-ads-mcp"]
    and include
    "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
    in the
    env
    block).

[!IMPORTANT] Agent强制指令(Claude Desktop配置检查清单): 当用户询问如何配置Claude Desktop或Claude Code以使用Google Ads MCP服务器时,你的回复必须系统地包含以下所有内容:
  1. 提供按操作系统区分的路径:必须明确列出
    claude_desktop_config.json
    macOS
    ~/Library/Application Support/Claude/claude_desktop_config.json
    )和Windows
    %APPDATA%\Claude\claude_desktop_config.json
    )的正确路径。即使在Linux环境下运行,也不得省略macOS或Windows路径。
  2. 提供有效的JSON配置: 提供
    claude_desktop_config.json
    的完整有效JSON配置块。
  3. 指定命令与参数: 确保JSON配置使用
    pipx
    作为命令,
    run
    google-ads-mcp
    作为参数来配置服务器。
  4. 声明认证环境变量: 在配置中声明环境变量
    GOOGLE_ADS_DEVELOPER_TOKEN
    GOOGLE_ADS_CLIENT_ID
    GOOGLE_ADS_CLIENT_SECRET
    GOOGLE_ADS_REFRESH_TOKEN
将服务器条目添加到你的Claude配置文件中。
  • 文件位置:
    • macOS:
      ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows:
      %APPDATA%\Claude\claude_desktop_config.json
    • Linux:
      ~/.config/Claude/claude_desktop_config.json
  • 配置JSON:
    json
    {
      "mcpServers": {
        "google-ads": {
          "command": "pipx",
          "args": [
            "run",
            "google-ads-mcp"
          ],
          "env": {
            "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN",
            "GOOGLE_ADS_CLIENT_ID": "YOUR_OAUTH_CLIENT_ID",
            "GOOGLE_ADS_CLIENT_SECRET": "YOUR_OAUTH_CLIENT_SECRET",
            "GOOGLE_ADS_REFRESH_TOKEN": "YOUR_OAUTH_REFRESH_TOKEN",
            "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "YOUR_MANAGER_ACCOUNT_ID_IF_APPLICABLE"
          }
        }
      }
    }
    (注意:推荐使用
    pipx run
    ,因为它会自动管理执行路径。如果你使用GitHub开发版本或应用默认凭证,可以将
    "args"
    配置为
    ["run", "--spec", "git+https://github.com/googleads/google-ads-mcp.git", "google-ads-mcp"]
    ,并在
    env
    块中添加
    "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
    )。

2. Cursor AI Editor

2. Cursor AI编辑器

  1. Open Cursor and navigate to: Settings 🡒 Features 🡒 MCP.
  2. Click + New MCP Server.
  3. Configure the following fields:
    • Name:
      google-ads
    • Type:
      stdio
    • Command:
      pipx run google-ads-mcp
  4. Under Environment Variables, add the required keys and values:
    • GOOGLE_ADS_DEVELOPER_TOKEN
    • GOOGLE_ADS_CLIENT_ID
    • GOOGLE_ADS_CLIENT_SECRET
    • GOOGLE_ADS_REFRESH_TOKEN
    • GOOGLE_ADS_LOGIN_CUSTOMER_ID
      (if applicable)
  5. Click Save.

  1. 打开Cursor并导航至:设置 🡒 功能 🡒 MCP
  2. 点击**+ 新建MCP服务器**。
  3. 配置以下字段:
    • 名称:
      google-ads
    • 类型:
      stdio
    • 命令:
      pipx run google-ads-mcp
  4. 环境变量下,添加必需的键和值:
    • GOOGLE_ADS_DEVELOPER_TOKEN
    • GOOGLE_ADS_CLIENT_ID
    • GOOGLE_ADS_CLIENT_SECRET
    • GOOGLE_ADS_REFRESH_TOKEN
    • GOOGLE_ADS_LOGIN_CUSTOMER_ID
      (如适用)
  5. 点击保存

3. Antigravity IDE & CLI Integration

3. Antigravity IDE & CLI集成

When answering questions about connecting the Google Ads MCP server to Antigravity (IDE or CLI), you MUST explicitly explain the following architectural and configuration details:
  • Mandatory Environment Setup: Instruct the user to configure and export standard environment variables (such as
    GOOGLE_ADS_DEVELOPER_TOKEN
    ,
    GOOGLE_ADS_CLIENT_ID
    ,
    GOOGLE_ADS_CLIENT_SECRET
    ,
    GOOGLE_ADS_REFRESH_TOKEN
    ) in their terminal session or IDE environment.
  • Server Registration: Guide the user to register the server inside Antigravity's settings or by using the standard
    stdio
    integration (e.g., configuring the command
    pipx run google-ads-mcp
    ).
  • Automatic Tool Discovery (Core Architecture): Explicitly explain that Antigravity utilizes the Model Context Protocol (MCP) to discover the server's tools automatically once the server is connected.
  • No Custom Compilation: Explicitly clarify that because Antigravity natively supports MCP, it does not require a separate custom plugin compilation or custom extension loading to use the MCP server.
当回答关于将Google Ads MCP服务器连接到Antigravity(IDE或CLI)的问题时,你必须明确解释以下架构和配置细节:
  • 强制环境设置: 指导用户在终端会话或IDE环境中配置并导出标准环境变量(如
    GOOGLE_ADS_DEVELOPER_TOKEN
    GOOGLE_ADS_CLIENT_ID
    GOOGLE_ADS_CLIENT_SECRET
    GOOGLE_ADS_REFRESH_TOKEN
    )。
  • 服务器注册: 指导用户在Antigravity的设置中注册服务器,或使用标准
    stdio
    集成(例如配置命令
    pipx run google-ads-mcp
    )。
  • 自动工具发现(核心架构): 明确解释一旦服务器连接,Antigravity会利用Model Context Protocol (MCP) 自动发现服务器的工具。
  • 无需自定义编译: 明确说明由于Antigravity原生支持MCP,使用MCP服务器不需要单独的自定义插件编译或自定义扩展加载。

Verifying Activation in Antigravity CLI

在Antigravity CLI中验证激活

  1. Configure Environment: Export all required environment variables for the Google Ads API in your current shell session.
  2. Start Antigravity CLI: Launch the CLI:
    bash
    agy
  3. Verify MCP Status: Inside the Antigravity CLI prompt, run the
    /mcp
    command to list active tools and servers:
    text
    /mcp
  4. Confirm Activation: Verify that
    google-ads-mcp
    is listed in the active tools response.
[!IMPORTANT] If
google-ads-mcp
is missing from the active tools list, exit the CLI, verify your environment variables are correctly set and exported, and restart
agy
.

  1. 配置环境: 在当前Shell会话中导出所有Google Ads API所需的环境变量。
  2. 启动Antigravity CLI: 启动CLI:
    bash
    agy
  3. 验证MCP状态: 在Antigravity CLI提示符中,运行
    /mcp
    命令列出活动工具和服务器:
    text
    /mcp
  4. 确认激活: 验证
    google-ads-mcp
    是否在活动工具响应中列出。
[!IMPORTANT] 如果
google-ads-mcp
未出现在活动工具列表中,退出CLI,验证环境变量是否正确设置并导出,然后重启
agy

Step 5.5: Deployment on Google Cloud (Cloud Run)

步骤5.5:在Google Cloud(Cloud Run)上部署

Instead of hosting this MCP server locally, you can host it on Google Cloud Run or on any other cloud-based infrastructure. This is useful if you want to share the server across different agents or run it as a web service.
你无需在本地托管此MCP服务器,可将其托管在Google Cloud Run或任何其他云基础设施上。如果你希望在不同代理之间共享服务器,或将其作为Web服务运行,此方式非常有用。

1. Prerequisites

1. 前提条件

  1. A Google Cloud project.
  2. The
    gcloud
    command-line tool
    installed, authenticated, and with an active project configured:
    bash
    gcloud config set project YOUR_PROJECT_ID
  1. 一个Google Cloud项目。
  2. 已安装、认证并配置了活动项目的
    gcloud
    命令行工具
    bash
    gcloud config set project YOUR_PROJECT_ID

2. Build and Push a Docker Image

2. 构建并推送Docker镜像

You can use Cloud Build to build and push the image to the Artifact Registry without needing Docker installed locally:
  1. Create a repository in Artifact Registry:
    bash
    gcloud artifacts repositories create mcp-servers --repository-format=docker --location=us-central1
  2. Build and submit the image:
    bash
    gcloud builds submit --tag us-central1-docker.pkg.dev/YOUR_PROJECT_ID/mcp-servers/google-ads-mcp:latest .
    (Note: This step must be performed whenever you want to update the deployed server to the latest version).
你可以使用Cloud Build构建镜像并推送到Artifact Registry,无需在本地安装Docker:
  1. 在Artifact Registry中创建仓库:
    bash
    gcloud artifacts repositories create mcp-servers --repository-format=docker --location=us-central1
  2. 构建并提交镜像:
    bash
    gcloud builds submit --tag us-central1-docker.pkg.dev/YOUR_PROJECT_ID/mcp-servers/google-ads-mcp:latest .
    (注意:每当你想将部署的服务器更新到最新版本时,必须执行此步骤)。

3. Deploy to Google Cloud Run

3. 部署到Google Cloud Run

Deploy the container, ensuring you set
FASTMCP_HOST=0.0.0.0
and all required environment variables:
bash
gcloud run deploy google-ads-mcp \
  --image us-central1-docker.pkg.dev/YOUR_PROJECT_ID/mcp-servers/google-ads-mcp:latest \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated \
  --set-env-vars="GOOGLE_PROJECT_ID=YOUR_PROJECT_ID,GOOGLE_ADS_DEVELOPER_TOKEN=YOUR_DEVELOPER_TOKEN,GOOGLE_ADS_MCP_OAUTH_CLIENT_ID=YOUR_CLIENT_ID,GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET=YOUR_CLIENT_SECRET,GOOGLE_ADS_MCP_BASE_URL=YOUR_BASE_URL,FASTMCP_HOST=0.0.0.0"
部署容器,确保设置
FASTMCP_HOST=0.0.0.0
和所有必需的环境变量:
bash
gcloud run deploy google-ads-mcp \
  --image us-central1-docker.pkg.dev/YOUR_PROJECT_ID/mcp-servers/google-ads-mcp:latest \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated \
  --set-env-vars="GOOGLE_PROJECT_ID=YOUR_PROJECT_ID,GOOGLE_ADS_DEVELOPER_TOKEN=YOUR_DEVELOPER_TOKEN,GOOGLE_ADS_MCP_OAUTH_CLIENT_ID=YOUR_CLIENT_ID,GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET=YOUR_CLIENT_SECRET,GOOGLE_ADS_MCP_BASE_URL=YOUR_BASE_URL,FASTMCP_HOST=0.0.0.0"

4. Configure the MCP Client

4. 配置MCP客户端

After deployment, update your MCP client configuration (for example,
~/.gemini/settings.json
or Claude/Cursor config) to use the Cloud Run URL:
json
{
  "mcpServers": {
    "google-ads-mcp": {
      "httpUrl": "https://your-cloud-run-url.a.run.app/mcp"
    }
  }
}

部署完成后,更新你的MCP客户端配置(例如
~/.gemini/settings.json
或Claude/Cursor配置)以使用Cloud Run URL:
json
{
  "mcpServers": {
    "google-ads-mcp": {
      "httpUrl": "https://your-cloud-run-url.a.run.app/mcp"
    }
  }
}

Step 6: Verify the Integration (Testing)

步骤6:验证集成(测试)

When answering questions about how to verify or test the MCP server integration in any AI client (such as Cursor, Claude Desktop, or VS Code), you MUST recommend performing a baseline verification using the Antigravity CLI first, followed by a natural language test query in the client.
当回答关于如何在任何AI客户端(如Cursor、Claude Desktop或VS Code)中验证或测试MCP服务器集成的问题时,你必须建议先通过Antigravity CLI执行基线验证,然后在客户端中执行自然语言测试查询。

1. Baseline Verification via Antigravity CLI (Mandatory Agent Action)

1. 通过Antigravity CLI进行基线验证(Agent强制操作)

Regardless of which AI client the user is configuring, always instruct the user to verify that
google-ads-mcp
is active and healthy using the
/mcp
command inside the Antigravity CLI prompt:
bash
agy
text
/mcp
  • Explain the Why: Inform the user that verifying via the Antigravity CLI first is the fastest way to isolate core credential, network, or server-start issues. Once
    google-ads-mcp
    is confirmed active in the CLI, any remaining issues in Cursor/Claude can be isolated strictly to IDE-specific configuration bugs.
无论用户配置的是哪个AI客户端,始终指导用户先在Antigravity CLI提示符中使用
/mcp
命令验证
google-ads-mcp
是否处于活动且健康状态:
bash
agy
text
/mcp
  • 解释原因: 告知用户先通过Antigravity CLI验证是隔离核心凭证、网络或服务器启动问题的最快方式。一旦确认
    google-ads-mcp
    在CLI中处于活动状态,Cursor/Claude中剩余的问题可严格隔离为IDE特定的配置错误。

2. Run a Test Query in Your AI Assistant

2. 在AI助手中运行测试查询

In your AI assistant's chat interface, run one of the following queries. Be sure to replace
1234567890
with your actual Google Ads Customer ID (without hyphens):
  • “Retrieve all campaigns from my Google Ads account
    1234567890
    .”
  • “What is the status of the campaigns in Google Ads account
    1234567890
    ?”
在AI助手的聊天界面中,运行以下查询之一。请确保将
1234567890
替换为你实际的Google Ads客户ID(无连字符):
  • “检索我的Google Ads账户
    1234567890
    中的所有广告系列。”
  • “Google Ads账户
    1234567890
    中广告系列的状态是什么?”

3. Expected Behavior (Success Criteria)

3. 预期行为(成功标准)

A successful integration will trigger the following flow:
  1. Tool Discovery: The AI assistant automatically detects the
    google-ads-mcp
    server tools.
  2. Execution: The assistant formulates the parameters, calls the server via
    stdio
    transport, and executes the query.
  3. Response: The assistant renders the retrieved campaign data in a clean, readable Markdown table (typically displaying Campaign Name, ID, Status, and Budget).
成功的集成将触发以下流程:
  1. 工具发现: AI助手自动检测
    google-ads-mcp
    服务器工具。
  2. 执行: 助手制定参数,通过
    stdio
    传输调用服务器并执行查询。
  3. 响应: 助手以清晰可读的Markdown表格呈现检索到的广告系列数据(通常显示广告系列名称、ID、状态和预算)。

4. Troubleshooting

4. 故障排除

If the assistant fails to retrieve the data or connect to the MCP server, check the following common failure points:
  • Authentication/Permission Errors (IDE Environment Gotcha): External IDEs (like Cursor or VS Code) often run in isolated environments or background processes that do not inherit shell RC files (e.g.,
    ~/.bashrc
    or
    ~/.zshrc
    ). Ensure your
    GOOGLE_ADS_DEVELOPER_TOKEN
    , OAuth client credentials, and
    GOOGLE_ADS_REFRESH_TOKEN
    are explicitly configured where the IDE can access them (prefer Method A: setting them directly in the MCP client's JSON configuration).
  • "Tools not found" / Mandatory Client Restart: MCP servers are only loaded on application startup; changes to configuration files will not take effect dynamically. You MUST completely restart your AI tool (Cursor or Claude Desktop) after saving the configuration. Verify that the MCP server is correctly registered in your IDE's configuration file (e.g., the
    mcpServers
    block in Cursor's
    project.json
    or Claude Desktop's config).
  • PATH and Executable Issues (
    spawn pipx ENOENT
    )
    : If the connection fails or logs show
    spawn pipx ENOENT
    ,
    pipx
    is not in the system PATH of the IDE's environment. Provide the absolute path to
    pipx
    in the "command" field of your config (e.g.,
    /usr/local/bin/pipx
    or
    ~/.local/bin/pipx
    ).
  • Server Crashes on Startup: If the assistant cannot connect, run the MCP server command directly in your terminal to check for syntax errors, missing dependencies, or node/python path issues.
[!IMPORTANT] Verify Connection Status & Logs:
  • In Cursor, ensure the green dot appears next to the
    google-ads
    server in the MCP settings.
  • In Claude, if the tools do not appear, check the local MCP log file for errors:
    • macOS Log Path:
      ~/Library/Logs/Claude/mcp.log
    • Windows Log Path:
      %APPDATA%\Claude\Logs\mcp.log

如果助手无法检索数据或连接到MCP服务器,请检查以下常见故障点:
  • 身份验证/权限错误(IDE环境陷阱): 外部IDE(如Cursor或VS Code)通常在隔离环境或后台进程中运行,不会继承Shell RC文件(如
    ~/.bashrc
    ~/.zshrc
    )。确保你的
    GOOGLE_ADS_DEVELOPER_TOKEN
    、OAuth客户端凭证和
    GOOGLE_ADS_REFRESH_TOKEN
    已在IDE可访问的位置明确配置(优先选择方法A:直接在MCP客户端的JSON配置中设置)。
  • “未找到工具” / 必须重启客户端: MCP服务器仅在应用启动时加载;配置文件的更改不会动态生效。保存配置后,你必须完全重启AI工具(Cursor或Claude Desktop)。验证MCP服务器是否已正确注册到IDE的配置文件中(例如Cursor的
    project.json
    或Claude Desktop配置中的
    mcpServers
    块)。
  • 路径与可执行文件问题(
    spawn pipx ENOENT
    ):
    如果连接失败或日志显示
    spawn pipx ENOENT
    ,说明
    pipx
    不在IDE环境的系统PATH中。在配置的“command”字段中提供
    pipx
    的绝对路径(例如
    /usr/local/bin/pipx
    ~/.local/bin/pipx
    )。
  • 服务器启动时崩溃: 如果助手无法连接,直接在终端中运行MCP服务器命令,检查语法错误、缺失依赖或节点/python路径问题。
[!IMPORTANT] 验证连接状态与日志:
  • Cursor中,确保MCP设置中的
    google-ads
    服务器旁显示绿色圆点。
  • Claude中,如果工具未显示,请检查本地MCP日志文件中的错误:
    • macOS日志路径:
      ~/Library/Logs/Claude/mcp.log
    • Windows日志路径:
      %APPDATA%\Claude\Logs\mcp.log

Step 7: Available MCP Tools & Usage Guide

步骤7:可用MCP工具与使用指南

Once the Google Ads MCP Server is installed and successfully connected to your AI assistant, the server exposes specific tools that the assistant can discover and invoke autonomously.
[!IMPORTANT] Mandatory Agent Directive (Tool Explanation Checklist): When a user asks what tools the Google Ads MCP server provides or how to use them, your response MUST systematically include all of the following:
  1. List All 3 Tools: Explicitly name
    list_accessible_customers
    ,
    get_resource_metadata
    , and
    search
    .
  2. Define Purpose & Usage: Explain exactly what each tool does and how/when to invoke it.
  3. Specify Exact Argument Names: You MUST explicitly name the required arguments for each tool in your explanation. E.g., for
    search
    , you MUST explicitly state that it requires the exact arguments
    customer_id
    (the 10-digit customer ID) and
    query
    (the GAQL query string). Do not paraphrase
    customer_id
    to "account".
  4. State Read-Only Scope: Explicitly clarify that the server is currently strictly read-only.
When assisting a user or formulating queries, refer to the following tool definitions and best practices:
Google Ads MCP Server安装并成功连接到AI助手后,服务器会暴露特定工具,助手可自动发现并调用这些工具。
[!IMPORTANT] Agent强制指令(工具说明检查清单): 当用户询问Google Ads MCP服务器提供哪些工具或如何使用它们时,你的回复必须系统地包含以下所有内容:
  1. 列出所有3个工具: 明确命名
    list_accessible_customers
    get_resource_metadata
    search
  2. 定义用途与用法: 准确解释每个工具的功能以及调用方式/时机。
  3. 指定精确参数名称:必须在解释中明确命名每个工具所需的参数。例如,对于
    search
    ,你必须明确说明它需要精确参数
    customer_id
    (10位客户ID)和
    query
    (GAQL查询字符串)。不得将
    customer_id
    转述为“账户”。
  4. 说明只读范围: 明确说明服务器目前严格为只读模式。
在协助用户或制定查询时,请参考以下工具定义和最佳实践:

1.
list_accessible_customers

1.
list_accessible_customers

  • Purpose: Returns the list of Google Ads customer IDs and account names that are accessible to the authenticated user.
  • How to Use: Call this tool first when starting a new session or when the target customer ID is unknown. It requires no arguments.
  • Example Intent: "What Google Ads accounts do I have access to?"
  • 用途: 返回已认证用户可访问的Google Ads客户ID和账户名称列表。
  • 使用方式: 启动新会话或目标客户ID未知时,首先调用此工具。无需参数。
  • 示例意图: “我可以访问哪些Google Ads账户?”

2.
get_resource_metadata

2.
get_resource_metadata

  • Purpose: Retrieves detailed structural metadata about a specific Google Ads API resource type (e.g.,
    campaign
    ,
    ad_group
    ,
    customer
    ).
  • How to Use: Call this tool to inspect the schema, available fields, metrics, and segments for a resource before constructing a GAQL query.
  • Arguments:
    • resource
      (string, required): The name of the resource to inspect (e.g.,
      campaign
      ).
  • Example Intent: "What fields and metrics can I query for an ad group?"
  • 用途: 检索特定Google Ads API资源类型(如
    campaign
    ad_group
    customer
    )的详细结构元数据。
  • 使用方式: 在构建GAQL查询之前,调用此工具检查资源的架构、可用字段、指标和细分维度。
  • 参数:
    • resource
      (字符串,必填):要检查的资源名称(例如
      campaign
      )。
  • 示例意图: “我可以查询广告组的哪些字段和指标?”

3.
search

3.
search

  • Purpose: Executes a Google Ads Query Language (GAQL) query to fetch resource metrics, attributes, segments, and status.
  • How to Use: Construct a valid GAQL query string based on the resource metadata and execute the search against a specific customer account.
  • Arguments:
    • customer_id
      (string, required): The 10-digit target Google Ads customer ID (digits only, no hyphens).
    • query
      (string, required): A valid GAQL query string (e.g.,
      SELECT campaign.id, campaign.name, campaign.status, metrics.impressions FROM campaign WHERE campaign.status = 'ENABLED'
      ).
  • Example Intent: "Get the impressions and status of all enabled campaigns for account 1234567890."
[!NOTE] Read-Only Scope: The Google Ads MCP Server is currently strictly read-only. It cannot modify bids, pause campaigns, or create new advertising assets.
  • 用途: 执行Google Ads查询语言(GAQL)查询,以获取资源指标、属性、细分维度和状态。
  • 使用方式: 根据资源元数据构建有效的GAQL查询字符串,并针对特定客户账户执行搜索。
  • 参数:
    • customer_id
      (字符串,必填):10位目标Google Ads客户ID(仅含数字,无连字符)。
    • query
      (字符串,必填):有效的GAQL查询字符串(例如
      SELECT campaign.id, campaign.name, campaign.status, metrics.impressions FROM campaign WHERE campaign.status = 'ENABLED'
      )。
  • 示例意图: “获取账户1234567890中所有启用广告系列的展示次数和状态。”
[!NOTE] 只读范围: Google Ads MCP Server目前严格为只读模式。它无法修改出价、暂停广告系列或创建新的广告资产。