
Ads Mcp
io.github.gudlab由 GitHub 账号 gudlab 发布v0.1.1更新于 Nov 3, 2026
MCP server for Google Ads and Meta Ads. Wraps both APIs directly to manage campaigns.
概览
本地 MCP 服务器,让助手直接通过 Google Ads 与 Meta 广告 API 管理搜索广告系列和 Meta 广告。
- 可以做什么
- 查看 Google Ads 广告系列、结构、关键词与出价策略
- 创建暂停状态的搜索广告系列,增删关键词、添加否定关键词、暂停或启用关键词与广告系列
- 查看 Meta 广告账户、广告系列、广告组、广告、创意及审核反馈
- 搜索兴趣与行为定向并估算受众覆盖
- 创建和更新 Meta 广告系列、广告组、创意与广告,上传图片,复制对象
- 按账户、广告系列、广告组或广告拉取带日期预设与细分维度的效果数据
- 适用场景
- 适合希望在自己的机器上让助手起草、检查或汇报 Google 与 Meta 广告投放,而不经过第三方面板或中转服务的场景。适用于已持有自有 API 凭据的广告主或代理商,可先做只读核对,再受控地创建广告系列。
- 运行要求
- 以 stdio 方式在本地运行,通常通过 npm 包的 npx 或本地构建启动,需要 Node.js 和 MCP 客户端。Google Ads 需要 OAuth 客户端 ID 与密钥、开发者令牌、授权步骤生成的刷新令牌和客户 ID,可选 MCC 登录客户 ID。Meta 需要应用 ID 与密钥、System User 访问令牌和广告账户 ID,可选页面、像素和 Graph 版本设置。需要访问 Google 与 Meta API 的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 Ads Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
ads-mcp
An MCP server wrapping the Google Ads API and Meta Marketing API directly, with no third-party quota or middleman. Point an MCP-compatible client at it and manage Search campaigns, keywords, ads, and the full Meta campaign lifecycle (create, publish, monitor, report) against Google's and Meta's own APIs.
Every write tool that could spend money is safe by default: google_ads_create_search_campaign and every Meta create/copy tool always create objects PAUSED. The only tools that can turn spend on are google_ads_set_campaign_status and meta_ads_set_campaign_status / meta_ads_set_ad_set_status / meta_ads_set_ad_status, called explicitly.
Setup
Credentials require logins and business identity only you have; nothing here can be automated. Do not commit .env.
Google Ads
- Google Cloud project + OAuth client: console.cloud.google.com, new (or existing) project, APIs & Services, Credentials, Create OAuth client ID (type: Desktop app). Copy the Client ID/Secret into
.env. - Under that OAuth client, add
http://localhost:8787/oauth2callbackas an authorized redirect URI. - Developer token: ads.google.com/aw/apicenter, apply for a token. Basic access is free and usually approved within a few days; it allows ~15,000 operations/day. Put it in
.envasGOOGLE_ADS_DEVELOPER_TOKEN. - Run
pnpm installthenpnpm google:auth. This opens a browser, you sign in and consent, and it prints a refresh token to paste into.envasGOOGLE_ADS_REFRESH_TOKEN. - Set
GOOGLE_ADS_CUSTOMER_IDto the 10-digit account ID (no dashes) these tools should operate on by default. If that account is managed under an MCC account, also setGOOGLE_ADS_LOGIN_CUSTOMER_IDto the MCC's ID.
Meta Ads (System User token)
A personal user token dies when Facebook shows a login checkpoint (Graph error 190 / subcode 459). A Business Manager System User token is the supported way to keep Marketing API access independent of a person's browser session.
- Meta App: developers.facebook.com, My Apps, Create App (type: Business). Copy the App ID and App Secret from Settings > Basic into
.envasMETA_APP_ID/META_APP_SECRET. - Business Manager: open business.facebook.com > Business Settings.
- Create a System User: Users > System Users > Add. Admin is simplest for ad account + Page + pixel assignment. Name it something like
ads-mcp. - Assign assets to that System User (Add Assets):
- Ad account: allow manage campaigns (or full control).
- Facebook Page used in creatives: allow create content / manage ads (or full control).
- Pixel used for optimization: allow advertise.
- Generate a token: on the System User, Generate New Token. Select the app from step 1. Request at least:
ads_managementads_readbusiness_managementpages_show_listpages_read_engagementpages_manage_ads(needed to create unpublished Page posts / link creatives) Choose a never-expiring token if the UI offers it.
- Put the token in
.envasMETA_ACCESS_TOKEN. Never commit it. - Set
META_AD_ACCOUNT_IDto the numeric account ID (act_prefix optional). Optionally setMETA_PAGE_IDandMETA_PIXEL_IDso create tools do not need them on every call. - Optional:
META_GRAPH_API_VERSIONpins the Graph version. Default isv26.0.
App Review / Development mode. If the app, ad account, Page and pixel all belong to the same Business, a System User token usually works while the app is in Development mode (Standard Access) without App Review. Advanced Access and App Review are required to manage other businesses' ad accounts, or when the app is Live and those permissions are restricted. ads_management and the pages_* permissions are the ones Meta most often holds behind review.
Housing, employment, credit, and (in some regions) financial products and services ads must set special_ad_categories accordingly (HOUSING, EMPLOYMENT, CREDIT, FINANCIAL_PRODUCTS_SERVICES). Those campaigns have extra targeting limits; Advantage+ may be required or forbidden depending on the category.
Call meta_ads_get_account first. If META_APP_ID and META_APP_SECRET are set, the response includes token debug (scopes, expiry).
Graph errors this server rewrites
Running
Once published to npm, it also runs via npx @gudlab/ads-mcp, no local clone needed. Point an MCP-compatible client at it, e.g. in Claude Code's .mcp.json:
Before that's published, point it at the local build instead: command: "node", args: ["/path/to/ads-mcp/dist/index.js"], or command: "pnpm", args: ["dev"] with cwd set to this directory for local iteration.
First real run: verify before trusting it
The Google Ads and Meta Marketing APIs both shift field/enum names across versions, so before relying on any tool here for real campaign work:
- Run
google_ads_list_campaigns/meta_ads_get_account/meta_ads_list_campaignsfirst, read-only, the cheapest way to confirm auth and the client libraries are wired correctly. - Test
google_ads_create_search_campaignormeta_ads_create_campaignon a throwaway name, then check it in the ads UI rather than trusting the tool's own response as proof of correctness. - Only after that, use
*_set_*_statuswithACTIVEon a real campaign.
End-to-end Meta example (always paused until the last step)
Budgets are in the ad account currency (e.g. 20 means 20 GBP, sent to Graph as 2000 minor units).
Tool reference
Google Ads (src/google-ads/tools.ts): list_campaigns, get_campaign_structure, create_search_campaign (always PAUSED), add_keywords, set_keyword_status (pause/enable, reversible), remove_keywords (permanent, requires confirm_delete: true), update_bid_strategy, add_negative_keywords, set_campaign_status (the only enable/spend switch).
Meta Ads (src/meta-ads/tools.ts), all names prefixed meta_ads_:
Privacy and data handling
All credentials stay in your own .env (never committed, see .gitignore) or your MCP client's own env config, and are used only to call Google's and Meta's APIs directly from your machine. This server sends nothing to any third party: no telemetry, no analytics, no relay service. Every request goes straight from your process to googleads.googleapis.com or graph.facebook.com, using your own developer token and access token.
License
MIT, see LICENSE.
来源:README.md,提交 e9c7237
工具
0版本历史
1- v0.1.1最新Sep 22, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分