@appsyogi/adsense-mcp-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present SuperZero11
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # Google AdSense MCP Server
2
+
3
+ A CLI-installable MCP (Model Context Protocol) server that enables Claude, Cursor, and other AI assistants to interact with your Google AdSense account.
4
+
5
+ ## Features
6
+
7
+ - 📊 **Earnings Summary** - Quick overview of today, yesterday, last 7 days, and monthly earnings
8
+ - 📈 **Detailed Reports** - Generate reports with dimensions (date, site, country, ad unit) and metrics
9
+ - 🔄 **Period Comparison** - Compare performance between time periods
10
+ - 🌐 **Site Status** - Check approval status for all your sites
11
+ - ⚠️ **Alerts & Policy Issues** - Monitor account health and catch violations early
12
+ - 💰 **Payment History** - View payment history and pending earnings
13
+ - 📦 **Ad Units** - List ad units and get embed codes
14
+ - 📤 **CSV Export** - Export reports for further analysis
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npx @appsyogi/adsense-mcp-server init
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ### 1. Initialize (OAuth Setup)
25
+
26
+ ```bash
27
+ npx adsense-mcp init
28
+ ```
29
+
30
+ This will:
31
+ - Open your browser for Google sign-in
32
+ - Request read-only access to your AdSense data
33
+ - Let you select your default account (if you have multiple)
34
+ - Store credentials securely
35
+
36
+ ### 2. Verify Setup
37
+
38
+ ```bash
39
+ npx adsense-mcp doctor
40
+ ```
41
+
42
+ ### 3. Add to Your MCP Client
43
+
44
+ #### VS Code Copilot (`~/.vscode/mcp.json`)
45
+
46
+ ```json
47
+ {
48
+ "servers": {
49
+ "adsense": {
50
+ "command": "npx",
51
+ "args": ["@appsyogi/adsense-mcp-server", "run"],
52
+ "type": "stdio"
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ #### Claude Desktop (`~/Library/Application Support/Claude/claude_desktop_config.json`)
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "adsense": {
64
+ "command": "npx",
65
+ "args": ["@appsyogi/adsense-mcp-server", "run"]
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Available Tools
72
+
73
+ | Tool | Description |
74
+ |------|-------------|
75
+ | `adsense_list_accounts` | List all AdSense accounts you have access to |
76
+ | `adsense_earnings_summary` | Quick earnings overview (today, yesterday, last 7 days, this month) |
77
+ | `adsense_generate_report` | Generate detailed reports with custom dimensions and metrics |
78
+ | `adsense_compare_periods` | Compare performance between two time periods |
79
+ | `adsense_list_sites` | List all sites with their approval status |
80
+ | `adsense_list_alerts` | Get account alerts and warnings |
81
+ | `adsense_list_policy_issues` | Check for policy violations |
82
+ | `adsense_list_payments` | View payment history and pending earnings |
83
+ | `adsense_list_ad_units` | List all ad units |
84
+ | `adsense_get_ad_code` | Get HTML embed code for an ad unit |
85
+ | `adsense_export_csv` | Export report data as CSV |
86
+
87
+ ## Example Conversations
88
+
89
+ ### Check Earnings
90
+ ```
91
+ You: How's my AdSense doing today?
92
+
93
+ Claude: 📊 **AdSense Earnings Summary**
94
+
95
+ | Period | Earnings | Impressions | Clicks | CTR |
96
+ |--------|----------|-------------|--------|-----|
97
+ | Today | $8.45 | 3,200 | 28 | 0.88% |
98
+ | Yesterday | $15.67 | 6,200 | 52 | 0.84% |
99
+ | Last 7 Days | $98.45 | 42,000 | 380 | 0.90% |
100
+ | This Month | $345.67 | 150,000 | 1,350 | 0.90% |
101
+
102
+ You're tracking 16% ahead of last month at this point! 🎉
103
+ ```
104
+
105
+ ### Check Site Status
106
+ ```
107
+ You: Is my new site approved yet?
108
+
109
+ Claude: 📋 **Site Status**
110
+
111
+ | Site | Status | Notes |
112
+ |------|--------|-------|
113
+ | example.com | ✅ READY | Ads serving |
114
+ | blog.example.com | ⏳ GETTING_READY | Under review |
115
+ | newsite.com | ⚠️ NEEDS_ATTENTION | Insufficient content |
116
+ ```
117
+
118
+ ### Generate Report
119
+ ```
120
+ You: Show me earnings by country for last week
121
+
122
+ Claude: [Generates report with COUNTRY_NAME dimension]
123
+ ```
124
+
125
+ ## CLI Commands
126
+
127
+ ### `adsense-mcp init`
128
+ Set up OAuth authentication and select default account.
129
+
130
+ ```bash
131
+ # Interactive setup
132
+ npx adsense-mcp init
133
+
134
+ # Set specific default account
135
+ npx adsense-mcp init --account pub-1234567890123456
136
+
137
+ # Use service account (advanced)
138
+ npx adsense-mcp init --service-account /path/to/key.json
139
+ ```
140
+
141
+ ### `adsense-mcp doctor`
142
+ Verify your setup and check account health.
143
+
144
+ ```bash
145
+ npx adsense-mcp doctor
146
+ ```
147
+
148
+ ### `adsense-mcp run`
149
+ Start the MCP server (typically called by your MCP client).
150
+
151
+ ```bash
152
+ # Use default account
153
+ npx adsense-mcp run
154
+
155
+ # Use specific account
156
+ npx adsense-mcp run --account pub-9876543210987654
157
+
158
+ # Verbose logging
159
+ npx adsense-mcp run --verbose
160
+ ```
161
+
162
+ ## Multi-Account Support
163
+
164
+ If you have multiple AdSense accounts, you can:
165
+
166
+ 1. Select default during `init`
167
+ 2. Override with `--account` flag
168
+ 3. Use `adsense_list_accounts` tool to see all accounts
169
+ 4. Pass `accountId` parameter to any tool
170
+
171
+ ## Data Storage
172
+
173
+ All data is stored locally in `~/.config/adsense-mcp/`:
174
+
175
+ - `config.json` - Default account and settings
176
+ - `tokens.json` - OAuth refresh token (encrypted)
177
+ - `cache.sqlite` - Report cache for faster responses
178
+
179
+ ## Security
180
+
181
+ - **Read-only access** - This server only requests `adsense.readonly` scope
182
+ - **Secure token storage** - Tokens are encrypted using OS keychain (via keytar)
183
+ - **Local only** - All data stays on your machine
184
+ - **No telemetry** - We don't collect any usage data
185
+
186
+ ## Rate Limits
187
+
188
+ The AdSense API has strict rate limits (100 requests/minute). This server:
189
+ - Caches responses intelligently (5min-24hr based on data type)
190
+ - Implements exponential backoff for retries
191
+ - Tracks request rates to avoid hitting limits
192
+
193
+ ## Troubleshooting
194
+
195
+ ### "No tokens found" error
196
+ Run `npx adsense-mcp init` to set up authentication.
197
+
198
+ ### "Rate limit exceeded" error
199
+ Wait a minute and try again. The server will automatically retry with backoff.
200
+
201
+ ### "Account not found" error
202
+ Make sure you've selected a valid account during setup. Run `npx adsense-mcp doctor` to see available accounts.
203
+
204
+ ## License
205
+
206
+ MIT
207
+
208
+ ## Contributing
209
+
210
+ Contributions welcome! Please open an issue or PR on GitHub.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node