谷歌广告MCP服务器
一种用于Google广告的模型上下文协议(MCP)服务器 读写功能与谷歌官方的只读MCP服务器不同,这款服务器允许您实际管理您的广告系列。
特性
读取操作
list_accounts-列出所有可访问的Google Ads帐户execute_query-对广告系列、广告组、关键字、指标等运行GAQL查询。
写入操作
create_campaign-创建新活动(为安全起见,默认暂停)create_ad_group-在广告系列中创建广告组add_keywords-将关键字添加到广告组add_negative_keywords-添加负面关键字(活动或广告组级别)create_responsive_search_ad-创建带有标题/描述的注册系统管理人pause_campaign/enable_campaign-切换活动状态pause_ad_group/enable_ad_group-切换广告组状态update_ad_group_bid-更新CPC投标
安全功能
- 干运行模式 -支持所有写入操作
dry_run=True在不执行的情况下进行验证 - 安全默认值 -新活动已创建暂停
- 清晰的反馈 -所有操作都返回成功状态和错误消息
安装
使用紫外线(推荐)
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install the package
uv pip install google-ads-mcp
# Or install from source
git clone https://github.com/maxghenis/google-ads-mcp-rw
cd google-ads-mcp
uv pip install -e .使用pip
pip install google-ads-mcp配置
1.创建Google Ads API凭据
- 去 谷歌广告API中心
- 创建开发人员令牌(或使用现有令牌)
- 在Google Cloud控制台中设置OAuth2凭据
- 生成刷新令牌
2.创建google-ads.yaml
创建一个 google-ads.yaml 使用您的凭据文件:
developer_token: YOUR_DEVELOPER_TOKEN
client_id: YOUR_CLIENT_ID.apps.googleusercontent.com
client_secret: YOUR_CLIENT_SECRET
refresh_token: YOUR_REFRESH_TOKEN
# MCC account ID if using multiple accounts (digits only, no dashes)
login_customer_id: "1234567890"
use_proto_plus: true看 google-ads.yaml.示例 对于模板。
3.设置配置路径(可选)
默认情况下,服务器会查找 google-ads.yaml 在当前目录中。您可以指定自定义位置:
export GOOGLE_ADS_CONFIG_PATH=/path/to/your/google-ads.yaml使用Claude Desktop
添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"google-ads": {
"command": "uv",
"args": ["run", "--with", "google-ads-mcp", "google-ads-mcp"],
"env": {
"GOOGLE_ADS_CONFIG_PATH": "/path/to/your/google-ads.yaml"
}
}
}
}或者,如果全局安装:
{
"mcpServers": {
"google-ads": {
"command": "google-ads-mcp",
"env": {
"GOOGLE_ADS_CONFIG_PATH": "/path/to/your/google-ads.yaml"
}
}
}
}示例工作流
列出您的帐户
Use list_accounts to show me all my Google Ads accounts查询活动绩效
Run this GAQL query for customer ID 1234567890:
SELECT campaign.name, metrics.clicks, metrics.impressions, metrics.cost_micros
FROM campaign
WHERE segments.date DURING LAST_7_DAYS
ORDER BY metrics.clicks DESC使用广告组、关键字和广告创建新的活动
Create a new search campaign called "Q1 Promo" with a $20/day budget,
then add an ad group "Product Keywords" with keywords like "buy widgets",
"widget sale", "best widgets", and create a responsive search ad with
these headlines: "Buy Widgets Now", "50% Off Widgets", "Free Shipping"
and descriptions: "Shop our huge selection of widgets. Free shipping on orders over $50.",
"Premium quality widgets at the best prices. Order today!"
Final URL: https://example.com/widgets添加负面关键字
Add these negative keywords to campaign 19638300165:
- "free"
- "cheap"
- "diy"
- "tutorial"暂停表现不佳的广告组
First, show me all ad groups in campaign 19638300165 with their metrics.
Then pause any ad groups with CTR below 1%.api参考
预算和投标价值
所有货币价值使用 微型 (货币单位的1/1000000):
1,000,000 micros = $1.002,500,000 micros = $2.5010,000,000 micros = $10.00
匹配类型
关键字支持三种匹配类型:
- 宽广的 -显示相关搜索(默认)
- 怎么翻译 -显示查询何时包含短语
- 精确 -仅显示完全匹配的查询
客户ID
客户ID只能是数字,不能是破折号:
- 对的:
1234567890 - 不正确:
123-456-7890
发展
# Clone the repo
git clone https://github.com/maxghenis/google-ads-mcp-rw
cd google-ads-mcp
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src tests
ruff check --fix src tests许可证
MIT许可证-请参阅 许可证 了解详情。
贡献
欢迎投稿!请打开问题或PR。
相关项目
- 谷歌官方的谷歌广告MCP -只读
- MCP协议 -基础协议
- FastMCP -使用的MCP服务器框架
