Google AdSense

io.github.SirMacke由 GitHub 账号 SirMacke 发布v0.2.0更新于 Oct 24, 2026

Read AdSense Management API v2 accounts, inventory, payments, policy, and reports through MCP.

已验证STDIO仅桌面数据与分析商业与电商

概览

AI 生成的概览

以只读方式访问 Google AdSense Management API v2 的账户、广告资源、付款、政策问题和报告。

可以做什么
将 AdSense Management API v2 的只读接口封装为 MCP 工具:账户与子账户、付款、提醒、政策问题、网站、广告客户端、广告单元、广告代码、自定义渠道与网址渠道,以及已保存或临时报告。报告工具支持指标、维度、日期范围和排序。账户级工具在未指定时使用已配置或首个可访问的账户,列表工具支持分页。
适用场景
适合让助手在不做任何修改的前提下查看 AdSense 的收益、广告资源、政策状态和报告数据,用于报表与监控类问题。
运行要求
通过 npm 包 @sirmacke/adsense-mcp 以 stdio 在本地运行,需要 Node.js。需提供 ADSENSE_ACCESS_TOKEN,或同时提供 ADSENSE_CLIENT_ID、ADSENSE_CLIENT_SECRET 和 ADSENSE_REFRESH_TOKEN,可选 ADSENSE_ACCOUNT。需要启用 AdSense Management API 的 Google Cloud 项目及 AdSense 只读 OAuth 权限范围。
安装前请注意
涉及 OAuth 凭据:ADSENSE_ACCESS_TOKEN、ADSENSE_CLIENT_SECRET 和 ADSENSE_REFRESH_TOKEN。不要写入共享配置、代码仓库或 shell 历史,泄露后应立即在 Google Cloud 中撤销。访问为只读,不会写入 AdSense 账户。若 External 同意屏幕停留在 Testing 状态,刷新令牌七天后失效。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Google AdSense,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

AdSense MCP

An MCP server providing read-only access to the AdSense Management API v2: accounts, payments, alerts, policy issues, sites, inventory, ad code, and saved or ad-hoc reports.

The server uses the read-only https://www.googleapis.com/auth/adsense.readonly OAuth scope. It does not write to an AdSense account.

Install

Once published, run it from an MCP client with npx -y @sirmacke/adsense-mcp. Configure either ADSENSE_ACCESS_TOKEN, or all three of ADSENSE_CLIENT_ID, ADSENSE_CLIENT_SECRET, and ADSENSE_REFRESH_TOKEN.

Security

OAuth access tokens, refresh tokens, and client secrets are credentials. Keep them out of this repository, issue trackers, shell history, and MCP configuration that is shared with others. If one is exposed, revoke it in Google Cloud immediately; see SECURITY.md.

Setup

  1. In Google Cloud, enable AdSense Management API and create an OAuth Desktop client.
  2. Obtain a refresh token granted the https://www.googleapis.com/auth/adsense.readonly scope. Keep it secret.
  3. Copy .env.example to your secure environment configuration and populate either ADSENSE_ACCESS_TOKEN or the OAuth client ID, secret, and refresh token.
  4. Install and build:
sh
npm installnpm run build

One-time OAuth authorization (without gcloud)

Download the OAuth Desktop client JSON from Google Cloud, then run:

powershell
$env:ADSENSE_OAUTH_CLIENT_FILE = "C:\secure\adsense-client.json"$env:ADSENSE_TOKEN_FILE = "C:\secure\adsense-oauth.json"npm run authorize

The command opens the Google consent screen on a localhost callback and saves the client ID, client secret, and refresh token only in the private token file. Copy those values to the ADSENSE_CLIENT_ID, ADSENSE_CLIENT_SECRET, and ADSENSE_REFRESH_TOKEN fields of the MCP configuration. Do not leave an External consent screen in Testing: its refresh tokens expire after seven days.

Claude Desktop

Current Claude Desktop builds use extensions. Run npm run package, then install build/adsense-mcp.mcpb from Settings → Extensions → Advanced settings → Install extension. It securely prompts for the OAuth values. On installations that support classic configuration, add this instead:

json
{  "mcpServers": {    "adsense": {      "command": "node",      "args": ["/absolute/path/to/adsense-mcp/dist/index.js"],      "env": {        "ADSENSE_CLIENT_ID": "...",        "ADSENSE_CLIENT_SECRET": "...",        "ADSENSE_REFRESH_TOKEN": "..."      }    }  }}

Codex

Add the equivalent server definition to your Codex MCP configuration, using the same command, arguments, and environment variables. The server uses the standard MCP stdio transport and works in both clients.

Tools

Accounts and account status

  • adsense_list_accounts
  • adsense_get_account
  • adsense_list_child_accounts
  • adsense_list_payments
  • adsense_list_alerts
  • adsense_get_ad_blocking_recovery_tag
  • adsense_list_policy_issues
  • adsense_get_policy_issue
  • adsense_list_sites
  • adsense_get_site

Inventory

  • adsense_list_ad_clients
  • adsense_get_ad_client
  • adsense_get_ad_client_ad_code
  • adsense_list_ad_units
  • adsense_get_ad_unit
  • adsense_get_ad_unit_ad_code
  • adsense_list_linked_custom_channels
  • adsense_list_url_channels
  • adsense_get_url_channel
  • adsense_list_custom_channels
  • adsense_get_custom_channel
  • adsense_list_linked_ad_units

Reports

  • adsense_list_saved_reports
  • adsense_get_saved_report
  • adsense_generate_saved_report
  • adsense_generate_report

Account-level tools discover the configured or first accessible account when account is omitted. Paginated list tools accept pageSize and pageToken; pass a returned nextPageToken to continue. Resource-specific tools accept the canonical names returned by their corresponding list tools.

adsense_list_payments returns paid and unpaid earnings, including the formatted amount and, for paid earnings, the credited date. The AdSense API does not expose bank or payment-method details.

Example report request: metrics: ["ESTIMATED_EARNINGS", "PAGE_VIEWS", "CLICKS"], dimensions: ["DATE", "COUNTRY_NAME"], dateRange: "LAST_7_DAYS", orderBy: ["-ESTIMATED_EARNINGS"].

The server returns structured JSON. The API's duplicate CSV report methods are intentionally omitted because agents can transform the structured response when CSV is needed.

Verify

sh
npm testnpm run build

Live verification also requires the OAuth values above and an AdSense account. Every exposed endpoint accepts the AdSense read-only OAuth scope.

Releasing

Releases are published to both npm and the official MCP Registry. The registry stores discovery metadata from server.json; the installable server itself is distributed through npm.

  1. Update the version consistently in package.json, package-lock.json, server.json (including its npm package entry), mcpb/manifest.json, and the MCP server version in src/index.ts.
  2. Run npm test and npm pack --dry-run to verify the build and published package contents.
  3. Commit and push the release to GitHub.
  4. Publish the public scoped package with npm publish --access public.
  5. Authenticate when necessary with mcp-publisher login github, then run mcp-publisher publish to publish the matching server.json version.

Publish npm before the MCP Registry because registry validation requires the referenced public package version to exist. Published versions are immutable, so corrections require a new version.

License

MIT

来源:README.md,提交 03c4c65

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v0.2.0最新Sep 22, 2026
  2. v0.1.3Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分