meta-ads-mcp 0.3.6__tar.gz → 0.3.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.
Files changed (56) hide show
  1. meta_ads_mcp-0.3.8/.github/workflows/publish.yml +39 -0
  2. meta_ads_mcp-0.3.8/.github/workflows/test.yml +56 -0
  3. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/.gitignore +10 -0
  4. meta_ads_mcp-0.3.8/CUSTOM_META_APP.md +110 -0
  5. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/PKG-INFO +94 -191
  6. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/README.md +91 -188
  7. meta_ads_mcp-0.3.8/RELEASE.md +84 -0
  8. meta_ads_mcp-0.3.8/STREAMABLE_HTTP_SETUP.md +350 -0
  9. meta_ads_mcp-0.3.8/debug/README.md +40 -0
  10. meta_ads_mcp-0.3.8/examples/README.md +36 -0
  11. meta_ads_mcp-0.3.8/examples/example_http_client.py +220 -0
  12. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/__init__.py +1 -1
  13. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/api.py +10 -2
  14. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/authentication.py +1 -1
  15. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/campaigns.py +5 -1
  16. meta_ads_mcp-0.3.8/meta_ads_mcp/core/http_auth_integration.py +248 -0
  17. meta_ads_mcp-0.3.8/meta_ads_mcp/core/server.py +381 -0
  18. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/utils.py +6 -2
  19. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/pyproject.toml +3 -3
  20. meta_ads_mcp-0.3.8/requirements.txt +7 -0
  21. meta_ads_mcp-0.3.8/tests/README.md +140 -0
  22. meta_ads_mcp-0.3.8/tests/__init__.py +1 -0
  23. meta_ads_mcp-0.3.8/tests/conftest.py +62 -0
  24. meta_ads_mcp-0.3.8/tests/test_http_transport.py +266 -0
  25. meta_ads_mcp-0.3.6/brands/injurypayouts.com/120221013820800183_76c8b7fd0c627bce0d6ad833682f45e5.jpg +0 -0
  26. meta_ads_mcp-0.3.6/brands/injurypayouts.com/120221013841190183_cc1ff1ad28a037f397fd0e1636e8239a.jpg +0 -0
  27. meta_ads_mcp-0.3.6/brands/injurypayouts.com/120221013863110183_76f042047ce288bfbf9e103ffa10c50f.jpg +0 -0
  28. meta_ads_mcp-0.3.6/debug_meta_api_tool.py +0 -248
  29. meta_ads_mcp-0.3.6/debug_token_flow.py +0 -156
  30. meta_ads_mcp-0.3.6/meta-ads-mcp +0 -50
  31. meta_ads_mcp-0.3.6/meta_ads_mcp/api.py +0 -2087
  32. meta_ads_mcp-0.3.6/meta_ads_mcp/core/server.py +0 -129
  33. meta_ads_mcp-0.3.6/meta_auth_test.sh +0 -4
  34. meta_ads_mcp-0.3.6/requirements.txt +0 -4
  35. meta_ads_mcp-0.3.6/test_meta_ads_auth.py +0 -78
  36. meta_ads_mcp-0.3.6/test_pipeboard_auth.py +0 -323
  37. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/Dockerfile +0 -0
  38. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/LICENSE +0 -0
  39. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/META_API_NOTES.md +0 -0
  40. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/future_improvements.md +0 -0
  41. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/images/meta-ads-example.png +0 -0
  42. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_auth.sh +0 -0
  43. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/__main__.py +0 -0
  44. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/__init__.py +0 -0
  45. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/accounts.py +0 -0
  46. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/ads.py +0 -0
  47. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/ads_library.py +0 -0
  48. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/adsets.py +0 -0
  49. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/auth.py +0 -0
  50. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/budget_schedules.py +0 -0
  51. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/callback_server.py +0 -0
  52. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/insights.py +0 -0
  53. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/pipeboard_auth.py +0 -0
  54. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/resources.py +0 -0
  55. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/setup.py +0 -0
  56. {meta_ads_mcp-0.3.6 → meta_ads_mcp-0.3.8}/smithery.yaml +0 -0
