meta-ads-mcp 0.2.2__tar.gz → 0.2.4__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.4/META_API_NOTES.md +28 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/PKG-INFO +56 -32
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/README.md +55 -31
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/future_improvements.md +6 -2
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/__init__.py +21 -3
- meta_ads_mcp-0.2.4/meta_ads_mcp/__main__.py +10 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/api.py +360 -273
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/__init__.py +1 -2
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/accounts.py +3 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/ads.py +5 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/adsets.py +52 -28
- meta_ads_mcp-0.2.4/meta_ads_mcp/core/api.py +220 -0
- meta_ads_mcp-0.2.4/meta_ads_mcp/core/auth.py +863 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/authentication.py +11 -4
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/campaigns.py +4 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/insights.py +4 -1
- meta_ads_mcp-0.2.4/meta_ads_mcp/core/server.py +84 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/utils.py +43 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/pyproject.toml +1 -1
- meta_ads_mcp-0.2.2/meta_ads_mcp/core/api.py +0 -211
- meta_ads_mcp-0.2.2/meta_ads_mcp/core/auth.py +0 -416
- meta_ads_mcp-0.2.2/meta_ads_mcp/core/server.py +0 -47
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/.gitignore +0 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta-ads-mcp +0 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/meta_ads_mcp/core/resources.py +0 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/requirements.txt +0 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/setup.py +0 -0
- {meta_ads_mcp-0.2.2 → meta_ads_mcp-0.2.4}/test_meta_ads_auth.py +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Meta Ads API Notes and Limitations
|
|
2
|
+
|
|
3
|
+
## Frequency Cap Visibility
|
|
4
|
+
The Meta Marketing API has some limitations regarding frequency cap visibility:
|
|
5
|
+
|
|
6
|
+
1. **Optimization Goal Dependency**: Frequency cap settings (`frequency_control_specs`) are only visible in API responses for ad sets where the optimization goal is set to REACH. For other optimization goals (like LINK_CLICKS, CONVERSIONS, etc.), the frequency caps will still work but won't be visible through the API.
|
|
7
|
+
|
|
8
|
+
2. **Verifying Frequency Caps**: Since frequency caps may not be directly visible, you can verify they're working by monitoring:
|
|
9
|
+
- The frequency metric in ad insights
|
|
10
|
+
- The ratio between reach and impressions over time
|
|
11
|
+
- The actual frequency cap behavior in the Meta Ads Manager UI
|
|
12
|
+
|
|
13
|
+
## Other API Behaviors to Note
|
|
14
|
+
|
|
15
|
+
1. **Field Visibility**: Some fields may not appear in API responses even when explicitly requested. This doesn't necessarily mean the field isn't set - it may just not be visible through the API.
|
|
16
|
+
|
|
17
|
+
2. **Response Filtering**: The API may filter out empty or default values from responses to reduce payload size. If a field is missing from a response, it might mean:
|
|
18
|
+
- The field is not set
|
|
19
|
+
- The field has a default value
|
|
20
|
+
- The field is not applicable for the current configuration
|
|
21
|
+
|
|
22
|
+
3. **Best Practices**:
|
|
23
|
+
- Always verify important changes through both the API and Meta Ads Manager UI
|
|
24
|
+
- Use insights and metrics to confirm behavioral changes when direct field access is limited
|
|
25
|
+
- Consider the optimization goal when setting up features like frequency caps
|
|
26
|
+
|
|
27
|
+
## Updates and Changes
|
|
28
|
+
Meta frequently updates their API behavior. These notes will be updated as we discover new limitations or changes in the API's behavior.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meta-ads-mcp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
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
|
|
@@ -195,14 +195,7 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
195
195
|
- `ad_id`: Meta Ads ad ID (optional, used if url is not provided)
|
|
196
196
|
- Returns: Diagnostic information about image download attempts
|
|
197
197
|
|
|
198
|
-
14. `
|
|
199
|
-
- Try to save an ad image by using the Marketing API's attachment endpoints
|
|
200
|
-
- Inputs:
|
|
201
|
-
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
202
|
-
- `ad_id`: Meta Ads ad ID
|
|
203
|
-
- Returns: Results of attempts to save the ad image
|
|
204
|
-
|
|
205
|
-
15. `mcp_meta_ads_get_login_link`
|
|
198
|
+
14. `mcp_meta_ads_get_login_link`
|
|
206
199
|
- Get a clickable login link for Meta Ads authentication
|
|
207
200
|
- Inputs:
|
|
208
201
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
@@ -227,42 +220,73 @@ The Meta Ads MCP uses the OAuth 2.0 flow designed for desktop apps. When authent
|
|
|
227
220
|
3. Ask you to authorize the app
|
|
228
221
|
4. Redirect back to the local server to extract and store the token securely
|
|
229
222
|
|
|
230
|
-
|
|
223
|
+
## Troubleshooting and Logging
|
|
224
|
+
|
|
225
|
+
The Meta Ads MCP includes a comprehensive logging system to help troubleshoot issues:
|
|
231
226
|
|
|
232
|
-
|
|
227
|
+
### Log Location
|
|
233
228
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
When using the Meta Ads MCP through an LLM interface (like Claude), simply use any Meta Ads function. If you're not authenticated, the system will automatically provide a clickable Markdown link to complete the authentication flow.
|
|
229
|
+
Log files are stored in a platform-specific location:
|
|
237
230
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
231
|
+
- **macOS**: `~/Library/Application Support/meta-ads-mcp/meta_ads_debug.log`
|
|
232
|
+
- **Windows**: `%APPDATA%\meta-ads-mcp\meta_ads_debug.log`
|
|
233
|
+
- **Linux**: `~/.config/meta-ads-mcp/meta_ads_debug.log`
|
|
241
234
|
|
|
242
|
-
|
|
235
|
+
### Common Issues
|
|
243
236
|
|
|
244
|
-
|
|
237
|
+
#### App ID Issues
|
|
245
238
|
|
|
246
|
-
|
|
239
|
+
If you encounter errors like `(#200) Provide valid app ID`, check the following:
|
|
247
240
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
1. Ensure you've set up a Meta Developer App correctly
|
|
242
|
+
2. Verify that you're passing the correct App ID using one of these methods:
|
|
243
|
+
- Set the `META_APP_ID` environment variable: `export META_APP_ID=your_app_id`
|
|
244
|
+
- Pass it as a command-line argument: `meta-ads-mcp --app-id your_app_id`
|
|
251
245
|
|
|
252
|
-
|
|
246
|
+
#### Authentication Errors
|
|
247
|
+
|
|
248
|
+
Authentication errors can be tracked in the log file. Check for:
|
|
249
|
+
- Token expiration issues
|
|
250
|
+
- App permission problems
|
|
251
|
+
- Connection errors
|
|
252
|
+
|
|
253
|
+
### Debugging Command
|
|
254
|
+
|
|
255
|
+
For specific image download issues, use the built-in diagnostic tool:
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
# Using direct tool call
|
|
259
|
+
mcp_meta_ads_debug_image_download(ad_id="your_ad_id")
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
This will give you detailed information about the download process and potential issues.
|
|
263
|
+
|
|
264
|
+
## Running with Different App IDs
|
|
265
|
+
|
|
266
|
+
If you need to use different Meta App IDs for different purposes:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Using environment variable
|
|
270
|
+
export META_APP_ID=your_app_id
|
|
271
|
+
uvx meta-ads-mcp
|
|
272
|
+
|
|
273
|
+
# Or using command line argument
|
|
274
|
+
uvx meta-ads-mcp --app-id=your_app_id
|
|
275
|
+
```
|
|
253
276
|
|
|
254
|
-
|
|
255
|
-
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
|
|
256
|
-
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
|
|
257
|
-
- Linux: `~/.config/meta-ads-mcp/token_cache.json`
|
|
277
|
+
## Privacy and Security
|
|
258
278
|
|
|
259
|
-
|
|
279
|
+
The Meta Ads MCP follows security best practices:
|
|
260
280
|
|
|
261
|
-
|
|
281
|
+
1. Tokens are cached in a platform-specific secure location:
|
|
282
|
+
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
|
|
283
|
+
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
|
|
284
|
+
- Linux: `~/.config/meta-ads-mcp/token_cache.json`
|
|
262
285
|
|
|
263
|
-
You
|
|
286
|
+
2. You do not need to provide your access token for each command; it will be automatically retrieved from the cache.
|
|
264
287
|
|
|
265
|
-
|
|
288
|
+
3. You can set the following environment variables instead of passing them as arguments:
|
|
289
|
+
- `META_APP_ID`: Your Meta App ID (Client ID)
|
|
266
290
|
|
|
267
291
|
## Testing
|
|
268
292
|
|
|
@@ -174,14 +174,7 @@ Add this to your `claude_desktop_config.json` to integrate with Claude in Cursor
|
|
|
174
174
|
- `ad_id`: Meta Ads ad ID (optional, used if url is not provided)
|
|
175
175
|
- Returns: Diagnostic information about image download attempts
|
|
176
176
|
|
|
177
|
-
14. `
|
|
178
|
-
- Try to save an ad image by using the Marketing API's attachment endpoints
|
|
179
|
-
- Inputs:
|
|
180
|
-
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
181
|
-
- `ad_id`: Meta Ads ad ID
|
|
182
|
-
- Returns: Results of attempts to save the ad image
|
|
183
|
-
|
|
184
|
-
15. `mcp_meta_ads_get_login_link`
|
|
177
|
+
14. `mcp_meta_ads_get_login_link`
|
|
185
178
|
- Get a clickable login link for Meta Ads authentication
|
|
186
179
|
- Inputs:
|
|
187
180
|
- `access_token` (optional): Meta API access token (will use cached token if not provided)
|
|
@@ -206,42 +199,73 @@ The Meta Ads MCP uses the OAuth 2.0 flow designed for desktop apps. When authent
|
|
|
206
199
|
3. Ask you to authorize the app
|
|
207
200
|
4. Redirect back to the local server to extract and store the token securely
|
|
208
201
|
|
|
209
|
-
|
|
202
|
+
## Troubleshooting and Logging
|
|
203
|
+
|
|
204
|
+
The Meta Ads MCP includes a comprehensive logging system to help troubleshoot issues:
|
|
210
205
|
|
|
211
|
-
|
|
206
|
+
### Log Location
|
|
212
207
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
When using the Meta Ads MCP through an LLM interface (like Claude), simply use any Meta Ads function. If you're not authenticated, the system will automatically provide a clickable Markdown link to complete the authentication flow.
|
|
208
|
+
Log files are stored in a platform-specific location:
|
|
216
209
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
210
|
+
- **macOS**: `~/Library/Application Support/meta-ads-mcp/meta_ads_debug.log`
|
|
211
|
+
- **Windows**: `%APPDATA%\meta-ads-mcp\meta_ads_debug.log`
|
|
212
|
+
- **Linux**: `~/.config/meta-ads-mcp/meta_ads_debug.log`
|
|
220
213
|
|
|
221
|
-
|
|
214
|
+
### Common Issues
|
|
222
215
|
|
|
223
|
-
|
|
216
|
+
#### App ID Issues
|
|
224
217
|
|
|
225
|
-
|
|
218
|
+
If you encounter errors like `(#200) Provide valid app ID`, check the following:
|
|
226
219
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
220
|
+
1. Ensure you've set up a Meta Developer App correctly
|
|
221
|
+
2. Verify that you're passing the correct App ID using one of these methods:
|
|
222
|
+
- Set the `META_APP_ID` environment variable: `export META_APP_ID=your_app_id`
|
|
223
|
+
- Pass it as a command-line argument: `meta-ads-mcp --app-id your_app_id`
|
|
230
224
|
|
|
231
|
-
|
|
225
|
+
#### Authentication Errors
|
|
226
|
+
|
|
227
|
+
Authentication errors can be tracked in the log file. Check for:
|
|
228
|
+
- Token expiration issues
|
|
229
|
+
- App permission problems
|
|
230
|
+
- Connection errors
|
|
231
|
+
|
|
232
|
+
### Debugging Command
|
|
233
|
+
|
|
234
|
+
For specific image download issues, use the built-in diagnostic tool:
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
# Using direct tool call
|
|
238
|
+
mcp_meta_ads_debug_image_download(ad_id="your_ad_id")
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
This will give you detailed information about the download process and potential issues.
|
|
242
|
+
|
|
243
|
+
## Running with Different App IDs
|
|
244
|
+
|
|
245
|
+
If you need to use different Meta App IDs for different purposes:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Using environment variable
|
|
249
|
+
export META_APP_ID=your_app_id
|
|
250
|
+
uvx meta-ads-mcp
|
|
251
|
+
|
|
252
|
+
# Or using command line argument
|
|
253
|
+
uvx meta-ads-mcp --app-id=your_app_id
|
|
254
|
+
```
|
|
232
255
|
|
|
233
|
-
|
|
234
|
-
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
|
|
235
|
-
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
|
|
236
|
-
- Linux: `~/.config/meta-ads-mcp/token_cache.json`
|
|
256
|
+
## Privacy and Security
|
|
237
257
|
|
|
238
|
-
|
|
258
|
+
The Meta Ads MCP follows security best practices:
|
|
239
259
|
|
|
240
|
-
|
|
260
|
+
1. Tokens are cached in a platform-specific secure location:
|
|
261
|
+
- Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
|
|
262
|
+
- macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
|
|
263
|
+
- Linux: `~/.config/meta-ads-mcp/token_cache.json`
|
|
241
264
|
|
|
242
|
-
You
|
|
265
|
+
2. You do not need to provide your access token for each command; it will be automatically retrieved from the cache.
|
|
243
266
|
|
|
244
|
-
|
|
267
|
+
3. You can set the following environment variables instead of passing them as arguments:
|
|
268
|
+
- `META_APP_ID`: Your Meta App ID (Client ID)
|
|
245
269
|
|
|
246
270
|
## Testing
|
|
247
271
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# Future Improvements for Meta Ads MCP
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Note about Meta Ads development work
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
If you update the MCP server code, please note that *I* have to restart the MCP server. After the server code is changed, ask me to restart it and then proceed with your testing after I confirm it's restarted.
|
|
6
|
+
|
|
7
|
+
## Access token should remain internal only
|
|
8
|
+
|
|
9
|
+
Don't share it ever with the LLM, only update the auth cache.
|
|
6
10
|
|
|
7
11
|
## Planned Improvement: Ad Set Update Confirmation Flow
|
|
8
12
|
|
|
@@ -7,9 +7,27 @@ with the Claude LLM.
|
|
|
7
7
|
|
|
8
8
|
from meta_ads_mcp.core.server import main
|
|
9
9
|
|
|
10
|
-
__version__ = "0.2.
|
|
10
|
+
__version__ = "0.2.4"
|
|
11
11
|
|
|
12
|
-
__all__ = [
|
|
12
|
+
__all__ = [
|
|
13
|
+
'get_ad_accounts',
|
|
14
|
+
'get_account_info',
|
|
15
|
+
'get_campaigns',
|
|
16
|
+
'get_campaign_details',
|
|
17
|
+
'create_campaign',
|
|
18
|
+
'get_adsets',
|
|
19
|
+
'get_adset_details',
|
|
20
|
+
'update_adset',
|
|
21
|
+
'get_ads',
|
|
22
|
+
'get_ad_details',
|
|
23
|
+
'get_ad_creatives',
|
|
24
|
+
'get_ad_image',
|
|
25
|
+
'get_insights',
|
|
26
|
+
'debug_image_download',
|
|
27
|
+
'get_login_link',
|
|
28
|
+
'login_cli',
|
|
29
|
+
'main'
|
|
30
|
+
]
|
|
13
31
|
|
|
14
32
|
# Import key functions to make them available at package level
|
|
15
33
|
from .core import (
|
|
@@ -27,9 +45,9 @@ from .core import (
|
|
|
27
45
|
get_ad_image,
|
|
28
46
|
get_insights,
|
|
29
47
|
debug_image_download,
|
|
30
|
-
save_ad_image_via_api,
|
|
31
48
|
get_login_link,
|
|
32
49
|
login_cli,
|
|
50
|
+
main
|
|
33
51
|
)
|
|
34
52
|
|
|
35
53
|
# Define a main function to be used as a package entry point
|