google-ads-mcp-server

s2003zy/google-ads-mcp-server

3.2

If you are the rightful owner of google-ads-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This repository contains the source code for a local MCP server that interacts with the Google Ads API.

Tools
1
Resources
0
Prompts
0

Google Ads MCP Server

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

Tools 🛠️

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

Retrieve account information

  • list_accessible_customers: Lists the resource names of all customers accessible to the user.
  • get_campaigns: Retrieves all campaigns for the specified customer.

Setup instructions

Setup involves the following steps:

  1. Configure Pipx.
  2. Configure credentials for Google Ads API.
  3. Configure Gemini CLI.

Configure Pipx 🐍

Install pipx.

Configure credentials 🔑

Enable the Google Ads API in your Google Cloud project.

Config a google_ads.yaml file in your local.

# This is an example of a google-ads.yaml file.
# You can find more information about these settings in the Google Ads API
# documentation:
# https://developers.google.com/google-ads/api/docs/client-libs/python/configuration

# The developer token  uniquely identifies a Google Ads API developer.
# How to obtain a developer token see:
#   https://developers.google.com/google-ads/api/docs/get-started/dev-token
developer_token: "xxx"

# The client ID and client secret are used for OAuth2 authentication. 
# See full documentation at https://support.google.com/cloud/answer/15549257?hl=en
# Example steps:
# Go to the Google Cloud Console https://console.cloud.google.com
#   Go to project Credentials pages
#   Click `Create Credentials` then `OAuth client ID`
#       Application type pick `Desktop Application` 
#   Copy the `client_id` & `client_secret` from the popup
client_id: "xxx"
client_secret: "xxx"

# How to obtain the refresh token: https://www.youtube.com/watch?v=_yvqUyZ72Kc
refresh_token: "xxx"

# The login customer ID is the customer ID of the account that you want to
# manage.
login_customer_id: "xxx"

# The `use_proto_plus` option is now set programmatically in the code.
use_proto_plus: True

For more information, see the Google Ads API documentation on configuration.

Configure Gemini CLI

  1. Install Gemini CLI
  2. Setup & Connect MCP server within Gemini CLI by edit the file at ~/.gemini/settings.json, adding your server to the mcpServers list.
{
  "mcpServers": {
    "ads-mcp": {
      "command": "pipx",
      "args": [
        "run",
        "--spec",
        "git+https://github.com/YOUR_USERNAME/google-ads-mcp.git",
        "google-ads-mcp"
      ],
      "env": {
        // IMPORTANT: Replace the path with the creadentials file created in provious step.
        "GOOGLE_ADS_CONFIGURATION_FILE_PATH": "/path/to/google_ads.yaml"
      }
    }
  }
}

Try it out 🥼

Launch Gemini Code Assist or Gemini CLI and type /mcp. You should see ads-mcp listed in the results.

Here are some sample prompts to get you started:

  • Ask what the server can do:

    what can the ads-mcp server do?

  • Ask about your accessible customers:

    list my accessible customers

  • Ask about campaigns for a specific customer (replace with a real customer ID):

    get campaigns for customer "1234567890"