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 分