@getmcpads/meta-ads-mcp-server 1.0.0
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.
- package/LICENSE +201 -0
- package/NOTICE +17 -0
- package/README.md +358 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +9497 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +9487 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
meta-ads-mcp-server
|
|
2
|
+
Copyright 2026 GetMCPAds
|
|
3
|
+
|
|
4
|
+
This product includes software developed at GetMCPAds (https://www.getmcpads.com).
|
|
5
|
+
|
|
6
|
+
An open-source Model Context Protocol server for the Facebook (Meta) Ads
|
|
7
|
+
Marketing API. It is self-hosted and unaffiliated with Meta Platforms, Inc.
|
|
8
|
+
|
|
9
|
+
GetMCPAds also runs a managed gateway that covers Facebook Ads alongside
|
|
10
|
+
Google Ads, TikTok Ads, Pinterest Ads, GA4 and Search Console, with hosted
|
|
11
|
+
OAuth and cross-platform reporting: https://www.getmcpads.com
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
Facebook, Meta, Instagram and the Meta Marketing API are trademarks of
|
|
16
|
+
Meta Platforms, Inc. This project is not affiliated with, endorsed by, or
|
|
17
|
+
sponsored by Meta Platforms, Inc.
|
package/README.md
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
# meta-ads-mcp-server
|
|
2
|
+
|
|
3
|
+
[](https://github.com/getmcpads-com/meta-ads-mcp-server/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](package.json)
|
|
6
|
+
|
|
7
|
+
An open-source [Model Context Protocol](https://modelcontextprotocol.io) server for the
|
|
8
|
+
**Facebook (Meta) Ads Marketing API**. It lets Claude, ChatGPT, Cursor or any MCP client
|
|
9
|
+
read and analyse your advertising data, and change it if you choose to.
|
|
10
|
+
|
|
11
|
+
You run it. Your token stays on your machine. Nothing is proxied through a third party.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx -y @getmcpads/meta-ads-mcp-server
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
> **Prefer not to run it yourself?** [getmcpads.com](https://www.getmcpads.com) is the hosted
|
|
18
|
+
> version of this server, with Meta Ads alongside Google Ads, TikTok Ads, Pinterest Ads, GA4 and
|
|
19
|
+
> Search Console behind a single endpoint, hosted OAuth, and cross-platform reporting.
|
|
20
|
+
> Same tools, same safety model, no setup.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## What you get
|
|
25
|
+
|
|
26
|
+
| | |
|
|
27
|
+
|---|---|
|
|
28
|
+
| **34 read tools** | Campaigns, ad sets, ads, creatives, audiences, pixels, catalogs, Pages, Instagram, activity logs, A/B tests and lift studies |
|
|
29
|
+
| **10 write tools** | Off by default. Status, budgets, schedules, renames, campaign creation. Each one **previews before it applies** |
|
|
30
|
+
| **190 metrics** | Including derived ones computed client-side (ROAS, CPA, frequency, hook rate, attribution-window views) |
|
|
31
|
+
| **56 breakdowns · 90 dimensions** | With a compatibility matrix that catches invalid combinations *before* they hit the API |
|
|
32
|
+
| **7 resources** | Live catalogues the model can read: metrics, breakdowns, compatibility rules, 11 workflow recipes |
|
|
33
|
+
| **Forward-compatible reads** | `meta_get_node_fields`, `meta_list_edge_raw`, `meta_get_insights_raw` reach Graph fields this server doesn't model yet |
|
|
34
|
+
|
|
35
|
+
### The query planner
|
|
36
|
+
|
|
37
|
+
Meta rejects many metric/breakdown combinations, and the error messages rarely say why.
|
|
38
|
+
This server encodes the compatibility matrix, so it **splits an impossible request into
|
|
39
|
+
several valid API calls and merges the results** instead of failing.
|
|
40
|
+
|
|
41
|
+
`meta_validate_query` lets the model check a combination before spending a call on it.
|
|
42
|
+
That is the difference between an assistant that reports "the API returned error 100" and
|
|
43
|
+
one that returns your numbers.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## How this compares to Meta's own MCP server
|
|
48
|
+
|
|
49
|
+
Meta ships an official MCP server, hosted at `mcp.facebook.com/ads`. It is a good product.
|
|
50
|
+
Here is an honest comparison, because the right choice depends on what you need.
|
|
51
|
+
|
|
52
|
+
| | Meta's official server | This server | [getmcpads.com](https://www.getmcpads.com) |
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
| Hosting | Meta-hosted, remote | **You host it.** stdio, local process | Hosted for you |
|
|
55
|
+
| Data path | Through Meta's endpoint | **Direct to the Graph API.** No intermediary | Through our gateway |
|
|
56
|
+
| Auth | Meta Business OAuth, 2 clicks | You bring a token, which is more setup (see below) | Hosted OAuth |
|
|
57
|
+
| Tools | 29 | **44** (34 read + 10 write) | 44, plus 5 other platforms |
|
|
58
|
+
| Writes | Applied directly | **Preview first**, applied only on `confirm: true` | Preview first |
|
|
59
|
+
| Metric compatibility | None | **Query planner splits incompatible requests** | Same planner |
|
|
60
|
+
| Auditable | No | **Yes.** Apache-2.0, read every line | This server, audited |
|
|
61
|
+
| Modifiable | No | **Fork it** | No |
|
|
62
|
+
| Help Center search | ✅ | ❌ | ❌ |
|
|
63
|
+
| Catalog creation | ✅ | ❌ (catalog *reads* are supported) | ❌ |
|
|
64
|
+
|
|
65
|
+
**Choose Meta's** if you want the fastest possible setup and don't need to see the code.
|
|
66
|
+
**Choose this one** if you need your data to stay on your infrastructure, want to audit or
|
|
67
|
+
extend what the model can do, or want writes that can't fire on the first call.
|
|
68
|
+
**Choose [getmcpads.com](https://www.getmcpads.com)** if you want this server's capabilities
|
|
69
|
+
without running it, or you need more than one ad platform in the same conversation.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Getting a token
|
|
74
|
+
|
|
75
|
+
This is the one step that takes real effort, and it's worth doing properly.
|
|
76
|
+
|
|
77
|
+
You need a Meta access token with **`ads_read`**. There are three ways to get one; the
|
|
78
|
+
second is the one we recommend.
|
|
79
|
+
|
|
80
|
+
### Recommended: System User token (does not expire)
|
|
81
|
+
|
|
82
|
+
A System User belongs to your Business, not to a person. Its token survives password
|
|
83
|
+
changes and staff departures, and **needs no App Review** to access ad accounts your
|
|
84
|
+
Business already owns.
|
|
85
|
+
|
|
86
|
+
1. Go to [Business Settings](https://business.facebook.com/settings) → **Users → System Users**
|
|
87
|
+
2. **Add** a system user. Give it the *Employee* role unless you need more.
|
|
88
|
+
3. **Assign Assets** → select your ad accounts → grant **View performance** (add
|
|
89
|
+
*Manage campaigns* only if you plan to enable writes).
|
|
90
|
+
4. **Generate New Token** → pick your app → select scope **`ads_read`**
|
|
91
|
+
(add `ads_management` only for writes).
|
|
92
|
+
5. Set the expiry to **Never**.
|
|
93
|
+
6. Copy the token. Meta shows it once.
|
|
94
|
+
|
|
95
|
+
📖 [Meta's System User documentation](https://developers.facebook.com/docs/marketing-api/system-users)
|
|
96
|
+
|
|
97
|
+
### Quick test: Graph API Explorer (expires in ~1 hour)
|
|
98
|
+
|
|
99
|
+
Fine for trying the server out, useless for daily work.
|
|
100
|
+
[Graph API Explorer](https://developers.facebook.com/tools/explorer/) → select your app →
|
|
101
|
+
add `ads_read` → **Generate Access Token**.
|
|
102
|
+
|
|
103
|
+
### Long-lived user token (~60 days)
|
|
104
|
+
|
|
105
|
+
Exchange a short-lived token for a 60-day one. You will have to redo this every two months.
|
|
106
|
+
📖 [Long-lived tokens](https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived)
|
|
107
|
+
|
|
108
|
+
### Which permissions?
|
|
109
|
+
|
|
110
|
+
| Permission | When you need it |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `ads_read` | **Always.** Campaigns, insights, everything read-only |
|
|
113
|
+
| `ads_management` | Only if you set `META_ENABLE_WRITES=1` |
|
|
114
|
+
| `business_management` | Optional. Business Manager asset discovery |
|
|
115
|
+
| `pages_show_list`, `pages_read_engagement` | Optional. Page posts and organic enrichment |
|
|
116
|
+
| `instagram_basic` | Optional. Linked Instagram accounts |
|
|
117
|
+
| `catalog_management` | Optional. Product catalog reads |
|
|
118
|
+
|
|
119
|
+
Run **`meta_health_check`** as your first call: it reports which scopes you actually have
|
|
120
|
+
and which ones are missing for the tools you tried to use, without printing your token.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Setup
|
|
125
|
+
|
|
126
|
+
### Claude Desktop
|
|
127
|
+
|
|
128
|
+
`~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
|
|
129
|
+
or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"meta-ads": {
|
|
135
|
+
"command": "npx",
|
|
136
|
+
"args": ["-y", "@getmcpads/meta-ads-mcp-server"],
|
|
137
|
+
"env": {
|
|
138
|
+
"META_ACCESS_TOKEN": "your-token-here"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Restart Claude Desktop. Ask it: *"list my Meta ad accounts"*.
|
|
146
|
+
|
|
147
|
+
### Claude Code
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
claude mcp add meta-ads --env META_ACCESS_TOKEN=your-token-here -- npx -y @getmcpads/meta-ads-mcp-server
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Cursor
|
|
154
|
+
|
|
155
|
+
`.cursor/mcp.json` in your project, same shape as the Claude Desktop config above.
|
|
156
|
+
|
|
157
|
+
### From source
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
git clone https://github.com/getmcpads-com/meta-ads-mcp-server.git
|
|
161
|
+
cd meta-ads-mcp-server
|
|
162
|
+
npm install && npm run build
|
|
163
|
+
cp .env.example .env # then fill in META_ACCESS_TOKEN
|
|
164
|
+
npm start
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Configuration
|
|
168
|
+
|
|
169
|
+
| Variable | Default | Meaning |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `META_ACCESS_TOKEN` | none | **Required.** Your Meta access token |
|
|
172
|
+
| `META_ENABLE_WRITES` | *unset* | Set to `1` to register the 10 write tools |
|
|
173
|
+
| `META_API_VERSION` | `v26.0` | Graph API version. Override to pin another |
|
|
174
|
+
| `LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error` |
|
|
175
|
+
|
|
176
|
+
Check your setup at any time:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm run doctor
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Writes, and why they preview first
|
|
185
|
+
|
|
186
|
+
Write tools are **disabled by default**. Enable them with `META_ENABLE_WRITES=1`.
|
|
187
|
+
|
|
188
|
+
When enabled, every write tool returns a preview and changes nothing:
|
|
189
|
+
|
|
190
|
+
```jsonc
|
|
191
|
+
// meta_update_adset_budget { adSetId: "123", currency: "EUR", dailyBudget: 50 }
|
|
192
|
+
{
|
|
193
|
+
"applied": false,
|
|
194
|
+
"action": "meta_update_adset_budget",
|
|
195
|
+
"change": { "adSet": "123", "field": "daily_budget", "amount": 50,
|
|
196
|
+
"currency": "EUR", "inMinorUnits": 5000 },
|
|
197
|
+
"message": "Preview only, nothing was changed. Repeat the same call with confirm: true to apply this change to the live account."
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Only a second call carrying `confirm: true` touches the live account.
|
|
202
|
+
|
|
203
|
+
This is deliberate. An assistant composes these calls, and it can pick the wrong account,
|
|
204
|
+
the wrong campaign, or the wrong order of magnitude on a budget. A mandatory preview makes
|
|
205
|
+
the mistake visible before it costs money, and gives a human the stopping point the
|
|
206
|
+
protocol does not guarantee on its own.
|
|
207
|
+
|
|
208
|
+
Two further guardrails:
|
|
209
|
+
|
|
210
|
+
- **`meta_create_campaign` always creates the campaign `PAUSED`.** There is no option to
|
|
211
|
+
create it active.
|
|
212
|
+
- **Budgets are converted to minor units per currency.** The yen, the won and the CFA franc
|
|
213
|
+
have no subunit, so sending 1250 for ¥12.50 would multiply the spend by a hundred. The
|
|
214
|
+
server knows the zero-decimal currencies.
|
|
215
|
+
|
|
216
|
+
| Tool | What it changes |
|
|
217
|
+
|---|---|
|
|
218
|
+
| `meta_update_campaign_status` / `_adset_status` / `_ad_status` | Pause or reactivate |
|
|
219
|
+
| `meta_update_campaign_budget` / `_adset_budget` | Daily or lifetime budget |
|
|
220
|
+
| `meta_update_adset_schedule` | Start and end time |
|
|
221
|
+
| `meta_rename_campaign` / `_adset` / `_ad` | Name only |
|
|
222
|
+
| `meta_create_campaign` | Creates a campaign, always `PAUSED` |
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Tools
|
|
227
|
+
|
|
228
|
+
<details>
|
|
229
|
+
<summary><b>34 read tools</b></summary>
|
|
230
|
+
|
|
231
|
+
### Discovery and health
|
|
232
|
+
| Tool | Purpose |
|
|
233
|
+
|---|---|
|
|
234
|
+
| `meta_health_check` | Validates the token, lists accessible accounts, reports missing scopes |
|
|
235
|
+
| `meta_debug_token` | Token validity, expiry and granted scopes |
|
|
236
|
+
| `meta_list_ad_accounts` | Every ad account the token can reach |
|
|
237
|
+
| `meta_get_account_details` | Currency, timezone, spend cap, status, business info |
|
|
238
|
+
| `meta_get_business_assets` | Businesses, Pages, Instagram accounts, pixels, datasets |
|
|
239
|
+
|
|
240
|
+
### Structure
|
|
241
|
+
| Tool | Purpose |
|
|
242
|
+
|---|---|
|
|
243
|
+
| `meta_get_campaigns` / `meta_get_adsets` / `meta_get_ads` | List entities, filterable by parent |
|
|
244
|
+
| `meta_get_campaign_structure` | Full hierarchy: campaigns → ad sets → ads |
|
|
245
|
+
| `meta_search_entities` | Search by name within an account |
|
|
246
|
+
| `meta_get_ad_activity` | Activity log: who changed what, and when |
|
|
247
|
+
|
|
248
|
+
### Performance
|
|
249
|
+
| Tool | Purpose |
|
|
250
|
+
|---|---|
|
|
251
|
+
| `meta_get_insights` | The main reporting tool. Metrics, breakdowns, attribution windows |
|
|
252
|
+
| `meta_validate_query` | Check a metric/breakdown combination *before* running it |
|
|
253
|
+
| `meta_get_insights_raw` | Native Insights fields, no aliasing |
|
|
254
|
+
| `meta_get_delivery_diagnostics` | Why delivery is limited: statuses and issues |
|
|
255
|
+
|
|
256
|
+
### Creatives
|
|
257
|
+
| Tool | Purpose |
|
|
258
|
+
|---|---|
|
|
259
|
+
| `meta_get_creatives` | Text, images, videos, links, CTAs |
|
|
260
|
+
| `meta_get_creative_assets` | Normalised asset metadata, media URLs, asset feeds |
|
|
261
|
+
| `meta_get_ad_preview` | Rendered preview markup for a placement |
|
|
262
|
+
|
|
263
|
+
### Audiences and targeting
|
|
264
|
+
| Tool | Purpose |
|
|
265
|
+
|---|---|
|
|
266
|
+
| `meta_get_audiences` / `meta_get_audience_details` | Custom, saved and lookalike audiences |
|
|
267
|
+
| `meta_search_targeting_options` | Interests, geographies, locales, cities, postal codes |
|
|
268
|
+
| `meta_get_brand_safety_controls` | Suitability, placement and context controls |
|
|
269
|
+
|
|
270
|
+
### Commerce and organic
|
|
271
|
+
| Tool | Purpose |
|
|
272
|
+
|---|---|
|
|
273
|
+
| `meta_get_catalog_products` | Product catalogs and items |
|
|
274
|
+
| `meta_join_product_insights` | Product-breakdown insights enriched with catalog metadata |
|
|
275
|
+
| `meta_get_pixels` | Pixels and datasets |
|
|
276
|
+
| `meta_get_pages` / `meta_get_page_posts` | Pages and their recent posts |
|
|
277
|
+
| `meta_get_instagram_accounts` | Linked Instagram accounts |
|
|
278
|
+
| `meta_get_organic_content_enrichment` | Media URLs, permalinks, counts for organic content |
|
|
279
|
+
|
|
280
|
+
### Experiments
|
|
281
|
+
| Tool | Purpose |
|
|
282
|
+
|---|---|
|
|
283
|
+
| `meta_get_ad_studies` | Conversion lift studies and A/B tests |
|
|
284
|
+
| `meta_get_study_results` | Detailed study results |
|
|
285
|
+
| `meta_interpret_experiment_results` | Results with confidence guardrails |
|
|
286
|
+
|
|
287
|
+
### Escape hatches
|
|
288
|
+
| Tool | Purpose |
|
|
289
|
+
|---|---|
|
|
290
|
+
| `meta_get_node_fields` | Read flat fields from any Graph node |
|
|
291
|
+
| `meta_list_edge_raw` | List an allowlisted Graph edge with your own field selection |
|
|
292
|
+
|
|
293
|
+
These last two exist so a new Graph field doesn't require a new release. The edge allowlist
|
|
294
|
+
deliberately **excludes lead records**, which carry personal data.
|
|
295
|
+
|
|
296
|
+
</details>
|
|
297
|
+
|
|
298
|
+
<details>
|
|
299
|
+
<summary><b>7 resources</b></summary>
|
|
300
|
+
|
|
301
|
+
| URI | Contents |
|
|
302
|
+
|---|---|
|
|
303
|
+
| `meta://manifest` | What this server exposes, and which tool to run first |
|
|
304
|
+
| `meta://metrics` | All 190 metrics with categories and formats |
|
|
305
|
+
| `meta://breakdowns` | All 56 breakdowns and where they are valid |
|
|
306
|
+
| `meta://compatibility` | The compatibility matrix, 90 dimensions |
|
|
307
|
+
| `meta://recipes` | 11 step-by-step workflows |
|
|
308
|
+
| `meta://p2-readonly` | Read-only scope guidance |
|
|
309
|
+
| `meta://app-review` | Scope positioning for a Meta App Review submission |
|
|
310
|
+
|
|
311
|
+
</details>
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Security
|
|
316
|
+
|
|
317
|
+
The server holds a credential that can read live ad accounts, and modify them when writes
|
|
318
|
+
are enabled.
|
|
319
|
+
Concretely:
|
|
320
|
+
|
|
321
|
+
- **The token is never logged**, at any log level, and never written to disk.
|
|
322
|
+
- **Requests go only to `graph.facebook.com`** on the pinned version. Any other host is
|
|
323
|
+
refused rather than called. *Covered by tests.*
|
|
324
|
+
- **Redirects are refused once a token is attached**, so a redirect cannot forward your
|
|
325
|
+
credential elsewhere. *Covered by tests.*
|
|
326
|
+
- **No telemetry.** The server makes no network call other than to the Graph API. There is
|
|
327
|
+
no analytics, no phone-home, and no usage reporting. You can verify this by grepping
|
|
328
|
+
the source for `fetch`.
|
|
329
|
+
|
|
330
|
+
Full policy and reporting instructions: [SECURITY.md](SECURITY.md).
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Looking for a managed, multi-platform version?
|
|
335
|
+
|
|
336
|
+
This server does one platform, on your machine, with your token. That is on purpose.
|
|
337
|
+
|
|
338
|
+
If you'd rather not run it yourself, or you need Facebook Ads **alongside Google Ads,
|
|
339
|
+
TikTok Ads, Pinterest Ads, GA4 and Search Console** behind one endpoint, with hosted OAuth
|
|
340
|
+
and cross-platform reporting, that's what we build at **[getmcpads.com](https://www.getmcpads.com)**.
|
|
341
|
+
|
|
342
|
+
Same philosophy, less plumbing. This project stays open source and independently useful
|
|
343
|
+
either way.
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## Contributing
|
|
348
|
+
|
|
349
|
+
Issues and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
350
|
+
Please read [SECURITY.md](SECURITY.md) before reporting anything security-related.
|
|
351
|
+
|
|
352
|
+
## Licence
|
|
353
|
+
|
|
354
|
+
[Apache License 2.0](LICENSE). See also [NOTICE](NOTICE).
|
|
355
|
+
|
|
356
|
+
Facebook, Meta, Instagram and the Meta Marketing API are trademarks of Meta Platforms, Inc.
|
|
357
|
+
**This project is not affiliated with, endorsed by, or sponsored by Meta Platforms, Inc.**
|
|
358
|
+
It is an independent client of a public API.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|