gads
A Google Ads API MCP server that enables searching and listing accessible customers via natural language queries.
README
gads
A Google Ads API MCP server & CLI written in Rust.
Calls the Google Ads REST API (v21) directly via reqwest — no gRPC dependency.
Inspired by googleads/gads (Python).
Security Notice
gads authenticates through Google Cloud Application Default Credentials (ADC).
Once you run gcloud auth application-default login, the resulting credential file
(~/.config/gcloud/application_default_credentials.json) is a machine-wide, long-lived
OAuth2 refresh token. Any process on your machine — not just gads — can read this file
and obtain access tokens for every scope you authorized, including the Google Ads API
and any other Google Cloud APIs.
Use gads at your own risk. You are responsible for securing your local credentials and understanding the implications of ADC-based authentication.
See Roadmap for planned mitigations.
Setup
1. Google Cloud Project
# Install gcloud CLI if needed
# https://cloud.google.com/sdk/docs/install
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
2. Enable the Google Ads API
gcloud services enable googleads.googleapis.com
Or enable via Cloud Console.
3. Obtain a Developer Token
- Sign in to Google Ads
- Tools & Settings > Setup > API Center
- Copy the developer token (initial access is test-account only; production requires approval)
Details: https://developers.google.com/google-ads/api/docs/get-started/dev-token
4. Authentication
Option A: Application Default Credentials (recommended)
gcloud auth application-default login \
--scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/adwords"
This creates ~/.config/gcloud/application_default_credentials.json, which gads discovers automatically.
Option B: Service Account
gcloud iam service-accounts create gads-sa \
--display-name="gads service account"
gcloud iam service-accounts keys create sa-key.json \
--iam-account=gads-sa@YOUR_PROJECT_ID.iam.gserviceaccount.com
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa-key.json
You must also invite the service account email in Google Ads: Tools & Settings > Access & Security > add the service account email.
5. Environment Variables
export GOOGLE_ADS_DEVELOPER_TOKEN="your-developer-token"
# Required only when accessing accounts via an MCC (Manager account)
export GOOGLE_ADS_LOGIN_CUSTOMER_ID="1234567890"
# Quota project for ADC user credentials (prevents 403)
export GOOGLE_CLOUD_QUOTA_PROJECT="your-gcp-project-id"
| Variable | Required | Description |
|---|---|---|
GOOGLE_ADS_DEVELOPER_TOKEN |
Yes | Google Ads API developer token |
GOOGLE_ADS_LOGIN_CUSTOMER_ID |
No | MCC customer ID (no hyphens) |
GOOGLE_CLOUD_QUOTA_PROJECT |
No | Sets x-goog-user-project header for ADC user credentials |
GOOGLE_APPLICATION_CREDENTIALS |
No | Path to service account JSON key. Falls back to ADC auto-discovery |
6. Verify
cargo build -p gads --release
# List accessible accounts to confirm authentication
gads customers
Build
# Build host binary + npx tgz
bun run build
Release
# Patch version bump + build + publish
bun run release
CLI Usage
Running without arguments (or with serve) starts the MCP server.
Subcommands invoke the API directly.
gads [COMMAND]
Commands:
serve Start MCP server (stdio transport) [default]
login Authenticate via gcloud ADC with Google Ads API scope
doctor Diagnose auth, config, and API connectivity
customers List accessible customers with MCC/ACCOUNT labels
use Save/show default customer ID
search Execute a GAQL query
campaign Campaign operations (list / status)
adgroup Ad group operations (list / status)
ad Ad operations (list / status)
creatives List ad creatives (headlines, descriptions, URLs)
mutate Execute arbitrary mutate requests (create/update/delete)
config Manage persistent config (developer-token, login-customer-id)
customers
gads customers
gads customers --tree
gads customers --ids-only
doctor
gads doctor
search
# Save a default customer ID first (optional)
gads use 1234567890
# Raw GAQL
gads search \
-q "SELECT campaign.id, campaign.name FROM campaign" \
-l 10
# Override login-customer-id for this command only
gads search \
--customer-id 1234567890 \
--login-customer-id 9988776655 \
-q "SELECT campaign.id, campaign.name FROM campaign"
# Disable login-customer-id for this command
gads search \
--customer-id 1234567890 \
--no-login-customer-id \
-q "SELECT campaign.id, campaign.name FROM campaign"
# Shorthand: resource + fields
gads search \
--customer-id 1234567890 \
-q "campaign campaign.id,campaign.name" \
-l 10
Output is a JSON array. Pipe to jq:
gads search -c 1234567890 -q "SELECT campaign.name FROM campaign" | jq '.[].["campaign.name"]'
use
gads use 1234567890 # save default customer ID
gads use # show current default
campaign / adgroup / ad / creatives
gads campaign list -l 100
gads adgroup list -l 200
gads ad list -l 200
gads creatives -l 200
# Disable MCC header for this command
gads campaign --no-login-customer-id list
Status updates (ENABLED / PAUSED)
gads campaign status --campaign-id 123456789 --status ENABLED
gads adgroup status --ad-group-id 987654321 --status PAUSED
gads ad status --ad-group-id 987654321 --ad-id 1122334455 --status ENABLED
# Validate only (dry run)
gads campaign status --campaign-id 123456789 --status ENABLED --validate-only
mutate
Calls customers/{customer_id}/{service}:mutate directly.
Supports any create/update/delete operation.
# Inline JSON
gads mutate \
--service campaigns \
--body '{
"operations": [{
"update": {
"resourceName": "customers/1234567890/campaigns/111222333",
"status": "ENABLED"
},
"updateMask": "status"
}]
}'
# From file + validate only
gads mutate \
--service adGroupAds \
--body-file ./mutate-body.json \
--validate-only
MCP Server Usage
Claude Desktop / Claude Code
{
"mcpServers": {
"gads": {
"command": "/path/to/gads",
"env": {
"GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_TOKEN",
"GOOGLE_ADS_LOGIN_CUSTOMER_ID": "1234567890"
}
}
}
}
MCP Tools
| Tool | Description |
|---|---|
search |
Execute GAQL queries against Google Ads. Includes embedded field reference for all v21 resources |
list_accessible_customers |
List customer IDs accessible by the authenticated user |
Architecture
src/
main.rs — Entry point (CLI parser + MCP serve)
server.rs — MCP tool registration + ServerHandler
client.rs — Google Ads REST API client
auth.rs — ADC token acquisition via gcp_auth
query.rs — GAQL query builder
format.rs — searchStream response flattening
error.rs — Unified error type
gaql_resources.json — GAQL v21 field reference (compile-time embed)
Test
cargo test -p gads
Roadmap
- Scoped credential isolation — Current ADC credentials grant access to all authorized
scopes machine-wide. Investigate per-tool credential isolation (e.g., short-lived tokens
with scope restricted to
adwordsonly, or a proxy that mediates token exchange) so that a compromised process cannot leverage gads credentials for unrelated GCP APIs. - Token broker / proxy architecture — Instead of reading ADC directly, gads could request tokens from a local broker that enforces scope, audience, and lifetime constraints. This would prevent other processes from reusing the raw refresh token.
- Credential storage hardening — Explore alternatives to the plaintext ADC JSON file (e.g., OS keychain integration, encrypted-at-rest profiles).
- Audit logging — Log all API calls with timestamps and caller context to detect unauthorized usage of shared credentials.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。