Google Ads MCP Server (Experimental) 标志

Google Ads MCP Server (Experimental)

组织
googleads

This repo contains the source code for running an

发布者googleads
代码仓库google-ads-mcp
语言Python
复刻数
286
星标数
975
可用工具
0
传输类型stdio
分类
许可协议Apache-2.0
链接
  • 将工具接入 AI 工作流

    Google Ads MCP Server (Experimental) 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 975 个星标和 286 个复刻。

Google Ads MCP Server

This repo contains the source code for running an MCP server that interacts with the Google Ads API.

Tools

The server uses the Google Ads API to provide several Tools and Resources for use with LLMs and AI agents.

Tools available

  • search: Retrieves information about the Google Ads account.
  • get_resource_metadata: Retrieves metadata about a Google Ads API resource type, for example "campaign". This is useful to understand the structure of the data and what fields are available for querying.
  • list_accessible_customers: Returns ids of customers directly accessible by the user authenticating the call.

Configuring and Namespacing Tools

The Google Ads MCP server uses the tools_config.yaml to let you selectively enable or disable individual tools or tool categories (namespaces) and customize their namespace prefixes.

A default tools_config.yaml with all tools enabled is bundled with the package, so the server works out of the box with no extra setup. To customize your installation, the server resolves the configuration in the following order:

  1. An explicit path set via the GOOGLE_ADS_MCP_TOOLS_CONFIG environment variable.
  2. A tools_config.yaml file in the current working directory.
  3. The default tools_config.yaml bundled with the package.

If an explicitly requested configuration file (via the environment variable) is missing, or any resolved file is invalid, the server raises an error and fails to start.

Configuration Example:

yaml
namespaces:
  # Option 1: Enable category 'customers' with default prefix -> "customers_list_accessible_customers"
  customers: true

  # Option 2: Enable category 'search' with a custom prefix -> "query_search"
  search: "query"

  # Option 3: Fine-grained control over tools in a category
  metadata:
    enabled: true
    prefix: "metadata"
    enabled_tools:
      - get_resource_metadata: true

Resources available

  • discovery-document: Retrieve the Google Ads API discovery document. Provides the discovery document for the latest version of the Google Ads API, which describes the API surface, including resources, methods, and schemas. Host LLMs should access this resource to understand the structure of the Google Ads API and discover available features.
  • metrics: Retrieve information about the metrics available for reporting in the Google Ads API.
  • segments: Retrieve information about the segments available for reporting in the Google Ads API.
  • release-notes: Retrieve the release notes for the latest version of the Google Ads API.

Notes

  1. The MCP Server will expose your data to the Agent or LLM that you connect to it.
  2. If you have technical issues, please use the GitHub issue tracker.
  3. To help us collect usage data, you will notice an extra header has been added to your API calls: this data is used to improve the product.

Setup instructions

Setup involves the following steps:

  1. Configure Python.
  2. Configure Developer Token.
  3. Enable APIs in your project
  4. Configure Credentials.
  5. Configure your MCP client.

Configure Python

Install pipx.

After a version has been published to PyPI, you can run that exact version instead of following the latest repository state:

shell
pipx run --spec "google-ads-mcp==X.Y.Z" google-ads-mcp

Configure Developer Token (Optional)

If your setup requires a developer token, follow the instructions for Obtaining a Developer Token.

Your developer token must have at least Explorer access to query production accounts. New tokens may be automatically upgraded to Explorer access; if not, you can apply through the API Center. See the access levels documentation for details.

If you see the error "The developer token is only approved for use with test accounts", your token does not yet have access to production accounts. See the access levels documentation for how to request the access level you need.

Enable APIs in your project

Follow the instructions to enable the following APIs in your Google Cloud project:

Configure Credentials

Option 1: Using FastMCP OAuth Proxy

The server supports FastMCP's OAuth proxy feature for dynamic user authentication. This is useful when running the server as a web service.