@@ -0,0 +1,39 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ # Allow manual triggering for testing
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+ environment: release
13
+ permissions:
14
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15
+ contents: read
16
+
17
+ steps:
18
+ - name: Check out code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.10"
25
+
26
+ - name: Install build dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install build
30
+
31
+ - name: Build package
32
+ run: python -m build
33
+
34
+ - name: Publish to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
36
+ with:
37
+ # Using trusted publishing (no API token needed)
38
+ # Make sure to configure trusted publishing in PyPI project settings
39
+ verbose: true
@@ -0,0 +1,56 @@
1
+ name: Test and Build
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, master ]
6
+ pull_request:
7
+ branches: [ main, master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - name: Check out code
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install build pytest
29
+ pip install -e .
30
+
31
+ - name: Test package build
32
+ run: python -m build
33
+
34
+ - name: Test package installation
35
+ run: |
36
+ pip install dist/*.whl
37
+ python -c "import meta_ads_mcp; print('Package imported successfully')"
38
+
39
+ validate-version:
40
+ runs-on: ubuntu-latest
41
+ if: github.event_name == 'pull_request'
42
+
43
+ steps:
44
+ - name: Check out code
45
+ uses: actions/checkout@v4
46
+
47
+ - name: Set up Python
48
+ uses: actions/setup-python@v5
49
+ with:
50
+ python-version: "3.10"
51
+
52
+ - name: Check version bump
53
+ run: |
54
+ # This is a simple check - you might want to make it more sophisticated
55
+ echo "Current version in pyproject.toml:"
56
+ grep "version = " pyproject.toml
@@ -20,3 +20,13 @@ uv.lock
20
20
 
21
21
  # Generated content
22
22
  ad_creatives/
23
+
24
+ # Debug and development files
25
+ debug/
26
+ *.pyc
27
+ .pytest_cache/
28
+
29
+ # Keep organized directories but exclude some debug content
30
+ !debug/README.md
31
+
32
+ internal/
@@ -0,0 +1,110 @@
1
+ # Using a Custom Meta Developer App
2
+
3
+ This guide explains how to use Meta Ads MCP with your own Meta Developer App. Note that this is an alternative method - we recommend using [Pipeboard authentication](README.md) for a simpler setup.
4
+
5
+ ## Create a Meta Developer App
6
+
7
+ Before using direct Meta authentication, you'll need to set up a Meta Developer App:
8
+
9
+ 1. Go to [Meta for Developers](https://developers.facebook.com/) and create a new app
10
+ 2. Choose the "Business" app type
11
+ 3. In your app settings, add the "Marketing API" product
12
+ 4. Configure your app's OAuth redirect URI to include `http://localhost:8888/callback`
13
+ 5. Note your App ID (Client ID) for use with the MCP
14
+
15
+ ## Installation & Usage
16
+
17
+ When using your own Meta app, you'll need to provide the App ID:
18
+
19
+ ```bash
20
+ # Using uvx
21
+ uvx meta-ads-mcp --app-id YOUR_META_ADS_APP_ID
22
+
23
+ # Using pip installation
24
+ python -m meta_ads_mcp --app-id YOUR_META_ADS_APP_ID
25
+ ```
26
+
27
+ ## Configuration
28
+
29
+ ### Cursor or Claude Desktop Integration
30
+
31
+ Add this to your `claude_desktop_config.json` or `~/.cursor/mcp.json`:
32
+
33
+ ```json
34
+ "mcpServers": {
35
+ "meta-ads": {
36
+ "command": "uvx",
37
+ "args": ["meta-ads-mcp", "--app-id", "YOUR_META_ADS_APP_ID"]
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Authentication Flow
43
+
44
+ When using direct Meta OAuth, the MCP uses Meta's OAuth 2.0 authentication flow:
45
+
46
+ 1. Starts a local callback server on your machine
47
+ 2. Opens a browser window to authenticate with Meta
48
+ 3. Asks you to authorize the app
49
+ 4. Redirects back to the local server to extract and store the token securely
50
+
51
+ ## Environment Variables
52
+
53
+ You can use these environment variables instead of command-line arguments:
54
+
55
+ ```bash
56
+ # Your Meta App ID
57
+ export META_APP_ID=your_app_id
58
+ uvx meta-ads-mcp
59
+
60
+ # Or provide a direct access token (bypasses local cache)
61
+ export META_ACCESS_TOKEN=your_access_token
62
+ uvx meta-ads-mcp
63
+ ```
64
+
65
+ ## Testing
66
+
67
+ ### CLI Testing
68
+
69
+ Run the test script to verify authentication:
70
+
71
+ ```bash
72
+ # Basic test
73
+ python test_meta_ads_auth.py --app-id YOUR_APP_ID
74
+
75
+ # Force new login
76
+ python test_meta_ads_auth.py --app-id YOUR_APP_ID --force-login
77
+ ```
78
+
79
+ ### LLM Interface Testing
80
+
81
+ When using direct Meta authentication:
82
+ 1. Test authentication by calling the `mcp_meta_ads_get_login_link` tool
83
+ 2. Verify account access by calling `mcp_meta_ads_get_ad_accounts`
84
+ 3. Check specific account details with `mcp_meta_ads_get_account_info`
85
+
86
+ ## Troubleshooting
87
+
88
+ ### Authentication Issues
89
+
90
+ 1. App ID Issues
91
+ - If you encounter errors like `(#200) Provide valid app ID`, verify your App ID is correct
92
+ - Make sure you've completed the app setup steps above
93
+ - Check that your app has the Marketing API product added
94
+
95
+ 2. OAuth Flow
96
+ - Run with `--force-login` to get a fresh token: `uvx meta-ads-mcp --login --app-id YOUR_APP_ID --force-login`
97
+ - Make sure the terminal has permissions to open a browser window
98
+ - Check that the callback server can run on port 8888
99
+
100
+ 3. Direct Token Usage
101
+ - If you have a valid access token, you can bypass the OAuth flow:
102
+ - `export META_ACCESS_TOKEN=your_access_token`
103
+ - This will ignore the local token cache
104
+
105
+ ### API Errors
106
+
107
+ If you receive errors from the Meta API:
108
+ 1. Verify your app has the Marketing API product added
109
+ 2. Ensure the user has appropriate permissions on the ad accounts
110
+ 3. Check if there are rate limits or other restrictions on your app
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meta-ads-mcp
3
- Version: 0.3.6
3
+ Version: 0.3.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
@@ -11,9 +11,9 @@ Keywords: ads,api,claude,facebook,mcp,meta
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
- Requires-Python: >=3.9.6
14
+ Requires-Python: >=3.10
15
15
  Requires-Dist: httpx>=0.26.0
16
- Requires-Dist: mcp[cli]>=1.6.0
16
+ Requires-Dist: mcp[cli]>=1.9.0
17
17
  Requires-Dist: pathlib>=1.0.1
18
18
  Requires-Dist: pillow>=10.0.0
19
19
  Requires-Dist: python-dateutil>=2.8.2
@@ -27,9 +27,35 @@ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for in
27
27
 
28
28
  > **DISCLAIMER:** This is an unofficial third-party tool and is not associated with, endorsed by, or affiliated with Meta in any way. This project is maintained independently and uses Meta's public APIs according to their terms of service. Meta, Facebook, Instagram, and other Meta brand names are trademarks of their respective owners.
29
29
 
30
- **Screenshot**: Using an LLM to understand your ad performance:
30
+ [![Meta Ads MCP Server Demo](https://github.com/user-attachments/assets/3e605cee-d289-414b-814c-6299e7f3383e)](https://github.com/user-attachments/assets/3e605cee-d289-414b-814c-6299e7f3383e)
31
31
 
32
- ![Meta Ads MCP in action: Visualize ad performance metrics and creative details directly in Claude or your favorite MCP client, with rich insights about campaign reach, engagement, and costs](./images/meta-ads-example.png)
32
+
33
+ ## Community & Support
34
+
35
+ - [Discord](https://discord.gg/hNxpJcqM52). Join the community.
36
+ - [Email Support](info@pipeboard.co). Email us for support.
37
+
38
+ ## Quick Start
39
+
40
+ 1. Sign-up to [Pipeboard](https://pipeboard.co) to authenticate with Meta (alternatively, you can setup your own [custom meta app](CUSTOM_META_APP.md))
41
+ 2. Get your Pipeboard token at [pipeboard.co/api-tokens](https://pipeboard.co/api-tokens)
42
+ 3. Add this configuration to your MCP client:
43
+
44
+ ```json
45
+ "mcpServers": {
46
+ "meta-ads": {
47
+ "command": "uvx",
48
+ "args": ["meta-ads-mcp"],
49
+ "env": {
50
+ "PIPEBOARD_API_TOKEN": "your_pipeboard_token" // Get your token at https://pipeboard.co/api-tokens
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ That's it! You can now use Meta Ads MCP in your favorite MCP client.
57
+
58
+ > **Note**: If you prefer to use your own Meta Developer App instead of Pipeboard authentication, see [CUSTOM_META_APP.md](CUSTOM_META_APP.md) for instructions.
33
59
 
34
60
  ## Features
35
61
 
@@ -44,56 +70,80 @@ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for in
44
70
  - **Simple Authentication**: Easy setup with secure OAuth authentication
45
71
  - **Cross-Platform Support**: Works on Windows, macOS, and Linux
46
72
 
47
- ## Installation
73
+ ## Advanced Setup
48
74
 
49
- ### Using uv (recommended)
75
+ ### Development Installation
50
76
 
51
- When using uv no specific installation is needed. We can use uvx to directly run meta-ads-mcp:
77
+ If you're contributing to the project or need to run it directly:
52
78
 
53
79
  ```bash
54
- # Run with Meta authentication
55
- uvx meta-ads-mcp --app-id YOUR_META_ADS_APP_ID
80
+ # From the repository root
81
+ uv pip install -e .
56
82
  ```
57
83
 
58
- If you want to install the package:
84
+ ## Privacy and Security
59
85
 
60
- ```bash
61
- uv pip install meta-ads-mcp
62
- ```
86
+ The Meta Ads MCP follows security best practices:
63
87
 
64
- For development (if you've cloned the repository):
88
+ 1. Tokens are cached in a platform-specific secure location:
89
+ - Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
90
+ - macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
91
+ - Linux: `~/.config/meta-ads-mcp/token_cache.json`
65
92
 
66
- ```bash
67
- # From the repository root
68
- uv pip install -e .
69
- ```
93
+ 2. You do not need to provide your access token for each command; it will be automatically retrieved from the cache.
70
94
 
71
- ### Using pip
95
+ ## Testing
72
96
 
73
- Alternatively, you can install meta-ads-mcp via pip:
97
+ ### LLM Interface Testing
74
98
 
75
- ```bash
76
- pip install meta-ads-mcp
77
- ```
99
+ When using the Meta Ads MCP with an LLM interface (like Claude):
78
100
 
79
- After installation, you can run it as:
101
+ 1. Ensure the PIPEBOARD_API_TOKEN environment variable is set
102
+ 2. Verify account access by calling `mcp_meta_ads_get_ad_accounts`
103
+ 3. Check specific account details with `mcp_meta_ads_get_account_info`
80
104
 
81
- ```bash
82
- # Run with Meta authentication
83
- python -m meta_ads_mcp --app-id YOUR_META_ADS_APP_ID
84
- ```
105
+ ## Troubleshooting
106
+
107
+ ### Authentication Issues
108
+
109
+ If you encounter authentication issues:
110
+
111
+ 1. Verify your Pipeboard setup:
112
+ - Check that `PIPEBOARD_API_TOKEN` is set correctly
113
+ - Verify your token in the Pipeboard dashboard
114
+ - Try forcing a new login: `python test_pipeboard_auth.py --force-login`
115
+
116
+ 2. When using the LLM interface:
117
+ - Ensure the PIPEBOARD_API_TOKEN environment variable is set
118
+ - Check that the callback server is running properly
119
+
120
+ ### API Errors
121
+
122
+ If you receive errors from the Meta API:
123
+ 1. Ensure the user has appropriate permissions on the ad accounts
124
+ 2. Check if there are rate limits or other restrictions
125
+ 3. Verify your Pipeboard token hasn't expired
126
+
127
+ ## Log Location
128
+
129
+ Log files are stored in a platform-specific location:
130
+
131
+ - **macOS**: `~/Library/Application Support/meta-ads-mcp/meta_ads_debug.log`
132
+ - **Windows**: `%APPDATA%\meta-ads-mcp\meta_ads_debug.log`
133
+ - **Linux**: `~/.config/meta-ads-mcp/meta_ads_debug.log`
85
134
 
86
135
  ## Configuration
87
136
 
88
- ### Create a Meta Developer App (Required)
137
+ ### Pipeboard Authentication
89
138
 
90
- Before using the MCP server, you'll need to set up a Meta Developer App:
139
+ The easiest way to use Meta Ads MCP is with Pipeboard authentication:
91
140
 
92
- 1. Go to [Meta for Developers](https://developers.facebook.com/) and create a new app
93
- 2. Choose the "Business" app type
94
- 3. In your app settings, add the "Marketing API" product
95
- 4. Configure your app's OAuth redirect URI to include `http://localhost:8888/callback`
96
- 5. Note your App ID (Client ID) for use with the MCP
141
+ 1. Sign up at [Pipeboard.co](https://pipeboard.co) and generate an API token
142
+ 2. Set the environment variable:
143
+ ```bash
144
+ export PIPEBOARD_API_TOKEN=your_pipeboard_token
145
+ ```
146
+ 3. Run meta-ads-mcp - it will handle authentication automatically
97
147
 
98
148
  ### Usage with Cursor or Claude Desktop
99
149
 
@@ -103,11 +153,18 @@ Add this to your `claude_desktop_config.json` to integrate with Claude or `~/.cu
103
153
  "mcpServers": {
104
154
  "meta-ads": {
105
155
  "command": "uvx",
106
- "args": ["meta-ads-mcp", "--app-id", "YOUR_META_ADS_APP_ID"]
156
+ "args": ["meta-ads-mcp"],
157
+ "env": {
158
+ "PIPEBOARD_API_TOKEN": "your_pipeboard_token" // Get your token at https://pipeboard.co
159
+ }
107
160
  }
108
161
  }
109
162
  ```
110
163
 
164
+ ## Transports
165
+
166
+ Meta Ads MCP uses **stdio transport** by default, which works with MCP clients like Claude Desktop and Cursor. For web applications and direct HTTP API access, see [STREAMABLE_HTTP_SETUP.md](STREAMABLE_HTTP_SETUP.md) for streamable HTTP transport configuration.
167
+
111
168
  ### Available MCP Tools
112
169
 
113
170
  1. `mcp_meta_ads_get_ad_accounts`
@@ -319,157 +376,3 @@ Add this to your `claude_desktop_config.json` to integrate with Claude or `~/.cu
319
376
  - `time_end`: Unix timestamp for when the high demand period should end.
320
377
  - `access_token` (optional): Meta API access token.
321
378
  - Returns: JSON string with the ID of the created budget schedule or an error message.
322
-
323
- ## Authentication
324
-
325
- The Meta Ads MCP uses Meta's OAuth 2.0 authentication flow, designed for desktop apps:
326
-
327
- When authenticating, it will:
328
-
329
- 1. Start a local callback server on your machine
330
- 2. Open a browser window to authenticate with Meta
331
- 3. Ask you to authorize the app
332
- 4. Redirect back to the local server to extract and store the token securely
333
-
334
- This method requires you to [create a Meta Developer App](#create-a-meta-developer-app) as described above.
335
-
336
- ## Troubleshooting and Logging
337
-
338
- The Meta Ads MCP includes a comprehensive logging system to help troubleshoot issues:
339
-
340
- ### Log Location
341
-
342
- Log files are stored in a platform-specific location:
343
-
344
- - **macOS**: `~/Library/Application Support/meta-ads-mcp/meta_ads_debug.log`
345
- - **Windows**: `%APPDATA%\meta-ads-mcp\meta_ads_debug.log`
346
- - **Linux**: `~/.config/meta-ads-mcp/meta_ads_debug.log`
347
-
348
- ### Common Issues
349
-
350
- #### Authentication Issues
351
-
352
- If you encounter errors like `(#200) Provide valid app ID`, check the following:
353
- - Ensure you've set up a Meta Developer App correctly
354
- - Verify that you're passing the correct App ID using one of these methods:
355
- - Set the `META_APP_ID` environment variable: `export META_APP_ID=your_app_id`
356
- - Pass it as a command-line argument: `meta-ads-mcp --app-id your_app_id`
357
-
358
- #### API Errors
359
-
360
- If you receive errors from the Meta API:
361
-
362
- 1. Verify your app has the Marketing API product added
363
- 2. Ensure the user has appropriate permissions on the ad accounts
364
- 3. Check if there are rate limits or other restrictions on your app
365
-
366
- ### Debugging Command
367
-
368
- For specific image download issues, use the built-in diagnostic tool:
369
-
370
- ```python
371
- # Using direct tool call
372
- mcp_meta_ads_debug_image_download(ad_id="your_ad_id")
373
- ```
374
-
375
- This will give you detailed information about the download process and potential issues.
376
-
377
- ## Running with Different App IDs
378
-
379
- If you need to use different Meta App IDs for different purposes:
380
-
381
- ```bash
382
- # Using environment variable
383
- export META_APP_ID=your_app_id
384
- uvx meta-ads-mcp
385
-
386
- # Or using command line argument
387
- uvx meta-ads-mcp --app-id=your_app_id
388
- ```
389
-
390
- ## Privacy and Security
391
-
392
- The Meta Ads MCP follows security best practices:
393
-
394
- 1. Tokens are cached in a platform-specific secure location:
395
- - Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
396
- - macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
397
- - Linux: `~/.config/meta-ads-mcp/token_cache.json`
398
-
399
- 2. You do not need to provide your access token for each command; it will be automatically retrieved from the cache.
400
-
401
- 3. You can set the `META_APP_ID` environment variable instead of passing it as an argument:
402
- ```bash
403
- export META_APP_ID=your_app_id
404
- uvx meta-ads-mcp
405
- ```
406
-
407
- 4. You can provide a direct access token using the `META_ACCESS_TOKEN` environment variable. This bypasses both the local token cache and the Pipeboard authentication method:
408
- ```bash
409
- export META_ACCESS_TOKEN=your_access_token
410
- uvx meta-ads-mcp
411
- ```
412
- This is useful for CI/CD pipelines or when you already have a valid access token from another source.
413
-
414
- ## Testing
415
-
416
- ### CLI Testing
417
-
418
- Run the test script to verify authentication and basic functionality:
419
-
420
- ```bash
421
- python test_meta_ads_auth.py --app-id YOUR_APP_ID
422
- ```
423
-
424
- Use the `--force-login` flag to force a new authentication even if a cached token exists:
425
-
426
- ```bash
427
- python test_meta_ads_auth.py --app-id YOUR_APP_ID --force-login
428
- ```
429
-
430
- ### LLM Interface Testing
431
-
432
- When using the Meta Ads MCP with an LLM interface (like Claude):
433
-
434
- 1. Test authentication by calling the `mcp_meta_ads_get_login_link` tool
435
- 2. Verify account access by calling `mcp_meta_ads_get_ad_accounts`
436
- 3. Check specific account details with `mcp_meta_ads_get_account_info`
437
-
438
- These functions will automatically handle authentication if needed and provide a clickable login link if required.
439
-
440
- ## Troubleshooting
441
-
442
- ### Authentication Issues
443
-
444
- If you encounter authentication issues:
445
-
446
- 1. When using the LLM interface:
447
- - Use the `mcp_meta_ads_get_login_link` tool to generate a fresh authentication link
448
- - Ensure you click the link and complete the authorization flow in your browser
449
- - Check that the callback server is running properly (the tool will report this)
450
-
451
- 2. When using direct Meta OAuth:
452
- - Run with `--force-login` to get a fresh token: `uvx meta-ads-mcp --login --app-id YOUR_APP_ID --force-login`
453
- - Make sure the terminal has permissions to open a browser window
454
-
455
- 3. Skip authentication entirely by providing a token directly:
456
- - If you already have a valid access token, you can bypass the authentication flow:
457
- - `export META_ACCESS_TOKEN=your_access_token`
458
- - This will ignore both the local token cache and the Pipeboard authentication
459
-
460
- ### API Errors
461
-
462
- If you receive errors from the Meta API:
463
-
464
- 1. Verify your app has the Marketing API product added
465
- 2. Ensure the user has appropriate permissions on the ad accounts
466
- 3. Check if there are rate limits or other restrictions on your app
467
-
468
- ## Versioning
469
-
470
- You can check the current version of the package:
471
-
472
- ```python
473
- import meta_ads_mcp
474
- print(meta_ads_mcp.__version__)
475
- ```