meta-ads-mcp 0.3.7__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 (52) hide show
  1. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/.gitignore +10 -0
  2. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/PKG-INFO +12 -4
  3. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/README.md +10 -2
  4. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/RELEASE.md +18 -25
  5. meta_ads_mcp-0.3.8/STREAMABLE_HTTP_SETUP.md +350 -0
  6. meta_ads_mcp-0.3.8/debug/README.md +40 -0
  7. meta_ads_mcp-0.3.8/examples/README.md +36 -0
  8. meta_ads_mcp-0.3.8/examples/example_http_client.py +220 -0
  9. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/__init__.py +1 -1
  10. meta_ads_mcp-0.3.8/meta_ads_mcp/core/http_auth_integration.py +248 -0
  11. meta_ads_mcp-0.3.8/meta_ads_mcp/core/server.py +381 -0
  12. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/pyproject.toml +2 -2
  13. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/requirements.txt +1 -1
  14. meta_ads_mcp-0.3.8/tests/README.md +140 -0
  15. meta_ads_mcp-0.3.8/tests/__init__.py +1 -0
  16. meta_ads_mcp-0.3.8/tests/conftest.py +62 -0
  17. meta_ads_mcp-0.3.8/tests/test_http_transport.py +266 -0
  18. meta_ads_mcp-0.3.7/debug_meta_api_tool.py +0 -248
  19. meta_ads_mcp-0.3.7/debug_token_flow.py +0 -156
  20. meta_ads_mcp-0.3.7/meta-ads-mcp +0 -50
  21. meta_ads_mcp-0.3.7/meta_ads_mcp/api.py +0 -2091
  22. meta_ads_mcp-0.3.7/meta_ads_mcp/core/server.py +0 -129
  23. meta_ads_mcp-0.3.7/meta_auth_test.sh +0 -4
  24. meta_ads_mcp-0.3.7/test_meta_ads_auth.py +0 -78
  25. meta_ads_mcp-0.3.7/test_pipeboard_auth.py +0 -323
  26. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/.github/workflows/publish.yml +0 -0
  27. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/.github/workflows/test.yml +0 -0
  28. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/CUSTOM_META_APP.md +0 -0
  29. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/Dockerfile +0 -0
  30. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/LICENSE +0 -0
  31. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/META_API_NOTES.md +0 -0
  32. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/future_improvements.md +0 -0
  33. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/images/meta-ads-example.png +0 -0
  34. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_auth.sh +0 -0
  35. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/__main__.py +0 -0
  36. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/__init__.py +0 -0
  37. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/accounts.py +0 -0
  38. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/ads.py +0 -0
  39. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/ads_library.py +0 -0
  40. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/adsets.py +0 -0
  41. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/api.py +0 -0
  42. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/auth.py +0 -0
  43. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/authentication.py +0 -0
  44. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/budget_schedules.py +0 -0
  45. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/callback_server.py +0 -0
  46. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/campaigns.py +0 -0
  47. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/insights.py +0 -0
  48. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/pipeboard_auth.py +0 -0
  49. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/resources.py +0 -0
  50. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/meta_ads_mcp/core/utils.py +0 -0
  51. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/setup.py +0 -0
  52. {meta_ads_mcp-0.3.7 → meta_ads_mcp-0.3.8}/smithery.yaml +0 -0
@@ -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/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meta-ads-mcp
3
- Version: 0.3.7
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
@@ -13,7 +13,7 @@ Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
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,10 +27,14 @@ 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)
33
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
+
34
38
  ## Quick Start
35
39
 
36
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))
@@ -157,6 +161,10 @@ Add this to your `claude_desktop_config.json` to integrate with Claude or `~/.cu
157
161
  }
158
162
  ```
159
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
+
160
168
  ### Available MCP Tools
161
169
 
162
170
  1. `mcp_meta_ads_get_ad_accounts`
@@ -4,10 +4,14 @@ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for in
4
4
 
5
5
  > **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.
6
6
 
7
- **Screenshot**: Using an LLM to understand your ad performance:
7
+ [![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)
8
8
 
9
- ![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)
10
9
 
10
+ ## Community & Support
11
+
12
+ - [Discord](https://discord.gg/hNxpJcqM52). Join the community.
13
+ - [Email Support](info@pipeboard.co). Email us for support.
14
+
11
15
  ## Quick Start
12
16
 
13
17
  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))
@@ -134,6 +138,10 @@ Add this to your `claude_desktop_config.json` to integrate with Claude or `~/.cu
134
138
  }
135
139
  ```
136
140
 
141
+ ## Transports
142
+
143
+ 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.
144
+
137
145
  ### Available MCP Tools
138
146
 
139
147
  1. `mcp_meta_ads_get_ad_accounts`
@@ -4,35 +4,27 @@ This repository uses GitHub Actions to automatically publish releases to PyPI. H
4
4
 
5
5
  ## Automated Publishing
6
6
 
7
- ### Setup Required
8
-
9
- 1. **Configure Trusted Publishing on PyPI** (Recommended):
10
- - Go to your PyPI project page: https://pypi.org/manage/project/meta-ads-mcp/
11
- - Navigate to "Publishing" → "Add a new pending publisher"
12
- - Fill in the details:
13
- - Owner: `nictuku` (your GitHub username/org)
14
- - Repository name: `meta-ads-mcp`
15
- - Workflow name: `publish.yml`
16
- - Environment name: `release`
17
-
18
- This eliminates the need for API tokens and is more secure.
7
+ ### Setup Status
19
8
 
20
- 2. **Alternative: API Token Method**:
21
- - If you prefer using API tokens, go to PyPI → Account Settings → API tokens
22
- - Create a token with scope limited to this project
23
- - Add it as a repository secret named `PYPI_API_TOKEN`
24
- - Modify `.github/workflows/publish.yml` to use the token instead of trusted publishing
9
+ **Trusted Publishing Configured**: The repository is already set up with PyPI trusted publishing using the `release` environment.
25
10
 
26
11
  ### Creating a Release
27
12
 
28
- 1. **Update the version** in `pyproject.toml`:
13
+ 1. **Update the version** in both files:
14
+
15
+ In `pyproject.toml`:
29
16
  ```toml
30
17
  version = "0.3.8" # Increment as needed
31
18
  ```
19
+
20
+ In `meta_ads_mcp/__init__.py`:
21
+ ```python
22
+ __version__ = "0.3.8" # Must match pyproject.toml
23
+ ```
32
24
 
33
- 2. **Commit and push** the version change:
25
+ 2. **Commit and push** the version changes:
34
26
  ```bash
35
- git add pyproject.toml
27
+ git add pyproject.toml meta_ads_mcp/__init__.py
36
28
  git commit -m "Bump version to 0.3.8"
37
29
  git push origin main
38
30
  ```
@@ -53,11 +45,11 @@ This repository uses GitHub Actions to automatically publish releases to PyPI. H
53
45
  ## Workflows
54
46
 
55
47
  ### `publish.yml`
56
- - **Triggers**: When a GitHub release is published
48
+ - **Triggers**: When a GitHub release is published, or manual workflow dispatch
57
49
  - **Purpose**: Builds and publishes the package to PyPI
58
- - **Environment**: Uses the `release` environment for additional security
50
+ - **Security**: Uses trusted publishing with OIDC tokens (no API keys needed)
59
51
 
60
- ### `test.yml`
52
+ ### `test.yml` (if present)
61
53
  - **Triggers**: On pushes and pull requests to main/master
62
54
  - **Purpose**: Tests package building and installation across Python versions
63
55
  - **Matrix**: Tests Python 3.10, 3.11, and 3.12
@@ -80,12 +72,13 @@ python -m twine upload dist/*
80
72
  ## Version Management
81
73
 
82
74
  - Follow semantic versioning (SemVer): `MAJOR.MINOR.PATCH`
83
- - Update version in `pyproject.toml` before creating releases
75
+ - **Important**: Update version in BOTH `pyproject.toml` and `meta_ads_mcp/__init__.py`
84
76
  - The git tag should match the version (e.g., `v0.3.8` for version `0.3.8`)
77
+ - Keep versions synchronized between the two files
85
78
 
86
79
  ## Security Notes
87
80
 
88
81
  - Trusted publishing is preferred over API tokens
89
- - The `release` environment can be configured with additional protection rules
82
+ - Uses GitHub's OIDC tokens for secure authentication to PyPI
90
83
  - Only maintainers should be able to create releases
91
84
  - All builds run in isolated GitHub-hosted runners
@@ -0,0 +1,350 @@
1
+ # Streamable HTTP Transport Setup
2
+
3
+ ## Overview
4
+
5
+ Meta Ads MCP supports **Streamable HTTP Transport**, which allows you to run the server as a standalone HTTP API. This enables direct integration with web applications, custom dashboards, and any system that can make HTTP requests.
6
+
7
+ ## Quick Start
8
+
9
+ ### 1. Start the HTTP Server
10
+
11
+ ```bash
12
+ # Basic HTTP server (default: localhost:8080)
13
+ python -m meta_ads_mcp --transport streamable-http
14
+
15
+ # Custom host and port
16
+ python -m meta_ads_mcp --transport streamable-http --host 0.0.0.0 --port 9000
17
+ ```
18
+
19
+ ### 2. Set Authentication
20
+
21
+ Set your Pipeboard token as an environment variable. This is optional for HTTP transport if you provide the token in the header, but it can be useful for command-line use.
22
+
23
+ ```bash
24
+ export PIPEBOARD_API_TOKEN=your_pipeboard_token
25
+ ```
26
+
27
+ ### 3. Make HTTP Requests
28
+
29
+ The server accepts JSON-RPC 2.0 requests at the `/mcp/` endpoint. Use the `Authorization` header to provide your token.
30
+
31
+ ```bash
32
+ curl -X POST http://localhost:8080/mcp/ \
33
+ -H "Content-Type: application/json" \
34
+ -H "Accept: application/json, text/event-stream" \
35
+ -H "Authorization: Bearer your_pipeboard_token" \
36
+ -d '{
37
+ "jsonrpc": "2.0",
38
+ "method": "tools/call",
39
+ "id": 1,
40
+ "params": {
41
+ "name": "get_ad_accounts",
42
+ "arguments": {"limit": 5}
43
+ }
44
+ }'
45
+ ```
46
+
47
+ ## Configuration Options
48
+
49
+ ### Command Line Arguments
50
+
51
+ | Argument | Description | Default |
52
+ |----------|-------------|---------|
53
+ | `--transport` | Transport mode | `stdio` |
54
+ | `--host` | Server host address | `localhost` |
55
+ | `--port` | Server port | `8080` |
56
+
57
+ ### Examples
58
+
59
+ ```bash
60
+ # Local development server
61
+ python -m meta_ads_mcp --transport streamable-http --host localhost --port 8080
62
+
63
+ # Production server (accessible externally)
64
+ python -m meta_ads_mcp --transport streamable-http --host 0.0.0.0 --port 8080
65
+
66
+ # Custom port
67
+ python -m meta_ads_mcp --transport streamable-http --port 9000
68
+ ```
69
+
70
+ ## Authentication
71
+
72
+ ### Primary Method: Bearer Token (Recommended)
73
+
74
+ 1. Sign up at [Pipeboard.co](https://pipeboard.co)
75
+ 2. Generate an API token at [pipeboard.co/api-tokens](https://pipeboard.co/api-tokens)
76
+ 3. Include the token in the `Authorization` HTTP header:
77
+
78
+ ```bash
79
+ curl -H "Authorization: Bearer your_pipeboard_token" \
80
+ -X POST http://localhost:8080/mcp/ \
81
+ -H "Content-Type: application/json" \
82
+ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
83
+ ```
84
+
85
+ ### Alternative Method: Direct Meta Token
86
+
87
+ If you have a Meta Developer App, you can use a direct access token via the `X-META-ACCESS-TOKEN` header. This is less common.
88
+
89
+ ```bash
90
+ curl -H "X-META-ACCESS-TOKEN: your_meta_access_token" \
91
+ -X POST http://localhost:8080/mcp/ \
92
+ -H "Content-Type: application/json" \
93
+ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
94
+ ```
95
+
96
+ ## Available Endpoints
97
+
98
+ ### Server URL Structure
99
+
100
+ **Base URL**: `http://localhost:8080`
101
+ **MCP Endpoint**: `/mcp/`
102
+
103
+ ### MCP Protocol Methods
104
+
105
+ | Method | Description |
106
+ |--------|-------------|
107
+ | `initialize` | Initialize MCP session and exchange capabilities |
108
+ | `tools/list` | Get list of all available Meta Ads tools |
109
+ | `tools/call` | Execute a specific tool with parameters |
110
+
111
+ ### Response Format
112
+
113
+ All responses follow JSON-RPC 2.0 format:
114
+
115
+ ```json
116
+ {
117
+ "jsonrpc": "2.0",
118
+ "id": 1,
119
+ "result": {
120
+ // Tool response data
121
+ }
122
+ }
123
+ ```
124
+
125
+ ## Example Usage
126
+
127
+ ### 1. Initialize Session
128
+
129
+ ```bash
130
+ curl -X POST http://localhost:8080/mcp/ \
131
+ -H "Content-Type: application/json" \
132
+ -H "Authorization: Bearer your_token" \
133
+ -d '{
134
+ "jsonrpc": "2.0",
135
+ "method": "initialize",
136
+ "id": 1,
137
+ "params": {
138
+ "protocolVersion": "2024-11-05",
139
+ "capabilities": {"roots": {"listChanged": true}},
140
+ "clientInfo": {"name": "my-app", "version": "1.0.0"}
141
+ }
142
+ }'
143
+ ```
144
+
145
+ ### 2. List Available Tools
146
+
147
+ ```bash
148
+ curl -X POST http://localhost:8080/mcp/ \
149
+ -H "Content-Type: application/json" \
150
+ -H "Authorization: Bearer your_token" \
151
+ -d '{
152
+ "jsonrpc": "2.0",
153
+ "method": "tools/list",
154
+ "id": 2
155
+ }'
156
+ ```
157
+
158
+ ### 3. Get Ad Accounts
159
+
160
+ ```bash
161
+ curl -X POST http://localhost:8080/mcp/ \
162
+ -H "Content-Type: application/json" \
163
+ -H "Authorization: Bearer your_token" \
164
+ -d '{
165
+ "jsonrpc": "2.0",
166
+ "method": "tools/call",
167
+ "id": 3,
168
+ "params": {
169
+ "name": "get_ad_accounts",
170
+ "arguments": {"limit": 10}
171
+ }
172
+ }'
173
+ ```
174
+
175
+ ### 4. Get Campaign Performance
176
+
177
+ ```bash
178
+ curl -X POST http://localhost:8080/mcp/ \
179
+ -H "Content-Type: application/json" \
180
+ -H "Authorization: Bearer your_token" \
181
+ -d '{
182
+ "jsonrpc": "2.0",
183
+ "method": "tools/call",
184
+ "id": 4,
185
+ "params": {
186
+ "name": "get_insights",
187
+ "arguments": {
188
+ "object_id": "act_701351919139047",
189
+ "time_range": "last_30d",
190
+ "level": "campaign"
191
+ }
192
+ }
193
+ }'
194
+ ```
195
+
196
+ ## Client Examples
197
+
198
+ ### Python Client
199
+
200
+ ```python
201
+ import requests
202
+ import json
203
+
204
+ class MetaAdsMCPClient:
205
+ def __init__(self, base_url="http://localhost:8080", token=None):
206
+ self.base_url = base_url
207
+ self.endpoint = f"{base_url}/mcp/"
208
+ self.headers = {
209
+ "Content-Type": "application/json",
210
+ "Accept": "application/json, text/event-stream"
211
+ }
212
+ if token:
213
+ self.headers["Authorization"] = f"Bearer {token}"
214
+
215
+ def call_tool(self, tool_name, arguments=None):
216
+ payload = {
217
+ "jsonrpc": "2.0",
218
+ "method": "tools/call",
219
+ "id": 1,
220
+ "params": {"name": tool_name}
221
+ }
222
+ if arguments:
223
+ payload["params"]["arguments"] = arguments
224
+
225
+ response = requests.post(self.endpoint, headers=self.headers, json=payload)
226
+ return response.json()
227
+
228
+ # Usage
229
+ client = MetaAdsMCPClient(token="your_pipeboard_token")
230
+ result = client.call_tool("get_ad_accounts", {"limit": 5})
231
+ print(json.dumps(result, indent=2))
232
+ ```
233
+
234
+ ### JavaScript/Node.js Client
235
+
236
+ ```javascript
237
+ const axios = require('axios');
238
+
239
+ class MetaAdsMCPClient {
240
+ constructor(baseUrl = 'http://localhost:8080', token = null) {
241
+ this.baseUrl = baseUrl;
242
+ this.endpoint = `${baseUrl}/mcp/`;
243
+ this.headers = {
244
+ 'Content-Type': 'application/json',
245
+ 'Accept': 'application/json, text/event-stream'
246
+ };
247
+ if (token) {
248
+ this.headers['Authorization'] = `Bearer ${token}`;
249
+ }
250
+ }
251
+
252
+ async callTool(toolName, arguments = null) {
253
+ const payload = {
254
+ jsonrpc: '2.0',
255
+ method: 'tools/call',
256
+ id: 1,
257
+ params: { name: toolName }
258
+ };
259
+ if (arguments) {
260
+ payload.params.arguments = arguments;
261
+ }
262
+
263
+ try {
264
+ const response = await axios.post(this.endpoint, payload, { headers: this.headers });
265
+ return response.data;
266
+ } catch (error) {
267
+ return { error: error.message };
268
+ }
269
+ }
270
+ }
271
+
272
+ // Usage
273
+ const client = new MetaAdsMCPClient('http://localhost:8080', 'your_pipeboard_token');
274
+ client.callTool('get_ad_accounts', { limit: 5 })
275
+ .then(result => console.log(JSON.stringify(result, null, 2)));
276
+ ```
277
+
278
+ ## Production Deployment
279
+
280
+ ### Security Considerations
281
+
282
+ 1. **Use HTTPS**: In production, run behind a reverse proxy with SSL/TLS
283
+ 2. **Authentication**: Always use valid Bearer tokens.
284
+ 3. **Network Security**: Configure firewalls and access controls appropriately
285
+ 4. **Rate Limiting**: Consider implementing rate limiting for public APIs
286
+
287
+ ### Docker Deployment
288
+
289
+ ```dockerfile
290
+ FROM python:3.10-slim
291
+
292
+ WORKDIR /app
293
+ COPY . .
294
+ RUN pip install -e .
295
+
296
+ EXPOSE 8080
297
+
298
+ CMD ["python", "-m", "meta_ads_mcp", "--transport", "streamable-http", "--host", "0.0.0.0", "--port", "8080"]
299
+ ```
300
+
301
+ ### Environment Variables
302
+
303
+ ```bash
304
+ # For Pipeboard-based authentication. The token will be used for stdio,
305
+ # but for HTTP it should be passed in the Authorization header.
306
+ export PIPEBOARD_API_TOKEN=your_pipeboard_token
307
+
308
+ # Optional (for custom Meta apps)
309
+ export META_APP_ID=your_app_id
310
+ export META_APP_SECRET=your_app_secret
311
+
312
+ # Optional (for direct Meta token)
313
+ export META_ACCESS_TOKEN=your_access_token
314
+ ```
315
+
316
+ ## Troubleshooting
317
+
318
+ ### Common Issues
319
+
320
+ 1. **Connection Refused**: Ensure the server is running and accessible on the specified port.
321
+ 2. **Authentication Failed**: Verify your Bearer token is valid and included in the `Authorization` header.
322
+ 3. **404 Not Found**: Make sure you're using the correct endpoint (`/mcp/`).
323
+ 4. **JSON-RPC Errors**: Check that your request follows the JSON-RPC 2.0 format.
324
+
325
+ ### Debug Mode
326
+
327
+ Enable verbose logging by setting the log level in your environment if the application supports it, or check the application's logging configuration. The current implementation logs to a file.
328
+
329
+ ### Health Check
330
+
331
+ Test if the server is running by sending a `tools/list` request:
332
+
333
+ ```bash
334
+ curl -X POST http://localhost:8080/mcp/ \
335
+ -H "Content-Type: application/json" \
336
+ -H "Authorization: Bearer your_token" \
337
+ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
338
+ ```
339
+
340
+ ## Migration from stdio
341
+
342
+ If you're currently using stdio transport with MCP clients, you can support both stdio for local clients and HTTP for web applications. The application can only run in one mode at a time, so you may need to run two separate instances if you need both simultaneously.
343
+
344
+ 1. **Keep existing MCP client setup** (Claude Desktop, Cursor, etc.) using stdio.
345
+ 2. **Add HTTP transport** for web applications and custom integrations by running a separate server instance with the `--transport streamable-http` flag.
346
+ 3. **Use the same authentication method**:
347
+ - For stdio, the `PIPEBOARD_API_TOKEN` environment variable is used.
348
+ - For HTTP, pass the token in the `Authorization: Bearer <token>` header.
349
+
350
+ Both transports access the same Meta Ads functionality and use the same underlying authentication system.
@@ -0,0 +1,40 @@
1
+ # Debug and Legacy Files
2
+
3
+ This directory contains debug scripts, development tools, and legacy test files that were used during the development process.
4
+
5
+ ## 🚨 **Important Note**
6
+ These files are **NOT** for production use. They are kept for:
7
+ - Development reference
8
+ - Debugging specific issues
9
+ - Historical context of implementation decisions
10
+
11
+ ## Files
12
+
13
+ ### Authentication & Token Flow Debug
14
+ - `debug_auth_integration.py` - Debug authentication integration between HTTP headers and tool execution
15
+ - `debug_token_flow.py` - Debug Meta API token validation and flow
16
+ - `debug_meta_api_tool.py` - Debug Meta API tool functionality
17
+
18
+ ### Server Configuration Debug
19
+ - `debug_fastmcp_config.py` - Debug FastMCP server configuration and HTTP transport setup
20
+
21
+ ### Legacy Test Files
22
+ - `test_streamable_http_old.py` - Original HTTP transport test (superseded by `tests/test_http_transport.py`)
23
+ - `test_meta_ads_auth.py` - Legacy authentication test
24
+ - `test_pipeboard_auth.py` - Legacy Pipeboard authentication test
25
+
26
+ ## Usage Guidelines
27
+
28
+ **For Development:**
29
+ - These scripts may have hardcoded values, test tokens, or development-specific configurations
30
+ - They may not follow production coding standards
31
+ - Use them as reference only
32
+
33
+ **For Production:**
34
+ - Use the organized `tests/` directory for proper testing
35
+ - Use the `examples/` directory for integration examples
36
+ - Use the main package (`meta_ads_mcp/`) for actual functionality
37
+
38
+ ## Cleanup Policy
39
+
40
+ Files in this directory may be removed in future releases once they're no longer needed for debugging or reference purposes.
@@ -0,0 +1,36 @@
1
+ # Meta Ads MCP Examples
2
+
3
+ This directory contains example scripts and usage demonstrations for the Meta Ads MCP server.
4
+
5
+ ## Files
6
+
7
+ ### `http_client.py`
8
+ A complete example HTTP client that demonstrates how to interact with the Meta Ads MCP server using the HTTP transport.
9
+
10
+ **Features:**
11
+ - Shows how to authenticate with Pipeboard tokens or Meta access tokens
12
+ - Demonstrates all basic MCP operations (initialize, list tools, call tools)
13
+ - Includes error handling and response formatting
14
+ - Ready-to-use client class for integration
15
+
16
+ **Usage:**
17
+ ```bash
18
+ # Start the MCP server
19
+ python -m meta_ads_mcp --transport streamable-http --port 8080
20
+
21
+ # Run the example (in another terminal)
22
+ cd examples
23
+ python http_client.py
24
+ ```
25
+
26
+ **Authentication:**
27
+ - Set `PIPEBOARD_API_TOKEN` environment variable for Pipeboard auth
28
+ - Or pass `meta_access_token` parameter for direct Meta API auth
29
+
30
+ ## Adding New Examples
31
+
32
+ When adding new example files:
33
+ 1. Include comprehensive docstrings
34
+ 2. Add usage instructions in comments
35
+ 3. Update this README with file descriptions
36
+ 4. Follow the same authentication patterns as `http_client.py`