
Google Ads API Developer Assistant
PluginGoogle Ads 官方 API 开发助手插件,面向 API 开发者与投放分析人员:用自然语言提问、生成并校验 GAQL 查询、运行查询拉取账户数据导出 CSV、排查离线转化上传;改动账户的代码只生成不执行。需要 API 开发者令牌、凭据文件和 Python 3.10+。
Google Ads API Developer Assistant
TL;DR: This assistant lets you interact with the Google Ads API using natural language. Ask questions, generate GAQL and code in several languages, and execute API calls directly in your terminal.
Overview
The Google Ads API Developer Assistant streamlines workflows for developers working with the Google Ads API. Use natural language prompts to:
- Get answers to Google Ads API questions.
- Construct Google Ads Query Language (GAQL) queries.
- Generate executable code in several languages using our client libraries for context.
- Retrieve and display data from the API.
This assistant is powered by the Antigravity (v4.0.0) and Claude Code agent frameworks and leverages AGENTS.md / CLAUDE.md files, native slash commands, and custom Skills to deliver persistent context, robust safety constraints, and automated execution pipelines.
Agentic Design & Approach
The Assistant uses a structured hierarchy of instruction files, slash commands, and specialized domain tools to ensure safe, precise, and highly competent interactions with the Google Ads API across supported agent environments.
1. Unified Context via AGENTS.md & CLAUDE.md
The master configuration files act as the system contract for the assistant:
- Version Cache Protocol: Automatically discovers and locks the latest active API version (cached in
config/api_version.txt). - Version Parity Enforcement: Verifies parity between the runtime
google-adsPython package and localclient_libs/google-ads-pythonsource-of-truth definitions, issuing warnings on discrepancies. - Code Generation Pipeline: Passes all generated Python code through strict
rufflinting before saving or displaying it. - Programmatic GAQL Validation: Evaluates queries against field metadata and compatibility boundaries.
- Safety Constraints: Strictly prohibits running unreviewed mutate operations directly.
2. Domain-Specific "Skills" & Native Commands
Rather than relying on generic AI completions, the assistant is empowered with specialized, test-backed tool directories under plugins/google-ads-api-developer-assistant/skills/ and native slash commands under plugins/google-ads-api-developer-assistant/commands/.
Key capabilities support dual invocation (natural language prompts in Antigravity or dedicated slash commands in Claude Code):
- GAQL Validation (
/validate-gaql): Dry-runs queries via the APIvalidate_onlyparameter. - Object Inspection (
/inspect-object): Inspects API resources, nested messages, or enum definitions on the fly. - MCC Account Mapping (
/get-cids): Maps client hierarchies and retrieves sub-account CIDs under manager accounts. - Conversion Troubleshooting (
/troubleshoot-conversions): Investigates conversion upload summaries and pre-validates files. - PMax Listing Filters & URL Exclusions (
/pmax-filter): Generates product partition trees and webpage URL exclusions. - Structured Explanations (
/explain,/step-by-step,/assistant-tutorial): Delivers standardized multi-part explanations, step breakdowns, and interactive tutorials. - Environment & Library Sync (
/sync-client-libs,/ext-version): Synchronizes client libraries and verifies active API version settings.
Key Features
-
Natural Language Q&A & Conceptual Guidance: Ask about Google Ads API concepts, fields, and usage in plain English, or use structured explanation commands.
- Natural Language: "What are the available campaign types?", "Tell me about reporting for Performance Max campaigns."
- Claude Code:
/explain,/step-by-step,/assistant-tutorial
-
Natural Language to GAQL & Client Library Code: Convert requests into executable code using the Google Ads Client Libraries.
- Code is saved to
saved/code/. - "Show me campaigns with the most conversions last 30 days."
- "Get all ad groups for customer '123-456-7890'."
- "Find disapproved ads across all campaigns."
- Code is saved to
-
Validate Complex GAQL Queries: Validate complex GAQL queries against API metadata and compatibility rules.
- Claude Code:
/validate-gaql - Natural Language:
validate: SELECT campaign.id, campaign.name, campaign.status, campaign.advertising_channel_type, ad_group.id, ad_group.name, ad_group.status, ad_group_ad.ad.id, ad_group_ad.status, ad_group_ad.ad.type, ad_group_ad.policy_summary.policy_topic_entries, metrics.clicks, metrics.impressions, metrics.cost_micros, metrics.conversions, segments.date FROM ad_group_ad WHERE campaign.status = 'ENABLED' AND ad_group.status = 'ENABLED' AND ad_group_ad.status = 'ENABLED' AND segments.date DURING LAST_30_DAYS AND metrics.impressions > 100 ORDER BY metrics.clicks DESC LIMIT 500
- Claude Code:
-
Direct API Execution: Run the generated Python code directly and view results, often formatted as tables. Execution takes place within a managed virtual environment that has the Google Ads API Client Libraries installed.
-
CSV Export: Save tabular API results to a CSV file in the
saved/csv/directory.- "Save results to a csv file"
-
Conversion Troubleshooting & Diagnostics: Generate structured diagnostic reports to debug offline conversion issues.
- Claude Code:
/troubleshoot-conversions - Natural Language: "Troubleshoot my conversions for customer '123-456-7890'." (Reports saved to
saved/data/).
- Claude Code:
Supported Languages
- Python
- PHP
- Ruby
- Java
- C# (.NET)
Code generated by Python, PHP, and Ruby can be executed directly. Code generated by Java and C# must be compiled and executed separately. This is because of security policies. For C# code generation, use 'in dotnet' to set the context.
By default, Python is strictly used for all code generation and execution across the assistant, even when other language libraries or project files are present. The assistant will only switch to generating or executing in another language if specifically requested by the user. As of v2.3.0 you can provide context from your project files using the context_dir flag: ./update.sh --context_dir /path/to/your/codebase. This allows Gemini to include your application logic in its reasoning when creating responses.
- Before requesting code output in a different language, tell the Assistant:
write saved code examples in <language of your application>
Prerequisites
- Familiarity with Google Ads API concepts and authentication.
- A Google Ads API developer token.
- A configured credentials file in your home directory if using Python (
google-ads.yaml), PHP (google_ads_php.ini), or Ruby (google_ads_config.rb). - Antigravity or Claude Code environment configured.
- A local clone of each client library for the languages you want to use.
install.sh(Linux/macOS) orinstall.ps1(Windows) can set this up for you. - Python >= 3.10 installed and available on your system PATH. This is required for executing the default generated Python code directly.
Setup
1. Install Host Platform
Choose and set up your assistant environment. You can install both Antigravity and Claude Code or just one of them. Install the host platform(s) you want to use:
Antigravity CLI
- Download and install
antigravity-clifrom https://antigravity.google/. - Verify your installation:
agy --version
Claude Code
- Prerequisites: Ensure Node.js (version 18 or higher) is installed on your system:
node --version - Install Claude Code CLI: Install Claude Code globally using npm:
(Alternatively on macOS via Homebrew:npm install -g @anthropic-ai/claude-codebrew install claude-code) - Authenticate: Run
claudein your terminal to authenticate with your Anthropic account or configure your API key:claude - Verify Installation: Check that the CLI is accessible:
claude --version
2. Clone the Assistant
Clone the repository to your local machine:
git clone https://github.com/googleads/google-ads-api-developer-assistant
cd google-ads-api-developer-assistant
3. Run Install Script
Run the installation script matching your platform:
-
Antigravity (Linux/macOS):
./install.sh agyInstalls plugin to
~/.gemini/config/plugins/google-ads-api-developer-assistant. To include additional client libraries:./install.sh agy --php --ruby --dotnet. -
Claude Code (Linux/macOS):
./install.sh claudeRegisters the repository as a local marketplace and installs the plugin into Claude Code via the
claudeCLI. To include additional client libraries:./install.sh claude --php --ruby --dotnet. -
Antigravity (Windows - PowerShell):
.\install.ps1 -Type agyInstalls plugin to
%USERPROFILE%\.gemini\config\plugins\google-ads-api-developer-assistant. To include additional client libraries:.\install.ps1 -Type agy -Php -Ruby -Dotnet. -
Claude Code (Windows - PowerShell):
.\install.ps1 -Type claudeRegisters the local marketplace and installs the plugin into Claude Code via Claude CLI. To include additional client libraries:
.\install.ps1 -Type claude -Php -Ruby -Dotnet.
- Configure Credentials: Make sure your API credentials configuration files are in your
$HOMEdirectory. Each language has its own configuration file naming convention and structure. - Optional: Default Customer ID: To set a default customer ID, enter your customer ID in
config/customer_id(e.g.,1234567890). You can then use prompts like "Get my campaigns" and the Assistant will use the CID for the request. - Google Ads API Version Validation: On your first run in a session, the assistant will automatically identify the latest stable Google Ads API version and ask you to confirm it. Once confirmed, this version is cached in api_version.txt and used for all subsequent prompts. If you need to force a version change or refresh the cache, simply delete or edit the
config/api_version.txtfile.
Usage
-
Start Assistant Session: Ask questions, generate code, and validate queries within your Antigravity terminal session or Claude Code.
-
Ask a question:
"What are the resource names for my enabled campaigns sorted by campaign id"
-
Generate Code:
"Get me the top 5 campaigns by cost last month for customer 1234567890"
-
Execute and Save:
"Run the code" ... (code displayed as the result of a previous request) ... "Save the results to csv"
Stay in sync
The Assistant includes automated synchronization tools to ensure your local client libraries, protobuf definitions, and API version metadata remain aligned with upstream releases on GitHub.
1. Update Check & Confirmation at Session Startup
Whenever an assistant session starts in Antigravity or Claude Code, the assistant executes an automated "Validate Before Act & Interactive Sync" directive:
- It checks both the Assistant repository itself and local client libraries (
client_libs/) against the latest upstream GitHub releases in check-only mode (--check_only). - If newer assistant releases or client library updates are detected, the assistant prompts you with the available updates and asks for confirmation before downloading:
"New updates are available on GitHub (e.g., google-ads-api-developer-assistant 4.0.0, google-ads-python 25.1.0 -> 26.0.0). Would you like to upgrade now?"
- If you confirm, it automatically synchronizes the codebases and refreshes
config/api_version.txt. If you decline, it proceeds with your currently installed versions.
2. Requesting Synchronization During a Session
You can check for updates or trigger synchronization at any time while in an active session:
-
Natural Language Prompts (Antigravity & Claude Code):
- "Sync my client libraries"
- "Check for Google Ads client library updates"
- "Update the Python client library to the latest release"
-
Dedicated Slash Command (Claude Code):
- Run
/sync-client-libsto inspect and synchronize all local client libraries. - Target a specific library:
/sync-client-libs pythonor/sync-client-libs dotnet.
- Run
-
Verify Active Version:
- Claude Code:
/ext-version - Natural Language: "What is the active Google Ads API version?"
- Claude Code:
3. Manual Terminal Updates
To update the repository, assistant plugin, and all configured client libraries outside an active session:
- Linux/macOS:
./update.sh agy --all # Update Antigravity plugin and all client libraries ./update.sh claude --all # Update Claude Code plugin and all client libraries - Windows (PowerShell):
.\update.ps1 -Type agy -All .\update.ps1 -Type claude -All
4. Client Library & Runtime Version Parity
The Assistant relies on local client library sources (client_libs/google-ads-python) as the primary source of truth for Protobuf schemas, resource definitions, and enum descriptors, while executing queries and generated code through the installed google-ads Python package in your environment.
To prevent silent schema discrepancies, missing fields, or descriptor errors:
- Automated Parity Checks: Tool scripts (such as
inspect_object.py) automatically compare the installed environment package version (importlib.metadata.version('google-ads')) against the localclient_libs/google-ads-pythonversion metadata (pyproject.toml/ChangeLog). - Warning Directives: If a version mismatch is detected, the Assistant and inspection tools output an explicit warning banner:
WARNING: Installed google-ads package version (<installed_version>) does not match client_libs/google-ads-python version (<client_libs_version>) used for protobuf inspection. Schema inspection or API calls may encounter field discrepancies. - Resolving Mismatches:
- Synchronize client libraries to latest:
/sync-client-libs(or prompt "Sync client libraries"). - Upgrade the runtime Python package:
pip install --upgrade google-ads(or within virtualenv:source .venv/bin/activate && pip install --upgrade google-ads). - Perform a complete update:
./update.sh agy --allor./update.sh claude --all.
- Synchronize client libraries to latest:
Directory Structure
plugins/google-ads-api-developer-assistant/: Source directory for the assistant plugin.plugins/google-ads-api-developer-assistant/commands/: Native slash commands for Claude Code.plugins/google-ads-api-developer-assistant/skills/: Assistant skills (GAQL analyzer, proto inspect, etc.).plugins/google-ads-api-developer-assistant/rules/: Agent behavioral rules and protocols.plugins/google-ads-api-developer-assistant/sidecars/: Background sidecar microservices.plugins/google-ads-api-developer-assistant/client_libs/: Cloned client libraries.plugins/google-ads-api-developer-assistant/mcp_config.json: Model Context Protocol configuration.config/: Configuration files (e.g.api_version.txt,customer_id).
Plugin Architecture
To learn more about how Antigravity and Claude define plugins, see the Antigravity plugin specification and the Claude plugin specification.
Mutate Operations
The Assistant is designed to generate code for mutate operations (e.g., creating campaigns, adding users) but will not execute them. This execution policy ensures you have full control over any changes to your Google Ads account. You must review the generated code for accuracy and execute it manually outside of the Assistant.
Known Quirks
- The underlying model may have been trained on an older API version. It may occasionally generate code with deprecated fields. Execution errors often provide feedback that allows the assistant to self-correct on the next attempt, using the context from the client libraries. To avoid these errors, we always search for the latest version of the API when initializing the session and ask you to verify the version.
Maintenance
We will periodically release updates to the assistant and client libraries. To update your repository, plugin installation, and client libraries:
- Linux/macOS:
To add or update specific client libraries:./update.sh agy # Update Antigravity plugin ./update.sh claude # Update Claude Code plugin./update.sh agy --java --dotnet - Windows:
To add or update specific client libraries:.\update.ps1 -Type agy .\update.ps1 -Type claude.\update.ps1 -Type agy -Java -Dotnet
Uninstallation
To remove the Google Ads API Developer Assistant plugin, use the native uninstallation mechanism for your platform:
Antigravity
Delete the installed plugin directory:
- Linux/macOS:
rm -rf ~/.gemini/config/plugins/google-ads-api-developer-assistant - Windows (PowerShell):
Remove-Item -Recurse -Force "$HOME\.gemini\config\plugins\google-ads-api-developer-assistant"
Restart your Antigravity / agy host session to complete the uninstallation.
Claude Code
- Within an active Claude Code session:
/plugin uninstall google-ads-api-developer-assistant@google-ads-assistant-local - Or from your terminal:
claude plugin uninstall google-ads-api-developer-assistant@google-ads-assistant-local
(Optional) To remove the local marketplace registration as well:
- Within Claude Code:
/plugin marketplace remove google-ads-assistant-local - From terminal:
claude plugin marketplace remove google-ads-assistant-local
Contributing
Please see CONTRIBUTING.md for guidelines on reporting bugs, suggesting features, and submitting pull requests.
Support
Use the GitHub Issues tab for bug reports, feature requests, and support questions.
License
Apache License 2.0. See the LICENSE file.
相關資源

