Google AdSense MCP Server β Connect Google AdSense to Claude, Cursor, and other MCP clients.
- π Earnings Summary β Quick overview of today, yesterday, last 7 days, and monthly earnings
- π Detailed Reports β Generate reports with dimensions (date, site, country, ad unit) and metrics
- π Period Comparison β Compare performance between time periods
- π Site Status β Check approval status for all your sites
β οΈ Alerts & Policy Issues β Monitor account health and catch violations early- π° Payment History β View payment history and pending earnings
- π¦ Ad Units β List ad units and get embed codes
- π€ CSV Export β Export reports for further analysis
- πΎ Caching β SQLite cache for faster repeated queries
- π Secure β OAuth tokens stored in OS keychain, read-only scope
# Install globally
npm install -g @appsyogi/adsense-mcp-server
# Set up OAuth credentials
adsense-mcp init
# Verify setup
adsense-mcp doctor
# Start the server (for MCP clients)
adsense-mcp runYou need to create your own OAuth credentials in Google Cloud Console:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the AdSense Management API:
- Go to "APIs & Services" β "Library"
- Search for "AdSense Management API"
- Click "Enable"
- Create OAuth credentials:
- Go to "APIs & Services" β "Credentials"
- Click "Create Credentials" β "OAuth client ID"
- Choose "Desktop application"
- Name it (e.g., "AdSense-MCP")
- Click "Create"
- Copy the Client ID and Client Secret
- Add test users (required while app is in testing mode):
- Go to "APIs & Services" β "OAuth consent screen"
- Scroll to "Test users" section
- Click "Add users"
- Add the Google account email(s) you'll use to authenticate
- Click "Save"
Note: While your app's publishing status is "Testing", only test users can authenticate. You can add up to 100 test users.
Run the init command and enter your credentials:
adsense-mcp initThis will:
- Prompt for your Client ID and Client Secret
- Open a browser for Google authentication
- Store your refresh token securely in the OS keychain
npx @appsyogi/adsense-mcp-server initnpx adsense-mcp initThis will:
- Open your browser for Google sign-in
- Request read-only access to your AdSense data
- Let you select your default account (if you have multiple)
- Store credentials securely
npx adsense-mcp doctor{
"servers": {
"adsense": {
"command": "npx",
"args": ["@appsyogi/adsense-mcp-server", "run"],
"type": "stdio"
}
}
}{
"mcpServers": {
"adsense": {
"command": "npx",
"args": ["@appsyogi/adsense-mcp-server", "run"]
}
}
}| Tool | Description |
|---|---|
adsense_list_accounts |
List all AdSense accounts you have access to |
adsense_earnings_summary |
Quick earnings overview (today, yesterday, last 7 days, this month) |
adsense_generate_report |
Generate detailed reports with custom dimensions and metrics |
adsense_compare_periods |
Compare performance between two time periods |
adsense_list_sites |
List all sites with their approval status |
adsense_list_alerts |
Get account alerts and warnings |
adsense_list_policy_issues |
Check for policy violations |
adsense_list_payments |
View payment history and pending earnings |
adsense_list_ad_units |
List all ad units |
adsense_get_ad_code |
Get HTML embed code for an ad unit |
adsense_export_csv |
Export report data as CSV |
You: How's my AdSense doing today?
Claude: π **AdSense Earnings Summary**
| Period | Earnings | Impressions | Clicks | CTR |
|--------|----------|-------------|--------|-----|
| Today | $8.45 | 3,200 | 28 | 0.88% |
| Yesterday | $15.67 | 6,200 | 52 | 0.84% |
| Last 7 Days | $98.45 | 42,000 | 380 | 0.90% |
| This Month | $345.67 | 150,000 | 1,350 | 0.90% |
You're tracking 16% ahead of last month at this point! π
You: Is my new site approved yet?
Claude: π **Site Status**
| Site | Status | Notes |
|------|--------|-------|
| example.com | β
READY | Ads serving |
| blog.example.com | β³ GETTING_READY | Under review |
| newsite.com | β οΈ NEEDS_ATTENTION | Insufficient content |
You: Show me earnings by country for last week
Claude: [Generates report with COUNTRY_NAME dimension]
Set up OAuth authentication and select default account.
# Interactive setup
npx adsense-mcp init
# Set specific default account
npx adsense-mcp init --account pub-1234567890123456
# Use service account (advanced)
npx adsense-mcp init --service-account /path/to/key.jsonVerify your setup and check account health.
npx adsense-mcp doctorStart the MCP server (typically called by your MCP client).
# Use default account
npx adsense-mcp run
# Use specific account
npx adsense-mcp run --account pub-9876543210987654
# Verbose logging
npx adsense-mcp run --verboseIf you have multiple AdSense accounts, you can:
- Select default during
init - Override with
--accountflag - Use
adsense_list_accountstool to see all accounts - Pass
accountIdparameter to any tool
All data is stored locally in ~/.config/adsense-mcp/:
config.json- Default account and settingstokens.json- OAuth refresh token (encrypted)cache.sqlite- Report cache for faster responses
- Read-only access - This server only requests
adsense.readonlyscope - Secure token storage - Tokens are encrypted using OS keychain (via keytar)
- Local only - All data stays on your machine
- No telemetry - We don't collect any usage data
The AdSense API has strict rate limits (100 requests/minute). This server:
- Caches responses intelligently (5min-24hr based on data type)
- Implements exponential backoff for retries
- Tracks request rates to avoid hitting limits
Run npx adsense-mcp init to set up authentication.
Wait a minute and try again. The server will automatically retry with backoff.
Make sure you've selected a valid account during setup. Run npx adsense-mcp doctor to see available accounts.
# Clone the repo
git clone https://github.com/AppsYogi-com/adsense-mcp-server.git
cd adsense-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Run in dev mode
npm run dev
# Test locally
node dist/cli/index.js doctorMIT
Contributions are welcome! Please open an issue or PR.
Built with: