meta-ads-mcp 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.4
2
+ Name: meta-ads-mcp
3
+ Version: 0.1.0
4
+ Summary: Model Calling Protocol (MCP) plugin for interacting with Meta Ads API
5
+ Project-URL: Homepage, https://github.com/nictuku/meta-ads-mcp
6
+ Project-URL: Bug Tracker, https://github.com/nictuku/meta-ads-mcp/issues
7
+ Author-email: Your Name <your.email@example.com>
8
+ License: MIT
9
+ Keywords: ads,api,claude,facebook,mcp,meta
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.11
14
+ Requires-Dist: httpx>=0.26.0
15
+ Requires-Dist: mcp[cli]>=1.6.0
16
+ Requires-Dist: pathlib>=1.0.1
17
+ Requires-Dist: pillow>=10.0.0
18
+ Requires-Dist: python-dotenv>=1.1.0
19
+ Requires-Dist: requests>=2.32.3
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Meta Ads MCP
23
+
24
+ A [Model Calling Protocol (MCP)](https://github.com/anthropics/anthropic-tools) plugin for interacting with Meta Ads API.
25
+
26
+ ## Features
27
+
28
+ - Seamless authentication with Meta's Graph API for desktop applications
29
+ - Automatic token caching across sessions
30
+ - Cross-platform support (Windows, macOS, Linux)
31
+ - Access to ad accounts, campaigns, ad sets, and ads
32
+ - Image download and analysis capabilities
33
+ - Performance insights
34
+
35
+ ## Setup
36
+
37
+ ### 1. Create a Meta Developer App
38
+
39
+ 1. Go to [Meta for Developers](https://developers.facebook.com/) and create a new app
40
+ 2. Choose the "Consumer" app type
41
+ 3. In your app settings, add the "Marketing API" product
42
+ 4. Configure your app's OAuth redirect URI to include `http://localhost:8888/callback`
43
+ 5. Note your App ID (Client ID) for use with the MCP
44
+
45
+ ### 2. Install the Package
46
+
47
+ #### Using uv (Recommended)
48
+
49
+ Install directly from GitHub:
50
+
51
+ ```bash
52
+ uv pip install git+https://github.com/nictuku/meta-ads-mcp.git
53
+ ```
54
+
55
+ Or if you've cloned the repository:
56
+
57
+ ```bash
58
+ # From the repository root
59
+ uv pip install -e .
60
+ ```
61
+
62
+ #### Using pip
63
+
64
+ ```bash
65
+ pip install git+https://github.com/nictuku/meta-ads-mcp.git
66
+ ```
67
+
68
+ ### 3. Install Dependencies (If installing from source)
69
+
70
+ ```bash
71
+ uv pip install -r requirements.txt
72
+ ```
73
+
74
+ Or:
75
+
76
+ ```bash
77
+ pip install -r requirements.txt
78
+ ```
79
+
80
+ ## Authentication
81
+
82
+ The Meta Ads MCP uses the OAuth 2.0 flow designed for desktop apps. When authenticating, it will:
83
+
84
+ 1. Start a local callback server on your machine
85
+ 2. Open a browser window to authenticate with Meta
86
+ 3. Ask you to authorize the app
87
+ 4. Redirect back to the local server to extract and store the token securely
88
+
89
+ ### Authentication Methods
90
+
91
+ There are two ways to authenticate with the Meta Ads API:
92
+
93
+ 1. **LLM/MCP Interface Authentication** (Recommended)
94
+
95
+ 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.
96
+
97
+ ```
98
+ [Click here to authenticate with Meta Ads API](https://www.facebook.com/dialog/oauth?...)
99
+ ```
100
+
101
+ Just click the link, complete the authorization in your browser, and the token will be automatically captured and stored.
102
+
103
+ 2. **Command Line Authentication**
104
+
105
+ You can also initiate authentication directly from the command line:
106
+
107
+ ```bash
108
+ python meta_ads_generated.py --login --app-id YOUR_APP_ID
109
+ ```
110
+
111
+ Or use the convenience scripts:
112
+
113
+ ```bash
114
+ # On macOS/Linux
115
+ ./login.sh YOUR_APP_ID
116
+
117
+ # On Windows
118
+ login.bat YOUR_APP_ID
119
+ ```
120
+
121
+ ### Token Caching
122
+
123
+ Tokens are cached in a platform-specific secure location:
124
+ - Windows: `%APPDATA%\meta-ads-mcp\token_cache.json`
125
+ - macOS: `~/Library/Application Support/meta-ads-mcp/token_cache.json`
126
+ - Linux: `~/.config/meta-ads-mcp/token_cache.json`
127
+
128
+ You do not need to provide your access token for each command; it will be automatically retrieved from the cache.
129
+
130
+ ## Usage Examples
131
+
132
+ ### Test Authentication
133
+
134
+ ```bash
135
+ python test_meta_ads_auth.py --app-id YOUR_APP_ID
136
+ ```
137
+
138
+ ### Get Ad Accounts
139
+
140
+ ```python
141
+ import asyncio
142
+ from meta_ads_mcp import get_ad_accounts
143
+
144
+ async def main():
145
+ # Token will be automatically retrieved from cache
146
+ accounts_json = await get_ad_accounts()
147
+ print(accounts_json)
148
+
149
+ asyncio.run(main())
150
+ ```
151
+
152
+ ### Get Campaign Details
153
+
154
+ ```python
155
+ import asyncio
156
+ from meta_ads_mcp import get_campaign_details
157
+
158
+ async def main():
159
+ # Provide a campaign ID
160
+ campaign_details = await get_campaign_details(campaign_id="123456789")
161
+ print(campaign_details)
162
+
163
+ asyncio.run(main())
164
+ ```
165
+
166
+ ### Create a Campaign
167
+
168
+ ```python
169
+ import asyncio
170
+ from meta_ads_mcp import create_campaign
171
+
172
+ async def main():
173
+ result = await create_campaign(
174
+ account_id="act_123456789",
175
+ name="Test Campaign via MCP",
176
+ objective="AWARENESS",
177
+ status="PAUSED",
178
+ daily_budget=1000 # $10.00
179
+ )
180
+ print(result)
181
+
182
+ asyncio.run(main())
183
+ ```
184
+
185
+ ## Environment Variables
186
+
187
+ You can set the following environment variables instead of passing them as arguments:
188
+
189
+ - `META_APP_ID`: Your Meta App ID (Client ID)
190
+
191
+ ## Testing
192
+
193
+ ### CLI Testing
194
+
195
+ Run the test script to verify authentication and basic functionality:
196
+
197
+ ```bash
198
+ python test_meta_ads_auth.py --app-id YOUR_APP_ID
199
+ ```
200
+
201
+ Use the `--force-login` flag to force a new authentication even if a cached token exists:
202
+
203
+ ```bash
204
+ python test_meta_ads_auth.py --app-id YOUR_APP_ID --force-login
205
+ ```
206
+
207
+ ### LLM Interface Testing
208
+
209
+ When using the Meta Ads MCP with an LLM interface (like Claude):
210
+
211
+ 1. Test authentication by calling the `get_login_link` tool
212
+ 2. Verify account access by calling `get_ad_accounts`
213
+ 3. Check specific account details with `get_account_info`
214
+
215
+ These functions will automatically handle authentication if needed and provide a clickable login link.
216
+
217
+ ## Troubleshooting
218
+
219
+ ### Authentication Issues
220
+
221
+ If you encounter authentication issues:
222
+
223
+ 1. When using the LLM interface:
224
+ - Use the `get_login_link` tool to generate a fresh authentication link
225
+ - Ensure you click the link and complete the authorization flow in your browser
226
+ - Check that the callback server is running properly (the tool will report this)
227
+
228
+ 2. When using the command line:
229
+ - Run with `--force-login` to get a fresh token: `python meta_ads_generated.py --login --app-id YOUR_APP_ID --force-login`
230
+ - Make sure the terminal has permissions to open a browser window
231
+
232
+ 3. General authentication troubleshooting:
233
+ - Check that your app is properly configured in the Meta Developers portal
234
+ - Ensure your app has the necessary permissions (ads_management, ads_read, business_management)
235
+ - Verify the app's redirect URI includes `http://localhost:8888/callback`
236
+ - Try clearing the token cache (located in platform-specific directories listed in the Token Caching section)
237
+
238
+ ### API Errors
239
+
240
+ If you receive errors from the Meta API:
241
+
242
+ 1. Verify your app has the Marketing API product added
243
+ 2. Ensure the user has appropriate permissions on the ad accounts
244
+ 3. Check if there are rate limits or other restrictions on your app
245
+
246
+ ## Files
247
+
248
+ This repository contains the implementation for the Meta Ads Marketing API Client Protocol (MCP).
249
+
250
+ - `meta_ads_generated.py`: The main MCP implementation for Meta Ads API
@@ -0,0 +1,6 @@
1
+ meta_ads_mcp/__init__.py,sha256=wxUeUJcUa1OcuMQqDjTlMBT5QVYTWdK2Taq6yrGpLOw,466
2
+ meta_ads_mcp/meta_ads_generated.py,sha256=lJDU3347bQNnGmjnD30pS4uT_h7l34rvxcyKIR2CJuk,72997
3
+ meta_ads_mcp-0.1.0.dist-info/METADATA,sha256=IV_vJOI0DIHChre6XAm_1xXV2crCeMXXbh5hdF7B13c,7021
4
+ meta_ads_mcp-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ meta_ads_mcp-0.1.0.dist-info/entry_points.txt,sha256=LKUVEPu7YWYjULD_OQMDIRn3IPql-6ERcxoM2fxWVUQ,77
6
+ meta_ads_mcp-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ meta-ads-login = meta_ads_mcp.meta_ads_generated:login_cli