Google Ads API Account Performance Diagnostics
SkillGoogle 官方技能:通过 Google Ads MCP 服务器查账户数据,诊断转化下滑、线索减少,以及出价、预算、广告评级造成的展示份额损失。需 Google Ads 账户、API 凭据(开发者令牌与 OAuth)和本机 Python 3.12,建议请技术人员协助配置。
google/skills21.4k
Google Ads MCP Server
MCP让 agent 用 GAQL 查询 Google Ads 账户、广告系列与投放效果数据,目前只提供查询类工具。Google 官方维护,需配置 Google Cloud 凭据与 Ads API 访问权限。
googleads/google-ads-mcp1k
NotFair Plugin
Plugin开源营销插件:48 个技能覆盖 SEO 与 AI 搜索优化(GEO)、GA4 与 Search Console 分析、Google/Meta/X/LinkedIn/Reddit/TikTok 广告诊断和 WordPress 维护。部分 SEO 技能给网址即可用,读取实时广告与分析数据需 OAuth 登录 NotFair 并连接各平台账号。
nowork-studio/notfair-plugin3.9k
MCP Server for Google Tag Manager
MCPStape 出品的 Google Tag Manager MCP:让 agent 查看、新建和修改 GTM 容器里的代码、触发器和变量,帮运营与投放人员配置埋点和转化跟踪。推荐用托管版(数据经 Stape 服务器中转),首次调用时在浏览器完成 Google 授权即可;也可用服务账号密钥在本地运行。
stape-io/google-tag-manager-mcp-server230
Windsor.ai
PluginWindsor.ai 官方插件:把 Google、Meta、TikTok 等广告账户和 GA4、CRM 等 350 多个数据源接入 Claude,一句话出跨渠道投放报表、找出浪费的预算;改预算、停广告前先征得确认。需要 Windsor.ai 账号,并在其后台连好数据源。
windsor-ai/claude-windsor-ai-plugin1
DuckDB
CLI进程内分析型 SQL 数据库,命令行可直接用 SQL 查询 CSV、Parquet、JSON 文件,无需导入或启动服务,适合 agent 抽样与聚合大文件。官方维护。
duckdb/duckdb42.2k