To enable it, set the following environment variables:

  • GOOGLE_ADS_MCP_OAUTH_CLIENT_ID: Your Google Cloud OAuth 2.0 Client ID.
  • GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET: Your Google Cloud OAuth 2.0 Client Secret.
  • GOOGLE_ADS_MCP_BASE_URL: (Optional) The base URL where the server is accessible (defaults to http://localhost:8080).
  • GOOGLE_ADS_MCP_JWT_SIGNING_KEY: (Optional) Secret key used to sign FastMCP JWT tokens across multiple server instances or deployments.
  • GOOGLE_ADS_MCP_STORAGE_TYPE: (Optional) Storage backend for OAuth state (filetree, redis, firestore, or memory).
  • GOOGLE_ADS_MCP_STORAGE_PATH: (Optional) Directory path for filetree persistent storage.
  • GOOGLE_ADS_MCP_STORAGE_REDIS_URL: (Optional) Redis URL for redis persistent storage.
  • GOOGLE_ADS_MCP_STORAGE_FIRESTORE_PROJECT: (Optional) Google Cloud project for firestore persistent storage. Defaults to the project inferred from Application Default Credentials. Setting it selects the firestore backend even if GOOGLE_ADS_MCP_STORAGE_TYPE is unset.
  • GOOGLE_ADS_MCP_STORAGE_FIRESTORE_DATABASE: (Optional) Firestore database name for firestore persistent storage. Defaults to (default).
  • GOOGLE_ADS_MCP_STORAGE_ENCRYPTION_KEY: (Optional) Encryption key for stored OAuth tokens.
  • GOOGLE_ADS_MCP_STORAGE_DISABLE_ENCRYPTION: (Optional) Set to true to disable token encryption.

The redis and firestore backends need their storage library installed alongside the server: pip install py-key-value-aio[redis] and pip install google-ads-mcp[firestore] respectively.

Once this is enabled, you can authenticate to the API through your MCP client.

When these variables are set, the server automatically switches to the streamable-http transport instead of stdio.

You will need to run the server as a separate process and configure your MCP client to connect to the Streamable HTTP endpoint (for example, http://localhost:8080/mcp).

Local WSL and Podman deployment

This deployment has been tested with rootless Podman in WSL and exposes a single Streamable HTTP endpoint at http://localhost:8080/mcp. Build the image from the repository inside WSL:

shell
podman build --tag localhost/google-ads-mcp:latest --file Dockerfile .

Keep server credentials out of MCP client configuration. The tested Quadlet loads Google Ads and OAuth settings from a private host-side file through EnvironmentFile= and uses a separate named volume for persistent encrypted OAuth state:

ini
[Container]
Image=localhost/google-ads-mcp:latest
PublishPort=127.0.0.1:8080:8080
EnvironmentFile=/absolute/host/path/google-ads-mcp.env
Volume=google-ads-mcp-oauth.volume:/var/lib/google-ads-mcp:rw
ReadOnly=true
NoNewPrivileges=true
DropCapability=all

The environment file and the OAuth-state volume serve different purposes: the volume does not contain the .env file. Keep the environment file outside the repository, restrict it to the service owner, and never commit it. Antigravity and Codex then need only the MCP endpoint and their own OAuth authorization; they do not need the server's Google Ads developer token, OAuth client secret, or signing and storage keys. Publish port 8080 only on the loopback interface when the server is intended for local agents.

The endpoint deliberately keeps stateful Streamable HTTP enabled. It supports legacy MCP 2025 clients that use Mcp-Session-Id and GET SSE as well as MCP 2026 clients that use sessionless POST requests and subscriptions/listen. Do not enable FastMCP's stateless_http option on this shared endpoint; doing so removes the legacy GET channel.

The server runs on FastMCP 4 (fastmcp>=4.0.3) paired with mcp[cli]==2.0.0. The Docker build also applies a version-guarded OAuth metadata workaround for Codex CLI 0.146. It stops advertising the RFC 9207 authorization-response iss parameter as mandatory while FastMCP still includes it in redirects. The build fails if the expected FastMCP version or patch location changes, so upgrades require explicit interoperability tests.

For Codex, configure and authenticate the server as described in the official Codex MCP documentation:

shell
codex mcp add google_ads --url http://localhost:8080/mcp
codex mcp login google_ads

For Antigravity, configure the same URL as serverUrl in its MCP configuration. This key is required for Streamable HTTP in Antigravity 2.8.1 and Antigravity IDE 2.5.5; httpUrl is not accepted by those versions. After authentication, both clients should list these namespaced tools:

  • customers_list_accessible_customers
  • metadata_get_resource_metadata
  • search_search

Option 2: Configure credentials using Application Default Credentials

Configure your Application Default Credentials (ADC). Make sure the credentials are for a user with access to your Google Ads accounts or properties.

Credentials must include the Google Ads API scope:

https://www.googleapis.com/auth/adwords

Check out Manage OAuth Clients for how to create an OAuth client.

Here are some sample gcloud commands you might find useful:

  • Set up ADC using user credentials and an OAuth desktop or web client after downloading the client JSON to YOUR_CLIENT_JSON_FILE.

    shell
    gcloud auth application-default login \
      --scopes https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform \
      --client-id-file=YOUR_CLIENT_JSON_FILE
  • Set up ADC using service account impersonation.

    shell
    gcloud auth application-default login \
      --impersonate-service-account=SERVICE_ACCOUNT_EMAIL \
      --scopes=https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform

When the gcloud auth application-default command completes, copy the PATH_TO_CREDENTIALS_JSON file location printed to the console in the following message. You will need this for a later step!

Credentials saved to file: [PATH_TO_CREDENTIALS_JSON]

Option 3: Configure credentials using the Google Ads API Python client library.

Follow the instructions to setup and configure the Google Ads API Python client library

If you have already done this and have a working google-ads.yaml , you can reuse this file!

In the utils.py file, change get_googleads_client() to use the load_from_storage() method.

Configure your MCP client

Add the server to your MCP client's configuration. Below are examples for popular clients.

Antigravity / Antigravity IDE

  1. Install Antigravity or Antigravity IDE.

  2. Configure your server. Refer to the docs at https://antigravity.google/docs/mcp for details on setting up MCP servers.

  • Option 1: Using FastMCP OAuth Proxy (Streamable HTTP)

    You can run the server as a separate process and configure your MCP client to connect to the Streamable HTTP endpoint (for example, http://localhost:8080/mcp). This also allows using FastMCP's OAuth proxy feature for dynamic user authentication.

    Antigravity 2.8.1 and Antigravity IDE 2.5.5 require serverUrl for a Streamable HTTP server. Do not use the older httpUrl key. Server-side credentials belong in the server process, not in this client configuration.

    json
    {
      "mcpServers": {
        "google-ads-mcp": {
          "serverUrl": "http://localhost:8080/mcp"
        }
      }
    }
  • Option 2: the Application Default Credentials method

    This remains a supported alternative, but it provides less credential isolation than the server-managed Streamable HTTP deployment above. The MCP client starts the server and its configuration contains the ADC file path and Google Ads developer token. Prefer the Quadlet deployment when several local clients share the same server or client configuration may be copied, synchronized, or inspected by other tools.

    Replace PATH_TO_CREDENTIALS_JSON with the path you copied in the previous step.

    We also recommend that you add a GOOGLE_CLOUD_PROJECT attribute to the env object. Replace YOUR_PROJECT_ID in the following example with the project ID of your Google Cloud project.

    json
    {
      "mcpServers": {
        "google-ads-mcp": {
          "command": "pipx",
          "args": [
            "run",
            "--spec",
            "git+https://github.com/googleads/google-ads-mcp.git",
            "google-ads-mcp"
          ],
          "env": {
            "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
            "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID",
            "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN"
          }
        }
      }
    }
  • Option 3: the Python client library method

    json
    {
      "mcpServers": {
        "google-ads-mcp": {
          "command": "pipx",
          "args": [
            "run",
            "--spec",
            "git+https://github.com/googleads/google-ads-mcp.git",
            "google-ads-mcp"
          ],
          "env": {
            "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID",
            "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN"
          }
        }
      }
    }

Login Customer Id

If your access to the customer account is through a manager account, you will need to add the customer ID of the manager account to the settings file.

See here for details.

The final file will look like this:

json
{
  "mcpServers": {
    "google-ads-mcp": {
      "command": "pipx",
      "args": [
        "run",
        "--spec",
        "git+https://github.com/googleads/google-ads-mcp.git",
        "google-ads-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
        "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID",
        "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN",
        "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "YOUR_MANAGER_CUSTOMER_ID"
      }
    }
  }
}

Other MCP clients (Claude Code, Cursor, VS Code, etc.)

The mcpServers block format is the same across all MCP clients. Add the configuration shown above to the appropriate settings file for your client (e.g., ~/.claude/settings.json for Claude Code, .cursor/mcp.json for Cursor, .vscode/mcp.json for VS Code with Copilot).

Deployment to Google Cloud Platform

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.

Note that this only supports authentication with an OAuth Client ID and Client Secret pair through the OAuth proxy (Option #1 above).

Prerequisites

  1. A Google Cloud project.
  2. The gcloud CLI installed, authenticated, and active project set.
    shell
    gcloud config set project YOUR_PROJECT_ID

Step 1: Build and Push Docker Image

You can use Cloud Build to build and push the image to Artifact Registry without needing Docker installed locally.

  1. Create a repository in Artifact Registry:
    shell
    gcloud artifacts repositories create mcp-servers --repository-format=docker --location=us-central1
  2. Build and submit the image:
    shell
    gcloud builds submit --tag us-central1-docker.pkg.dev/YOUR_PROJECT_ID/mcp-servers/google-ads-mcp:latest .
    Replace YOUR_PROJECT_ID with your Google Cloud project ID.

Step 2: Deploy to Google Cloud Run

Make sure to set the required environment variables:

  • GOOGLE_PROJECT_ID: Your Google Cloud project ID.

  • GOOGLE_ADS_DEVELOPER_TOKEN: (Optional) The developer token you want the MCP server to use (see above).

  • GOOGLE_ADS_MCP_OAUTH_CLIENT_ID: The OAuth Client ID you want the MCP server to use.

  • GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET: The OAuth Client secret you want the MCP server to use.

  • GOOGLE_ADS_MCP_BASE_URL: The base URL where your MCP server is accessible: this will be automatically assigned by Google Cloud Run after your first deployment. You can update the environment variables after deployment.

  • GOOGLE_ADS_MCP_JWT_SIGNING_KEY: (Recommended for production) Persistent JWT signing key across Cloud Run instances.

  • GOOGLE_ADS_MCP_STORAGE_TYPE: (Recommended for production) Storage backend to persist OAuth tokens across instances. Set it to firestore to use Firestore through Application Default Credentials, which needs no VPC connector, or to redis along with GOOGLE_ADS_MCP_STORAGE_REDIS_URL.

    Using firestore requires three things: build the image with the extra installed (change the Dockerfile to uv pip install --system .[firestore]), create a Firestore database in the project, since one is not provisioned automatically, and grant the Cloud Run service account roles/datastore.user. Note that entries are not expired automatically: the store filters expired entries on read but never deletes them, and expires_at is written as a string, so a Firestore TTL policy cannot collect them either. Plan on a periodic cleanup job for long-running deployments. Redis expires entries on its own.

  • FASTMCP_HOST: Set this to 0.0.0.0 to allow FastMCP to accept connections from all IP addresses.

  • GOOGLE_ADS_LOGIN_CUSTOMER_ID: Required if your access to the customer account is through a manager account. Set it to the customer ID of the manager account. See Login Customer Id above for details.

shell
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,GOOGLE_ADS_MCP_JWT_SIGNING_KEY=YOUR_JWT_SIGNING_KEY,GOOGLE_ADS_MCP_STORAGE_TYPE=firestore,FASTMCP_HOST=0.0.0.0"

Step 3: Configure MCP Client

Once deployed, update your MCP client configuration (refer to the docs at https://antigravity.google/docs/mcp) to use the Cloud Run URL.

json
{
  "mcpServers": {
    "google-ads-mcp": {
      "httpUrl": "https://your-cloud-run-url.a.run.app/mcp"
    }
  }
}

Try it out

Launch your MCP client. You should see google-ads-mcp listed in the available servers.

Here are some sample prompts to get you started:

  • Ask what the server can do:

    what can the ads-mcp server do?
  • Ask about customers:

    what customers do I have access to?
  • Ask about campaigns

    How many active campaigns do I have?
    How is my campaign performance this week?

Note about Customer ID

Your agent will need and ask for a customer id for most prompts. If you are moving between multiple customers, including the customer ID in the prompt may be simpler.

How many active campaigns do I have for customer id 1234567890

Contributing

Contributions welcome! See the Contributing Guide. Project maintainers can find the Trusted Publishing and release procedure in the release guide.

安装

TypingMind
{
  "mcpServers": {
    "googleads-google-ads-mcp": {
      "command": "pipx",
      "args": [
        "run",
        "--spec",
        "git+https://github.com/googleads/google-ads-mcp.git",
        "google-ads-mcp"
      ],
      "env": {
        "GOOGLE_PROJECT_ID": "<GOOGLE_PROJECT_ID>",
        "GOOGLE_ADS_DEVELOPER_TOKEN": "<GOOGLE_ADS_DEVELOPER_TOKEN>"
      }
    }
  }
}

将 Google Ads MCP Server (Experimental) MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Google Ads MCP Server (Experimental) 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 Google Ads MCP Server (Experimental) 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Google Ads MCP Server (Experimental) MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "googleads-google-ads-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Google Ads MCP Server (Experimental) MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Google Ads MCP Server (Experimental) MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Google Ads MCP Server (Experimental) 帮我完成这项任务吗?
Google Ads MCP Server (Experimental)
当然,我看过了。
以下是我使用 Google Ads MCP Server (Experimental) 得到的结果。

常见问题

Google Ads MCP Server (Experimental) MCP 服务器有什么用途?

Google Ads MCP Server (Experimental) 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Google Ads MCP Server (Experimental) MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 Google Ads MCP Server (Experimental)。

为什么在 TypingMind 中使用 Google Ads MCP Server (Experimental) MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 Google Ads MCP Server (Experimental) 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Google Ads MCP Server (Experimental) MCP 连接到 TypingMind?

Google Ads MCP Server (Experimental) 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Google Ads MCP Server (Experimental) MCP 在 TypingMind 中提供哪些工具?

Google Ads MCP Server (Experimental) 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Google Ads MCP Server (Experimental) MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 Google Ads MCP Server (Experimental) 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