meta-ads-mcp 0.2.5__tar.gz → 0.2.8__tar.gz
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.
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/PKG-INFO +139 -32
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/README.md +137 -31
- meta_ads_mcp-0.2.8/debug_meta_api_tool.py +248 -0
- meta_ads_mcp-0.2.8/debug_token_flow.py +156 -0
- meta_ads_mcp-0.2.8/meta-ads-mcp +50 -0
- meta_ads_mcp-0.2.8/meta_ads_auth.sh +54 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/__init__.py +3 -1
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/api.py +122 -53
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/__init__.py +2 -1
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/ads.py +61 -1
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/adsets.py +8 -3
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/api.py +29 -1
- meta_ads_mcp-0.2.8/meta_ads_mcp/core/auth.py +514 -0
- meta_ads_mcp-0.2.8/meta_ads_mcp/core/authentication.py +126 -0
- meta_ads_mcp-0.2.8/meta_ads_mcp/core/callback_server.py +958 -0
- meta_ads_mcp-0.2.8/meta_ads_mcp/core/pipeboard_auth.py +484 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/server.py +49 -4
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/utils.py +11 -5
- meta_ads_mcp-0.2.8/meta_auth_test.sh +4 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/pyproject.toml +2 -1
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/test_meta_ads_auth.py +26 -21
- meta_ads_mcp-0.2.8/test_pipeboard_auth.py +323 -0
- meta_ads_mcp-0.2.5/meta-ads-mcp +0 -13
- meta_ads_mcp-0.2.5/meta_ads_mcp/core/auth.py +0 -1693
- meta_ads_mcp-0.2.5/meta_ads_mcp/core/authentication.py +0 -72
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/.gitignore +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/META_API_NOTES.md +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/future_improvements.md +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/images/meta-ads-example.png +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/__main__.py +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/accounts.py +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/campaigns.py +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/insights.py +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/meta_ads_mcp/core/resources.py +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/requirements.txt +0 -0
- {meta_ads_mcp-0.2.5 → meta_ads_mcp-0.2.8}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meta-ads-mcp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Model Calling Protocol (MCP) plugin for interacting with Meta Ads API
|
|
5
5
|
Project-URL: Homepage, https://github.com/nictuku/meta-ads-mcp
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/nictuku/meta-ads-mcp/issues
|
|
@@ -15,6 +15,7 @@ Requires-Dist: httpx>=0.26.0
|
|
|
15
15
|
Requires-Dist: mcp[cli]>=1.6.0
|
|
16
16
|
Requires-Dist: pathlib>=1.0.1
|
|
17
17
|
Requires-Dist: pillow>=10.0.0
|
|
18
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
18
19
|
Requires-Dist: python-dotenv>=1.1.0
|
|
19
20
|
Requires-Dist: requests>=2.32.3
|
|
20
21
|
Description-Content-Type: text/markdown
|
|
@@ -49,6 +50,11 @@ Screenhot: using an LLM to understand your ad performance.
|
|
|
49
50
|
When using uv no specific installation is needed. We can use uvx to directly run meta-ads-mcp:
|
|
50
51
|
|
|
51
52
|
```bash
|
|
53
|
+
# RECOMMENDED: Use with Pipeboard authentication
|
|
54
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token # Get your token at https://pipeboard.co
|
|
55
|
+
uvx meta-ads-mcp
|
|
56
|
+
|
|
57
|
+
# Alternative: Use with direct Meta authentication
|
|
52
58
|
uvx meta-ads-mcp --app-id YOUR_META_ADS_APP_ID
|
|
53
59
|
```
|
|
54
60
|
|
|
@@ -76,15 +82,50 @@ pip install meta-ads-mcp
|
|
|
76
82
|
After installation, you can run it as:
|
|
77
83
|
|
|
78
84
|
```bash
|
|
85
|
+
# RECOMMENDED: Use with Pipeboard authentication
|
|
86
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token # Get your token at https://pipeboard.co
|
|
79
87
|
python -m meta_ads_mcp
|
|
88
|
+
|
|
89
|
+
# Alternative: Use with direct Meta authentication
|
|
90
|
+
python -m meta_ads_mcp --app-id YOUR_META_ADS_APP_ID
|
|
80
91
|
```
|
|
81
92
|
|
|
82
93
|
## Configuration
|
|
83
94
|
|
|
95
|
+
### Quick Start with Pipeboard Authentication (Recommended)
|
|
96
|
+
|
|
97
|
+
The easiest way to configure Meta Ads MCP is using Pipeboard authentication:
|
|
98
|
+
|
|
99
|
+
1. Sign up at [Pipeboard.co](https://pipeboard.co) and generate an API token - **Get your free token at [https://pipeboard.co](https://pipeboard.co)**
|
|
100
|
+
2. Set the environment variable:
|
|
101
|
+
```bash
|
|
102
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token # Token obtainable via https://pipeboard.co
|
|
103
|
+
```
|
|
104
|
+
3. Run meta-ads-mcp without needing to set up a Meta Developer App:
|
|
105
|
+
```bash
|
|
106
|
+
uvx meta-ads-mcp
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This method provides longer-lived tokens (60 days), simplified setup, and automatic token renewal.
|
|
110
|
+
|
|
84
111
|
### Usage with Claude in Cursor
|
|
85
112
|
|
|
86
113
|
Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor:
|
|
87
114
|
|
|
115
|
+
```json
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"meta-ads": {
|
|
118
|
+
"command": "uvx",
|
|
119
|
+
"args": ["meta-ads-mcp"],
|
|
120
|
+
"env": {
|
|
121
|
+
"PIPEBOARD_API_TOKEN": "your_pipeboard_token" // Token obtainable via https://pipeboard.co
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Or if you prefer direct Meta authentication (using your own Facebook app):
|
|
128
|
+
|
|
88
129
|
```json
|
|
89
130
|
"mcpServers": {
|
|
90
131
|
"meta-ads": {
|
|
@@ -187,7 +228,28 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
187
228
|
- `ad_id`: Meta Ads ad ID
|
|
188
229
|
- Returns: The ad image ready for direct visual analysis
|
|
189
230
|
|
|
190
|
-
12. `
|
|
231
|
+
12. `mcp_meta_ads_update_ad`
|
|
232
|
+
- Update an ad with new settings
|
|
233
|
+
- Inputs:
|
|
234
|
+
- `ad_id`: Meta Ads ad ID
|
|
235
|
+
- `status`: Update ad status (ACTIVE, PAUSED, etc.)
|
|
236
|
+
- `bid_amount`: Bid amount in account currency (in cents for USD)
|
|
237
|
+
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
238
|
+
- Returns: Confirmation with updated ad details and a confirmation link
|
|
239
|
+
|
|
240
|
+
13. `mcp_meta_ads_update_adset`
|
|
241
|
+
- Update an ad set with new settings including frequency caps
|
|
242
|
+
- Inputs:
|
|
243
|
+
- `adset_id`: Meta Ads ad set ID
|
|
244
|
+
- `frequency_control_specs`: List of frequency control specifications
|
|
245
|
+
- `bid_strategy`: Bid strategy (e.g., 'LOWEST_COST_WITH_BID_CAP')
|
|
246
|
+
- `bid_amount`: Bid amount in account currency (in cents for USD)
|
|
247
|
+
- `status`: Update ad set status (ACTIVE, PAUSED, etc.)
|
|
248
|
+
- `targeting`: Targeting specifications including targeting_automation
|
|
249
|
+
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
250
|
+
- Returns: Confirmation with updated ad set details and a confirmation link
|
|
251
|
+
|
|
252
|
+
14. `mcp_meta_ads_get_insights`
|
|
191
253
|
- Get performance insights for a campaign, ad set, ad or account
|
|
192
254
|
- Inputs:
|
|
193
255
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
@@ -197,7 +259,7 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
197
259
|
- `level`: Level of aggregation (ad, adset, campaign, account)
|
|
198
260
|
- Returns: Performance metrics for the specified object
|
|
199
261
|
|
|
200
|
-
|
|
262
|
+
15. `mcp_meta_ads_debug_image_download`
|
|
201
263
|
- Debug image download issues and report detailed diagnostics
|
|
202
264
|
- Inputs:
|
|
203
265
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
@@ -205,8 +267,9 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
205
267
|
- `ad_id`: Meta Ads ad ID (optional, used if url is not provided)
|
|
206
268
|
- Returns: Diagnostic information about image download attempts
|
|
207
269
|
|
|
208
|
-
|
|
270
|
+
16. `mcp_meta_ads_get_login_link`
|
|
209
271
|
- Get a clickable login link for Meta Ads authentication
|
|
272
|
+
- NOTE: This method should only be used if you're using your own Facebook app. If using Pipeboard authentication (recommended), set the PIPEBOARD_API_TOKEN environment variable instead (token obtainable via https://pipeboard.co).
|
|
210
273
|
- Inputs:
|
|
211
274
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
212
275
|
- Returns: A clickable resource link for Meta authentication
|
|
@@ -223,13 +286,47 @@ Before using the MCP server, you'll need to set up a Meta Developer App:
|
|
|
223
286
|
|
|
224
287
|
## Authentication
|
|
225
288
|
|
|
226
|
-
The Meta Ads MCP
|
|
289
|
+
The Meta Ads MCP supports two authentication methods:
|
|
290
|
+
|
|
291
|
+
### 1. Pipeboard Authentication (Recommended ⭐)
|
|
292
|
+
|
|
293
|
+
This method uses [Pipeboard.co](https://pipeboard.co) to manage Meta API authentication, providing longer-lived tokens and a simplified flow:
|
|
294
|
+
|
|
295
|
+
1. **Get your Pipeboard token**: Sign up at [https://pipeboard.co](https://pipeboard.co) to generate your free API token
|
|
296
|
+
2. Set the `PIPEBOARD_API_TOKEN` environment variable with your token:
|
|
297
|
+
```bash
|
|
298
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token
|
|
299
|
+
```
|
|
300
|
+
3. Run the Meta Ads MCP normally - it will automatically detect and use Pipeboard authentication:
|
|
301
|
+
```bash
|
|
302
|
+
uvx meta-ads-mcp
|
|
303
|
+
```
|
|
304
|
+
4. The first time you run a command, you'll be provided with a login URL to authorize with Meta
|
|
305
|
+
|
|
306
|
+
**Benefits of Pipeboard authentication:**
|
|
307
|
+
- ✅ Longer-lived tokens (60 days)
|
|
308
|
+
- ✅ No need to configure a Meta Developer App
|
|
309
|
+
- ✅ Simpler setup with just an API token
|
|
310
|
+
- ✅ Automatic token renewal
|
|
311
|
+
|
|
312
|
+
To test the Pipeboard authentication flow:
|
|
313
|
+
```bash
|
|
314
|
+
python test_pipeboard_auth.py --api-token YOUR_PIPEBOARD_TOKEN
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### 2. Direct Meta OAuth (Legacy)
|
|
318
|
+
|
|
319
|
+
The traditional OAuth 2.0 flow designed for desktop apps. This method should only be used if you are using your own Facebook app instead of Pipeboard.
|
|
320
|
+
|
|
321
|
+
When authenticating, it will:
|
|
227
322
|
|
|
228
323
|
1. Start a local callback server on your machine
|
|
229
324
|
2. Open a browser window to authenticate with Meta
|
|
230
325
|
3. Ask you to authorize the app
|
|
231
326
|
4. Redirect back to the local server to extract and store the token securely
|
|
232
327
|
|
|
328
|
+
This method requires you to [create a Meta Developer App](#create-a-meta-developer-app) first.
|
|
329
|
+
|
|
233
330
|
## Troubleshooting and Logging
|
|
234
331
|
|
|
235
332
|
The Meta Ads MCP includes a comprehensive logging system to help troubleshoot issues:
|
|
@@ -244,21 +341,29 @@ Log files are stored in a platform-specific location:
|
|
|
244
341
|
|
|
245
342
|
### Common Issues
|
|
246
343
|
|
|
247
|
-
####
|
|
344
|
+
#### Authentication Issues
|
|
345
|
+
|
|
346
|
+
If you're having authentication problems:
|
|
248
347
|
|
|
249
|
-
|
|
348
|
+
1. **Recommended: Use Pipeboard Authentication**
|
|
349
|
+
- Set `export PIPEBOARD_API_TOKEN=your_token` and retry
|
|
350
|
+
- This provides longer-lived tokens and better reliability
|
|
351
|
+
- Verify your token in the Pipeboard dashboard
|
|
250
352
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
-
|
|
254
|
-
-
|
|
353
|
+
2. For App ID issues (when using direct authentication):
|
|
354
|
+
If you encounter errors like `(#200) Provide valid app ID`, check the following:
|
|
355
|
+
- Ensure you've set up a Meta Developer App correctly
|
|
356
|
+
- Verify that you're passing the correct App ID using one of these methods:
|
|
357
|
+
- Set the `META_APP_ID` environment variable: `export META_APP_ID=your_app_id`
|
|
358
|
+
- Pass it as a command-line argument: `meta-ads-mcp --app-id your_app_id`
|
|
255
359
|
|
|
256
|
-
####
|
|
360
|
+
#### API Errors
|
|
361
|
+
|
|
362
|
+
If you receive errors from the Meta API:
|
|
257
363
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
- Connection errors
|
|
364
|
+
1. Verify your app has the Marketing API product added
|
|
365
|
+
2. Ensure the user has appropriate permissions on the ad accounts
|
|
366
|
+
3. Check if there are rate limits or other restrictions on your app
|
|
262
367
|
|
|
263
368
|
### Debugging Command
|
|
264
369
|
|
|
@@ -289,14 +394,15 @@ uvx meta-ads-mcp --app-id=your_app_id
|
|
|
289
394
|
The Meta Ads MCP follows security best practices:
|
|
290
395
|
|
|
291
396
|
1. Tokens are cached in a platform-specific secure location:
|
|
292
|
-
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
|
|
293
|
-
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
|
|
294
|
-
- Linux: `~/.config/meta-ads-mcp/token_cache.json`
|
|
397
|
+
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json` or `%APPDATA%\meta-ads-mcp\pipeboard_token_cache.json`
|
|
398
|
+
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json` or `~/Library/Application Support/meta-ads-mcp/pipeboard_token_cache.json`
|
|
399
|
+
- Linux: `~/.config/meta-ads-mcp/token_cache.json` or `~/.config/meta-ads-mcp/pipeboard_token_cache.json`
|
|
295
400
|
|
|
296
401
|
2. You do not need to provide your access token for each command; it will be automatically retrieved from the cache.
|
|
297
402
|
|
|
298
403
|
3. You can set the following environment variables instead of passing them as arguments:
|
|
299
|
-
- `META_APP_ID`: Your Meta App ID (Client ID)
|
|
404
|
+
- `META_APP_ID`: Your Meta App ID (Client ID) - for direct OAuth method
|
|
405
|
+
- `PIPEBOARD_API_TOKEN`: Your Pipeboard API token - for Pipeboard authentication method
|
|
300
406
|
|
|
301
407
|
## Testing
|
|
302
408
|
|
|
@@ -318,11 +424,12 @@ python test_meta_ads_auth.py --app-id YOUR_APP_ID --force-login
|
|
|
318
424
|
|
|
319
425
|
When using the Meta Ads MCP with an LLM interface (like Claude):
|
|
320
426
|
|
|
321
|
-
1.
|
|
322
|
-
2.
|
|
323
|
-
3.
|
|
427
|
+
1. If using direct Meta authentication (your own Facebook app), test authentication by calling the `mcp_meta_ads_get_login_link` tool
|
|
428
|
+
2. If using Pipeboard authentication (recommended), ensure the PIPEBOARD_API_TOKEN environment variable is set (token obtainable via https://pipeboard.co)
|
|
429
|
+
3. Verify account access by calling `mcp_meta_ads_get_ad_accounts`
|
|
430
|
+
4. Check specific account details with `mcp_meta_ads_get_account_info`
|
|
324
431
|
|
|
325
|
-
These functions will automatically handle authentication if needed and provide a clickable login link.
|
|
432
|
+
These functions will automatically handle authentication if needed and provide a clickable login link if required.
|
|
326
433
|
|
|
327
434
|
## Troubleshooting
|
|
328
435
|
|
|
@@ -331,20 +438,20 @@ These functions will automatically handle authentication if needed and provide a
|
|
|
331
438
|
If you encounter authentication issues:
|
|
332
439
|
|
|
333
440
|
1. When using the LLM interface:
|
|
334
|
-
-
|
|
441
|
+
- If using direct Meta authentication (your own Facebook app), use the `mcp_meta_ads_get_login_link` tool to generate a fresh authentication link
|
|
442
|
+
- If using Pipeboard authentication (recommended), ensure the PIPEBOARD_API_TOKEN environment variable is set (token obtainable via https://pipeboard.co)
|
|
335
443
|
- Ensure you click the link and complete the authorization flow in your browser
|
|
336
444
|
- Check that the callback server is running properly (the tool will report this)
|
|
337
445
|
|
|
338
|
-
2. When using
|
|
446
|
+
2. When using Pipeboard authentication:
|
|
447
|
+
- Verify your `PIPEBOARD_API_TOKEN` is set correctly (token obtainable via https://pipeboard.co)
|
|
448
|
+
- Check if you need to complete the authorization process by visiting the provided login URL
|
|
449
|
+
- Try forcing a new login: `python test_pipeboard_auth.py --force-login`
|
|
450
|
+
|
|
451
|
+
3. When using direct Meta OAuth:
|
|
339
452
|
- Run with `--force-login` to get a fresh token: `uvx meta-ads-mcp --login --app-id YOUR_APP_ID --force-login`
|
|
340
453
|
- Make sure the terminal has permissions to open a browser window
|
|
341
454
|
|
|
342
|
-
3. General authentication troubleshooting:
|
|
343
|
-
- Check that your app is properly configured in the Meta Developers portal
|
|
344
|
-
- Ensure your app has the necessary permissions (ads_management, ads_read, business_management)
|
|
345
|
-
- Verify the app's redirect URI includes `http://localhost:8888/callback`
|
|
346
|
-
- Try clearing the token cache (located in platform-specific directories listed in the Token Caching section)
|
|
347
|
-
|
|
348
455
|
### API Errors
|
|
349
456
|
|
|
350
457
|
If you receive errors from the Meta API:
|
|
@@ -28,6 +28,11 @@ Screenhot: using an LLM to understand your ad performance.
|
|
|
28
28
|
When using uv no specific installation is needed. We can use uvx to directly run meta-ads-mcp:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
+
# RECOMMENDED: Use with Pipeboard authentication
|
|
32
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token # Get your token at https://pipeboard.co
|
|
33
|
+
uvx meta-ads-mcp
|
|
34
|
+
|
|
35
|
+
# Alternative: Use with direct Meta authentication
|
|
31
36
|
uvx meta-ads-mcp --app-id YOUR_META_ADS_APP_ID
|
|
32
37
|
```
|
|
33
38
|
|
|
@@ -55,15 +60,50 @@ pip install meta-ads-mcp
|
|
|
55
60
|
After installation, you can run it as:
|
|
56
61
|
|
|
57
62
|
```bash
|
|
63
|
+
# RECOMMENDED: Use with Pipeboard authentication
|
|
64
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token # Get your token at https://pipeboard.co
|
|
58
65
|
python -m meta_ads_mcp
|
|
66
|
+
|
|
67
|
+
# Alternative: Use with direct Meta authentication
|
|
68
|
+
python -m meta_ads_mcp --app-id YOUR_META_ADS_APP_ID
|
|
59
69
|
```
|
|
60
70
|
|
|
61
71
|
## Configuration
|
|
62
72
|
|
|
73
|
+
### Quick Start with Pipeboard Authentication (Recommended)
|
|
74
|
+
|
|
75
|
+
The easiest way to configure Meta Ads MCP is using Pipeboard authentication:
|
|
76
|
+
|
|
77
|
+
1. Sign up at [Pipeboard.co](https://pipeboard.co) and generate an API token - **Get your free token at [https://pipeboard.co](https://pipeboard.co)**
|
|
78
|
+
2. Set the environment variable:
|
|
79
|
+
```bash
|
|
80
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token # Token obtainable via https://pipeboard.co
|
|
81
|
+
```
|
|
82
|
+
3. Run meta-ads-mcp without needing to set up a Meta Developer App:
|
|
83
|
+
```bash
|
|
84
|
+
uvx meta-ads-mcp
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This method provides longer-lived tokens (60 days), simplified setup, and automatic token renewal.
|
|
88
|
+
|
|
63
89
|
### Usage with Claude in Cursor
|
|
64
90
|
|
|
65
91
|
Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor:
|
|
66
92
|
|
|
93
|
+
```json
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"meta-ads": {
|
|
96
|
+
"command": "uvx",
|
|
97
|
+
"args": ["meta-ads-mcp"],
|
|
98
|
+
"env": {
|
|
99
|
+
"PIPEBOARD_API_TOKEN": "your_pipeboard_token" // Token obtainable via https://pipeboard.co
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Or if you prefer direct Meta authentication (using your own Facebook app):
|
|
106
|
+
|
|
67
107
|
```json
|
|
68
108
|
"mcpServers": {
|
|
69
109
|
"meta-ads": {
|
|
@@ -166,7 +206,28 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
166
206
|
- `ad_id`: Meta Ads ad ID
|
|
167
207
|
- Returns: The ad image ready for direct visual analysis
|
|
168
208
|
|
|
169
|
-
12. `
|
|
209
|
+
12. `mcp_meta_ads_update_ad`
|
|
210
|
+
- Update an ad with new settings
|
|
211
|
+
- Inputs:
|
|
212
|
+
- `ad_id`: Meta Ads ad ID
|
|
213
|
+
- `status`: Update ad status (ACTIVE, PAUSED, etc.)
|
|
214
|
+
- `bid_amount`: Bid amount in account currency (in cents for USD)
|
|
215
|
+
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
216
|
+
- Returns: Confirmation with updated ad details and a confirmation link
|
|
217
|
+
|
|
218
|
+
13. `mcp_meta_ads_update_adset`
|
|
219
|
+
- Update an ad set with new settings including frequency caps
|
|
220
|
+
- Inputs:
|
|
221
|
+
- `adset_id`: Meta Ads ad set ID
|
|
222
|
+
- `frequency_control_specs`: List of frequency control specifications
|
|
223
|
+
- `bid_strategy`: Bid strategy (e.g., 'LOWEST_COST_WITH_BID_CAP')
|
|
224
|
+
- `bid_amount`: Bid amount in account currency (in cents for USD)
|
|
225
|
+
- `status`: Update ad set status (ACTIVE, PAUSED, etc.)
|
|
226
|
+
- `targeting`: Targeting specifications including targeting_automation
|
|
227
|
+
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
228
|
+
- Returns: Confirmation with updated ad set details and a confirmation link
|
|
229
|
+
|
|
230
|
+
14. `mcp_meta_ads_get_insights`
|
|
170
231
|
- Get performance insights for a campaign, ad set, ad or account
|
|
171
232
|
- Inputs:
|
|
172
233
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
@@ -176,7 +237,7 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
176
237
|
- `level`: Level of aggregation (ad, adset, campaign, account)
|
|
177
238
|
- Returns: Performance metrics for the specified object
|
|
178
239
|
|
|
179
|
-
|
|
240
|
+
15. `mcp_meta_ads_debug_image_download`
|
|
180
241
|
- Debug image download issues and report detailed diagnostics
|
|
181
242
|
- Inputs:
|
|
182
243
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
@@ -184,8 +245,9 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
184
245
|
- `ad_id`: Meta Ads ad ID (optional, used if url is not provided)
|
|
185
246
|
- Returns: Diagnostic information about image download attempts
|
|
186
247
|
|
|
187
|
-
|
|
248
|
+
16. `mcp_meta_ads_get_login_link`
|
|
188
249
|
- Get a clickable login link for Meta Ads authentication
|
|
250
|
+
- NOTE: This method should only be used if you're using your own Facebook app. If using Pipeboard authentication (recommended), set the PIPEBOARD_API_TOKEN environment variable instead (token obtainable via https://pipeboard.co).
|
|
189
251
|
- Inputs:
|
|
190
252
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
191
253
|
- Returns: A clickable resource link for Meta authentication
|
|
@@ -202,13 +264,47 @@ Before using the MCP server, you'll need to set up a Meta Developer App:
|
|
|
202
264
|
|
|
203
265
|
## Authentication
|
|
204
266
|
|
|
205
|
-
The Meta Ads MCP
|
|
267
|
+
The Meta Ads MCP supports two authentication methods:
|
|
268
|
+
|
|
269
|
+
### 1. Pipeboard Authentication (Recommended ⭐)
|
|
270
|
+
|
|
271
|
+
This method uses [Pipeboard.co](https://pipeboard.co) to manage Meta API authentication, providing longer-lived tokens and a simplified flow:
|
|
272
|
+
|
|
273
|
+
1. **Get your Pipeboard token**: Sign up at [https://pipeboard.co](https://pipeboard.co) to generate your free API token
|
|
274
|
+
2. Set the `PIPEBOARD_API_TOKEN` environment variable with your token:
|
|
275
|
+
```bash
|
|
276
|
+
export PIPEBOARD_API_TOKEN=your_pipeboard_token
|
|
277
|
+
```
|
|
278
|
+
3. Run the Meta Ads MCP normally - it will automatically detect and use Pipeboard authentication:
|
|
279
|
+
```bash
|
|
280
|
+
uvx meta-ads-mcp
|
|
281
|
+
```
|
|
282
|
+
4. The first time you run a command, you'll be provided with a login URL to authorize with Meta
|
|
283
|
+
|
|
284
|
+
**Benefits of Pipeboard authentication:**
|
|
285
|
+
- ✅ Longer-lived tokens (60 days)
|
|
286
|
+
- ✅ No need to configure a Meta Developer App
|
|
287
|
+
- ✅ Simpler setup with just an API token
|
|
288
|
+
- ✅ Automatic token renewal
|
|
289
|
+
|
|
290
|
+
To test the Pipeboard authentication flow:
|
|
291
|
+
```bash
|
|
292
|
+
python test_pipeboard_auth.py --api-token YOUR_PIPEBOARD_TOKEN
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 2. Direct Meta OAuth (Legacy)
|
|
296
|
+
|
|
297
|
+
The traditional OAuth 2.0 flow designed for desktop apps. This method should only be used if you are using your own Facebook app instead of Pipeboard.
|
|
298
|
+
|
|
299
|
+
When authenticating, it will:
|
|
206
300
|
|
|
207
301
|
1. Start a local callback server on your machine
|
|
208
302
|
2. Open a browser window to authenticate with Meta
|
|
209
303
|
3. Ask you to authorize the app
|
|
210
304
|
4. Redirect back to the local server to extract and store the token securely
|
|
211
305
|
|
|
306
|
+
This method requires you to [create a Meta Developer App](#create-a-meta-developer-app) first.
|
|
307
|
+
|
|
212
308
|
## Troubleshooting and Logging
|
|
213
309
|
|
|
214
310
|
The Meta Ads MCP includes a comprehensive logging system to help troubleshoot issues:
|
|
@@ -223,21 +319,29 @@ Log files are stored in a platform-specific location:
|
|
|
223
319
|
|
|
224
320
|
### Common Issues
|
|
225
321
|
|
|
226
|
-
####
|
|
322
|
+
#### Authentication Issues
|
|
323
|
+
|
|
324
|
+
If you're having authentication problems:
|
|
227
325
|
|
|
228
|
-
|
|
326
|
+
1. **Recommended: Use Pipeboard Authentication**
|
|
327
|
+
- Set `export PIPEBOARD_API_TOKEN=your_token` and retry
|
|
328
|
+
- This provides longer-lived tokens and better reliability
|
|
329
|
+
- Verify your token in the Pipeboard dashboard
|
|
229
330
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
331
|
+
2. For App ID issues (when using direct authentication):
|
|
332
|
+
If you encounter errors like `(#200) Provide valid app ID`, check the following:
|
|
333
|
+
- Ensure you've set up a Meta Developer App correctly
|
|
334
|
+
- Verify that you're passing the correct App ID using one of these methods:
|
|
335
|
+
- Set the `META_APP_ID` environment variable: `export META_APP_ID=your_app_id`
|
|
336
|
+
- Pass it as a command-line argument: `meta-ads-mcp --app-id your_app_id`
|
|
234
337
|
|
|
235
|
-
####
|
|
338
|
+
#### API Errors
|
|
339
|
+
|
|
340
|
+
If you receive errors from the Meta API:
|
|
236
341
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
- Connection errors
|
|
342
|
+
1. Verify your app has the Marketing API product added
|
|
343
|
+
2. Ensure the user has appropriate permissions on the ad accounts
|
|
344
|
+
3. Check if there are rate limits or other restrictions on your app
|
|
241
345
|
|
|
242
346
|
### Debugging Command
|
|
243
347
|
|
|
@@ -268,14 +372,15 @@ uvx meta-ads-mcp --app-id=your_app_id
|
|
|
268
372
|
The Meta Ads MCP follows security best practices:
|
|
269
373
|
|
|
270
374
|
1. Tokens are cached in a platform-specific secure location:
|
|
271
|
-
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
|
|
272
|
-
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
|
|
273
|
-
- Linux: `~/.config/meta-ads-mcp/token_cache.json`
|
|
375
|
+
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json` or `%APPDATA%\meta-ads-mcp\pipeboard_token_cache.json`
|
|
376
|
+
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json` or `~/Library/Application Support/meta-ads-mcp/pipeboard_token_cache.json`
|
|
377
|
+
- Linux: `~/.config/meta-ads-mcp/token_cache.json` or `~/.config/meta-ads-mcp/pipeboard_token_cache.json`
|
|
274
378
|
|
|
275
379
|
2. You do not need to provide your access token for each command; it will be automatically retrieved from the cache.
|
|
276
380
|
|
|
277
381
|
3. You can set the following environment variables instead of passing them as arguments:
|
|
278
|
-
- `META_APP_ID`: Your Meta App ID (Client ID)
|
|
382
|
+
- `META_APP_ID`: Your Meta App ID (Client ID) - for direct OAuth method
|
|
383
|
+
- `PIPEBOARD_API_TOKEN`: Your Pipeboard API token - for Pipeboard authentication method
|
|
279
384
|
|
|
280
385
|
## Testing
|
|
281
386
|
|
|
@@ -297,11 +402,12 @@ python test_meta_ads_auth.py --app-id YOUR_APP_ID --force-login
|
|
|
297
402
|
|
|
298
403
|
When using the Meta Ads MCP with an LLM interface (like Claude):
|
|
299
404
|
|
|
300
|
-
1.
|
|
301
|
-
2.
|
|
302
|
-
3.
|
|
405
|
+
1. If using direct Meta authentication (your own Facebook app), test authentication by calling the `mcp_meta_ads_get_login_link` tool
|
|
406
|
+
2. If using Pipeboard authentication (recommended), ensure the PIPEBOARD_API_TOKEN environment variable is set (token obtainable via https://pipeboard.co)
|
|
407
|
+
3. Verify account access by calling `mcp_meta_ads_get_ad_accounts`
|
|
408
|
+
4. Check specific account details with `mcp_meta_ads_get_account_info`
|
|
303
409
|
|
|
304
|
-
These functions will automatically handle authentication if needed and provide a clickable login link.
|
|
410
|
+
These functions will automatically handle authentication if needed and provide a clickable login link if required.
|
|
305
411
|
|
|
306
412
|
## Troubleshooting
|
|
307
413
|
|
|
@@ -310,20 +416,20 @@ These functions will automatically handle authentication if needed and provide a
|
|
|
310
416
|
If you encounter authentication issues:
|
|
311
417
|
|
|
312
418
|
1. When using the LLM interface:
|
|
313
|
-
-
|
|
419
|
+
- If using direct Meta authentication (your own Facebook app), use the `mcp_meta_ads_get_login_link` tool to generate a fresh authentication link
|
|
420
|
+
- If using Pipeboard authentication (recommended), ensure the PIPEBOARD_API_TOKEN environment variable is set (token obtainable via https://pipeboard.co)
|
|
314
421
|
- Ensure you click the link and complete the authorization flow in your browser
|
|
315
422
|
- Check that the callback server is running properly (the tool will report this)
|
|
316
423
|
|
|
317
|
-
2. When using
|
|
424
|
+
2. When using Pipeboard authentication:
|
|
425
|
+
- Verify your `PIPEBOARD_API_TOKEN` is set correctly (token obtainable via https://pipeboard.co)
|
|
426
|
+
- Check if you need to complete the authorization process by visiting the provided login URL
|
|
427
|
+
- Try forcing a new login: `python test_pipeboard_auth.py --force-login`
|
|
428
|
+
|
|
429
|
+
3. When using direct Meta OAuth:
|
|
318
430
|
- Run with `--force-login` to get a fresh token: `uvx meta-ads-mcp --login --app-id YOUR_APP_ID --force-login`
|
|
319
431
|
- Make sure the terminal has permissions to open a browser window
|
|
320
432
|
|
|
321
|
-
3. General authentication troubleshooting:
|
|
322
|
-
- Check that your app is properly configured in the Meta Developers portal
|
|
323
|
-
- Ensure your app has the necessary permissions (ads_management, ads_read, business_management)
|
|
324
|
-
- Verify the app's redirect URI includes `http://localhost:8888/callback`
|
|
325
|
-
- Try clearing the token cache (located in platform-specific directories listed in the Token Caching section)
|
|
326
|
-
|
|
327
433
|
### API Errors
|
|
328
434
|
|
|
329
435
|
If you receive errors from the Meta API:
|