Skip to main content
Glama
adsense-mcp

adsense-mcp

by SirMacke

AdSense MCP

AdSense Management API v2 からアドホックなデータを抽出する MCP サーバーです。制限のないレポートインターフェースを公開しており、サポートされている AdSense のディメンション、指標、フィルタ、期間、並べ替え順、タイムゾーン、言語、通貨、制限をすべて accounts.reports.generate に渡すことができます。

このサーバーは、読み取り専用の https://www.googleapis.com/auth/adsense.readonly OAuth スコープを使用します。AdSense アカウントに書き込むことはありません。

インストール

公開されたら、MCP クライアントから npx -y @sirmacke/adsense-mcp で実行します。ADSENSE_ACCESS_TOKEN を設定するか、ADSENSE_CLIENT_ID、ADSENSE_CLIENT_SECRET、ADSENSE_REFRESH_TOKEN の3つすべてを設定します。

Related MCP server: google-ads-mcp

セキュリティ

OAuth アクセストークン、リフレッシュトークン、クライアントシークレットは資格情報です。これらをこのリポジトリ、課題トラッカー、シェル履歴、他のユーザーと共有される MCP 設定に置かないでください。漏えいした場合は、すぐに Google Cloud で失効させてください。SECURITY.md を参照してください。

セットアップ

  1. Google Cloud で AdSense Management API を有効にし、OAuth デスクトップクライアントを作成します。

  2. https://www.googleapis.com/auth/adsense.readonly スコープが付与されたリフレッシュトークンを取得します。これは秘密にしてください。

  3. .env.example を安全な環境設定にコピーし、ADSENSE_ACCESS_TOKEN または OAuth クライアント ID、シークレット、リフレッシュトークンを入力します。

  4. インストールしてビルドします:

npm install
npm run build

1回限りの OAuth 認可(gcloud を使用しない場合)

Google Cloud から OAuth デスクトップ クライアントの JSON をダウンロードし、次を実行します:

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

このコマンドは、localhost コールバックで Google の同意画面を開き、クライアント ID、クライアントシークレット、リフレッシュトークンをプライベートなトークンファイルにのみ保存します。それらの値を MCP 設定の ADSENSE_CLIENT_ID、ADSENSE_CLIENT_SECRET、ADSENSE_REFRESH_TOKEN フィールドにコピーします。外部の同意画面を「テスト中」のままにしないでください。リフレッシュトークンは7日で期限切れになります。

Claude Desktop

現在の Claude Desktop ビルドは拡張機能を使用します。npm run package を実行し、設定 → 拡張機能 → 詳細設定 → 拡張機能をインストール から build/adsense-mcp.mcpb をインストールします。OAuth 値の入力を安全に求められます。従来の設定をサポートするインストールでは、代わりに次を追加します:

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

Codex

同等のサーバー定義を Codex MCP 設定に追加します。同じコマンド、引数、環境変数を使用します。このサーバーは標準の MCP stdio トランスポートを使用し、両方のクライアントで動作します。

ツール

  • adsense_list_accounts

  • adsense_get_account

  • adsense_generate_report

レポートリクエストの例: metrics: ["ESTIMATED_EARNINGS", "PAGE_VIEWS", "CLICKS"]、dimensions: ["DATE", "COUNTRY_NAME"]、dateRange: "LAST_7_DAYS"、orderBy: ["-ESTIMATED_EARNINGS"]。

検証

npm test
npm run build

ライブ検証には、上記の OAuth 値と AdSense アカウントも必要です。API のレポートエンドポイントは GET /v2/{account}/reports:generate で、AdSense または AdSense 読み取り専用の OAuth スコープが必要です。

ライセンス

MIT

Available Tools

3 tools
adsense_generate_reportA

Extract any ad-hoc AdSense report. Supply API v2 dimensions, metrics, filters, dates, sorting, and other report parameters. Account is discovered automatically when omitted.

Inputs: metrics (required), limit, account, endDate, +8 more.

adsense_get_accountA

Get one AdSense account by resource name, e.g. accounts/pub-123.

Inputs: account (required).

adsense_list_accountsA

List AdSense accounts available to the authenticated user.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool targets a distinct operation: listing accounts, retrieving a specific account, and generating reports. There is no overlap between these actions, and the report tool even auto-discovers the account, reducing ambiguity.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with the 'adsense_' prefix (list_accounts, get_account, generate_report). This makes the naming predictable and easy to navigate.

    Tool Count4/5

    With 3 tools, the server is on the lower end of the ideal range, but it covers the core AdSense operations: account listing, account retrieval, and report generation. The count feels minimal yet sufficient for a focused server, though slightly thin.

    Completeness3/5

    The surface covers essential account and reporting operations, but lacks other common AdSense resources like ad units, sites, or alerts. This might be a notable gap for agents needing broader management capabilities, though it may be acceptable for a report-focused server.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server for Google AdSense management. Create ad units, generate framework-specific ad code, manage earnings reports, and automate ads.txt — all from your AI assistant.
      12
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      MCP server for Google Ads campaign reporting and management via Claude, enabling GAQL queries, performance metrics, and campaign modifications.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for querying Google Analytics accounts, properties, reports, and realtime data using the Data API and Admin API.
      1
      Apache 2.0
    • A
      license
      Not graded
      quality
      F
      maintenance
      MCP server that provides tools to interact with Google Analytics APIs, enabling account and property retrieval, report running, and custom dimension/metrics access.
      Apache 2.0