Google Ads MCP server — query campaigns, keywords, assets & more via natural language.
Built with Bun + TypeScript. Works with Claude, Cursor, and any MCP client.
______________________________________________________________________
快速开始
1.获取凭据
你需要一个 Google Ads API开发者代币 以及OAuth客户端凭据。
- 从下载OAuth客户端JSON 谷歌云控制台
- 设置环境变量:
export GOOGLE_ADS_DEVELOPER_TOKEN=your-token
export GOOGLE_ADS_CREDENTIALS_PATH=./credentials.json- 运行安装帮助程序以授权:
npx mcp-gads setup这将打开您的浏览器,完成OAuth,并保存刷新令牌。
2.添加到克劳德代码
claude mcp add google-ads --scope user --transport stdio \
-e GOOGLE_ADS_DEVELOPER_TOKEN=your-token \
-e GOOGLE_ADS_CREDENTIALS_PATH=/path/to/credentials.json \
-- npx -y mcp-gads@latest就是这样。重新启动Claude Code,工具就可用了。每个会话都会自动运行最新版本。
也与bunx mcp-gads@latest如果你有 包子. 通过运行时需要Node 18+npx.
如果您的环境在运行时阻止了npm注册表访问,请安装一次并直接运行已发布的二进制名称:
npm i -g mcp-gads@latest
claude mcp add google-ads --scope user --transport stdio \
-e GOOGLE_ADS_DEVELOPER_TOKEN=your-token \
-e GOOGLE_ADS_CREDENTIALS_PATH=/path/to/credentials.json \
-- mcp-gadsAlternative: standalone binary
从下载预构建的二进制文件 发布:
| 平台 | 文件 |
|---|---|
| macOS(苹果硅) | mcp-gads-darwin-arm64 |
| macOS(英特尔) | mcp-gads-darwin-x64 |
| Linux | mcp-gads-linux-x64 |
| 窗户 | mcp-gads-windows-x64.exe |
macOS/Linux:
curl -Lo mcp-gads https://github.com/pijusz/mcp-gads/releases/latest/download/mcp-gads-darwin-arm64
chmod +x mcp-gads
sudo mv mcp-gads /usr/local/bin/
claude mcp add google-ads --scope user --transport stdio \
-e GOOGLE_ADS_DEVELOPER_TOKEN=your-token \
-e GOOGLE_ADS_CREDENTIALS_PATH=/path/to/credentials.json \
-- /usr/local/bin/mcp-gadsWindows(PowerShell):
Invoke-WebRequest -Uri "https://github.com/pijusz/mcp-gads/releases/latest/download/mcp-gads-windows-x64.exe" -OutFile "$env:LOCALAPPDATA\mcp-gads.exe"
claude mcp add google-ads --scope user --transport stdio -e GOOGLE_ADS_DEVELOPER_TOKEN=your-token -e GOOGLE_ADS_CREDENTIALS_PATH=C:\path\to\credentials.json -- "%LOCALAPPDATA%\mcp-gads.exe"ChatGPT法典
Codex使用TOML,而不是JSON。安装一次,然后添加到 ~/.codex/config.toml:
npm i -g mcp-gads[mcp_servers.gads]
command = "mcp-gads"
[mcp_servers.gads.env]
GOOGLE_ADS_DEVELOPER_TOKEN = "your-token"
GOOGLE_ADS_CREDENTIALS_PATH = "/absolute/path/to/credentials.json"导致Codex无声失败的三个陷阱:
- 不使用
npx -y而不提高超时时间。 Codex的默认设置startup_timeout_sec是10s,对于npx的首次运行下载来说太短了。全局安装(如上)或 预构建二进制文件 完全回避了这一点。如果必须使用npx,请添加startup_timeout_sec = 30. - 环境必须被破坏
[mcp_servers.gads.env]. Codex不会将父shell环境继承到stdio服务器中——在shell中导出变量不会到达服务器。 - 使用绝对路径 为了
GOOGLE_ADS_CREDENTIALS_PATH.code使用自己的cwd生成服务器,因此相对路径会自动丢失。
在Windows上,某些Codex版本使用 startup_timeout_ms = 20000 而不是 _sec.
克劳德桌面版
添加到您的 claude_desktop_config.json:
Using npx (auto-updates)
{
"mcpServers": {
"google-ads": {
"command": "npx",
"args": ["-y", "mcp-gads@latest"],
"env": {
"GOOGLE_ADS_DEVELOPER_TOKEN": "your-token",
"GOOGLE_ADS_CREDENTIALS_PATH": "/path/to/credentials.json"
}
}
}
}Using binary (macOS / Linux)
{
"mcpServers": {
"google-ads": {
"command": "/usr/local/bin/mcp-gads",
"env": {
"GOOGLE_ADS_DEVELOPER_TOKEN": "your-token",
"GOOGLE_ADS_CREDENTIALS_PATH": "/path/to/credentials.json"
}
}
}
}Using binary (Windows)
{
"mcpServers": {
"google-ads": {
"command": "C:\\Users\\YOU\\AppData\\Local\\mcp-gads.exe",
"env": {
"GOOGLE_ADS_DEVELOPER_TOKEN": "your-token",
"GOOGLE_ADS_CREDENTIALS_PATH": "C:\\path\\to\\credentials.json"
}
}
}
}工具(39)
账户管理
| 工具 | 说明 |
|---|---|
list_accounts | 列出所有可访问的Google Ads帐户 |
get_account_currency | 获取帐户的货币代码 |
get_account_hierarchy | 获取MCC账户树(经理->客户端) |
查询
| 工具 | 说明 |
|---|---|
execute_gaql_query | 运行任何GAQL查询(表输出) |
run_gaql | 使用格式选项(表/json/csv)运行GAQL |
get_gaql_help | GAQL参考指南,包括语法、资源和示例 |
list_resources | 列出有效的GAQL FROM子句资源 |
活动
| 工具 | 说明 |
|---|---|
get_campaign_performance | 活动指标(印象、点击、成本、转化率) |
get_budget_utilization | 预算金额与实际支出 |
广告
| 工具 | 说明 |
|---|---|
get_ad_performance | 广告级别性能指标 |
get_ad_creatives | RSA标题、描述、最终URL |
资产
| 工具 | 说明 |
|---|---|
get_image_assets | 列出带有URL和维度的图像资产 |
download_image_asset | 将特定映像资源下载到磁盘 |
get_asset_usage | 查找资产的使用位置(活动、广告组) |
analyze_image_assets | 图像资产性能与指标 |
关键词
| 工具 | 说明 |
|---|---|
generate_keyword_ideas | 关键字规划师根据种子关键字提出的建议 |
get_keyword_volumes | 特定关键字的历史搜索量 |
get_quality_scores | 按组件细分的质量分数 |
get_search_terms | 触发广告的实际搜索查询 |
地理和设备
| 工具 | 说明 |
|---|---|
get_geographic_performance | 按地点分列的业绩 |
get_device_performance | 按设备类型划分的性能 |
洞察
| 工具 | 说明 |
|---|---|
get_recommendations | 谷歌的人工智能优化建议 |
get_change_history | 最近帐户更改 |
扩展工具(默认禁用)
启用 GOOGLE_ADS_ENABLE_EXTENDED_TOOLS=true:
| 工具 | 说明 |
|---|---|
get_ad_group_performance | 带有可选活动过滤器的广告组指标 |
get_conversion_actions | 具有设置和性能的转换操作 |
get_account_summary | 快速仪表板:总计+前5个活动 |
get_impression_share | 竞争地位:印象分享和损失IS |
get_ad_schedule_performance | 按小时或一周中的某一天显示的性能 |
get_audience_performance | 人口统计:年龄范围和性别细分 |
get_landing_page_performance | 带有指标的登录页面URL |
get_placement_performance | 显示/PMax放置细节 |
get_asset_group_performance | PMax资产组指标和广告强度 |
get_video_performance | YouTube/视频观看率和四分之一完成率 |
get_labels | 标签及其活动/广告组分配 |
写入工具(默认禁用)
启用 GOOGLE_ADS_ENABLE_MUTATIONS=true:
| 工具 | 说明 |
|---|---|
update_campaign_status | 暂停/启用活动 |
update_ad_group_status | 暂停/启用广告组 |
update_ad_status | 暂停/启用广告 |
update_campaign_budget | 更改每日预算金额 |
add_negative_keywords | 在广告系列中添加负面关键字 |
配置
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
GOOGLE_ADS_DEVELOPER_TOKEN | 是 | - | neneneba API开发者令牌 |
GOOGLE_ADS_CREDENTIALS_PATH | 是 | -- | OAuth客户端JSON的路径 |
GOOGLE_ADS_AUTH_TYPE | 没有 | oauth | oauth 或 service_account |
GOOGLE_ADS_CUSTOMER_ID | 否 | -- | 默认客户ID(跳过按工具传递) |
GOOGLE_ADS_LOGIN_CUSTOMER_ID | 否 | -- | MCC经理帐户ID |
GOOGLE_ADS_IMPERSONATION_EMAIL | 否 | -- | 服务帐户模拟电子邮件 |
GOOGLE_ADS_ENABLE_MUTATIONS | 没有 | false | 启用写入工具 |
GOOGLE_ADS_ENABLE_EXTENDED_TOOLS | 没有 | false | 启用扩展读取工具(额外11个) |
GOOGLE_ADS_ENV_FILE | 没有 | .env | .env文件的路径(如果存在则加载,从不覆盖现有env) |
GOOGLE_ADS_API_VERSION | 没有 | v23 | 谷歌广告API版本 |
更新
使用 npx @latest (推荐):您始终获得最新版本,无需手动更新。
使用二进制:服务器在启动时检查新版本,如果过时,则记录到stderr:
[mcp-gads] v0.2.0 available (current: v0.1.0). Download: https://github.com/pijusz/mcp-gads/releases/latest检查您安装的版本:
mcp-gads --version要更新,请下载新的二进制文件并替换旧的。
发展
需要 包子.
git clone https://github.com/pijusz/mcp-gads.git
cd mcp-gads
bun install
bun test # tests
bun run build # standalone binary
bun run inspect # MCP Inspector
bun run check # biome format + lint许可证
麻省理工学院
