adsense-mcp
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 を参照してください。
セットアップ
Google Cloud で AdSense Management API を有効にし、OAuth デスクトップクライアントを作成します。
https://www.googleapis.com/auth/adsense.readonlyスコープが付与されたリフレッシュトークンを取得します。これは秘密にしてください。.env.exampleを安全な環境設定にコピーし、ADSENSE_ACCESS_TOKENまたは OAuth クライアント ID、シークレット、リフレッシュトークンを入力します。インストールしてビルドします:
npm install
npm run build1回限りの 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_accountsadsense_get_accountadsense_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 スコープが必要です。
ライセンス
Available Tools
3 toolsadsense_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
Scored across 3 tools
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.
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.
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.
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
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MCP server for GA4, Google Ads and Search Console. Google OAuth, nothing to install.
Google Ads MCP server — manage campaigns, keywords, and metrics.
Query selected Google and Bing analytics, search, and advertising reports through MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP 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.12MIT
- FlicenseNot gradedqualityDmaintenanceMCP server for Google Ads campaign reporting and management via Claude, enabling GAQL queries, performance metrics, and campaign modifications.-
- AlicenseNot gradedqualityDmaintenanceMCP server for querying Google Analytics accounts, properties, reports, and realtime data using the Data API and Admin API.1Apache 2.0
- AlicenseNot gradedqualityFmaintenanceMCP 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