climent-meta-ads-mcp
# climent-meta-ads-mcp
A free, open-source, **read-only** MCP server for the Meta Marketing API (Facebook and Instagram ads).
Ask Claude, Cursor or any MCP client about your campaigns, ad sets, ads and audiences, using your own Meta token, on your own machine.
- Node.js, runs with `npx`. No Python, no Docker.
- Read-only by construction: the only HTTP method in the code is `GET`. Meta writes with `POST` and `DELETE`; neither exists here.
- Same tool vocabulary as its sibling `climent-google-ads-mcp` (`*_list_accounts`, `*_account_summary`, `*_campaigns`, `*_ads`...), with the same metric names (`spend`, `ctr`, `cpc`, `roas`).
- Open source under Apache-2.0. No telemetry. We never receive your data.
Marketing API version: **v25.0** by default, set in [`src/constants.js`](src/constants.js); newer versions (v26.0, v27.0) are one environment variable away. The default API version, the authentication (Authorization header plus `appsecret_proof`) and the fields this server asks for mirror an integration that has called the live Meta API every day in production (as of 2026-12-04).
---
## Quickstart
You need Node.js 20 or newer and one value: a Meta **access token** with the `ads_read` permission. If you do not have one yet, follow [Credentials](#credentials-step-by-step) first (about 10 minutes).
### Claude Desktop
Edit `claude_desktop_config.json` (Settings > Developer > Edit Config):
```json
{
"mcpServers": {
"meta-ads": {
"command": "npx",
"args": ["-y", "github:Manucliment/climent-meta-ads-mcp"],
"env": {
"META_ACCESS_TOKEN": "your-system-user-token",
"META_APP_SECRET": "your-app-secret"
}
}
}
}
```
`META_APP_SECRET` is optional (see below). On Windows, if Claude Desktop cannot find `npx`, use `"command": "cmd"` and `"args": ["/c", "npx", "-y", "github:Manucliment/climent-meta-ads-mcp"]`.
### Claude Code
```bash
claude mcp add meta-ads -e META_ACCESS_TOKEN=... -- npx -y github:Manucliment/climent-meta-ads-mcp
```
To keep the token out of your shell history, put the block above in a project `.mcp.json` and reference an environment variable (`"META_ACCESS_TOKEN": "${META_ACCESS_TOKEN}"`).
### Cursor
`~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project) takes the same `mcpServers` block as Claude Desktop.
### Any other MCP client
Run `npx -y github:Manucliment/climent-meta-ads-mcp` as a stdio server with the environment variables below. Or run it over HTTP (next section).
### Environment variables
| Variable | Required | What it is |
|---|---|---|
| `META_ACCESS_TOKEN` | yes | A system user token (recommended) or a long-lived user token with `ads_read` |
| `META_APP_SECRET` | no | Your app secret. If set, every call is signed with `appsecret_proof`. Required if your app has "Require App Secret" turned on |
| `META_GRAPH_API_VERSION` | no | Graph API version to call, as `v<major>.<minor>` (default `v25.0`). Set `v27.0` to opt in to a newer version. Anything else is refused with a clear error |
The token is sent in the `Authorization` header, never in a URL. The server reads only these variables: no `.env` files, keychains or files on disk.
---
## Self-host over HTTP
For remote clients, or to share one server with a team, run the Streamable HTTP transport. It refuses to start without a bearer token.
```bash
export MCP_HTTP_BEARER_TOKEN="$(openssl rand -hex 32)" # at least 32 characters
export META_ACCESS_TOKEN=...
npx -y github:Manucliment/climent-meta-ads-mcp http
# MCP endpoint: http://127.0.0.1:3000/mcp
```
- `MCP_HTTP_HOST` (default `127.0.0.1`) and `MCP_HTTP_PORT` (default `3000`) control where it listens. `GET /healthz` answers `{"ok":true}` without auth and without data.
- Every request to `/mcp` must send `Authorization: Bearer <MCP_HTTP_BEARER_TOKEN>`; anything else gets `401`.
- The server speaks plain HTTP. Before exposing it to the internet, put it behind HTTPS (Caddy, nginx, a cloud load balancer).
- Whoever has the bearer token can read every ad account your Meta token can read. Treat it like the Meta token.
Claude Code example: `claude mcp add --transport http meta-ads https://your-host/mcp --header "Authorization: Bearer <token>"`.
**ChatGPT and other remote clients** can only talk to MCP servers over HTTP(S), so they need this mode. Some of them only support OAuth or no authentication for custom connectors, not a static bearer header. Check what your client supports; if it cannot send an `Authorization` header, put the server behind a proxy you control that adds it, and never expose it without authentication.
---
## Credentials, step by step
Everything below happens in your own Meta accounts. Nothing is shared with us. Screens and labels in Meta's tools change often; the names below were current when this was written.
### 1. A Meta app with the Marketing API
1. Go to [developers.facebook.com/apps](https://developers.facebook.com/apps) and create an app. Choose the use case for creating and managing ads with the Marketing API, and connect it to your **business portfolio** (Business Manager).
2. Adding the Marketing API gives the app the **Limited access** tier automatically. That is enough to read your own ad accounts (see limits below).
3. In App settings > Basic, copy the **App secret** if you want to use `META_APP_SECRET`.
### 2. A system user and its token (recommended)
A system user is a non-human user of your business. Its token is not tied to your personal login and can be set to never expire.
1. Open [business.facebook.com/settings](https://business.facebook.com/settings) > Users > **System users** > Add. A regular (employee) role is enough.
2. **Assign assets**: pick the ad accounts this server may read and give **view performance** access only. Read-only access is all it needs.
3. **Generate new token**: choose your app, choose an expiry (never, or 60 days), and select the permission **`ads_read`**. Nothing else is needed.
4. Copy the token into `META_ACCESS_TOKEN`. Meta shows it once.
What the permission is for:
| Permission | Needed? | What it allows |
|---|---|---|
| `ads_read` | **yes** | Read ad accounts, campaigns, ad sets, ads, creatives and insights. This server uses nothing else |
| `ads_management` | no | Create and edit ads. This server never writes, so do not grant it |
| `business_management` | no | Manage business assets and users. Not used |
### 3. Alternative: a long-lived user token
If you cannot create a system user: in the [Graph API Explorer](https://developers.facebook.com/tools/explorer/) pick your app, generate a **User token** with `ads_read`, then paste it into the [Access Token Debugger](https://developers.facebook.com/tools/debug/accesstoken/) and click **Extend Access Token**. It lasts about 60 days, and stops working if you change your password. You will have to renew it.
### 4. Access tiers and limits: the honest part
Meta grants the Marketing API in two tiers ([Authorization](https://developers.facebook.com/documentation/ads-commerce/marketing-api/get-started/authorization)):
| Tier | How you get it | What it means here |
|---|---|---|
| **Limited access** (default) | Automatic when you add the Marketing API | Works for ad accounts your own business owns. Meta describes it as for development and **heavily rate-limited per ad account**. Allows 1 system user |
| **Full access** | At least 500 Marketing API calls in 15 days, an error rate under 15%, and App Review | Lightly rate-limited. Allows 10 system users |
Separately, Meta's docs say that managing **your own** ad accounts needs only standard access to `ads_read`, while managing **other people's** ad accounts needs **advanced access** to `ads_read`, which goes through App Review. If you are an agency reading client accounts shared with your business, you may hit this: if those accounts return permission errors while your own work, this is the likely reason. We have not measured where Meta draws the line for partner-shared accounts.
In practice: for conversational use on your own accounts, the default tier is fine. If you see rate-limit errors, wait a few minutes, ask for fewer rows or a shorter date range.
---
## Tools
All tools are read-only. Dates are a `preset` (`today`, `yesterday`, `last_7d`, `last_14d`, `last_30d`, `this_month`, `last_month`; the default is `last_30d`, and `last_N` excludes today) or `since` + `until` as `YYYY-MM-DD`, in the ad account time zone. Money is in the account currency, named in every response (`currency`); budgets are converted from Meta's minor units. Lists are capped (`max_rows`, default 50) and say `"truncated": true` when there is more.
Every performance row has `spend`, `impressions`, `reach`, `frequency`, `clicks`, `link_clicks`, `ctr`, `cpc`, `cpm`, `purchases`, `purchase_value`, `cost_per_purchase`, `roas`, `leads`, `cost_per_lead` and the main raw `actions`.
| Tool | What it returns | Example prompt |
|---|---|---|
| `meta_list_accounts` | Ad accounts the token can read (name, currency, time zone, status) | "Which Meta ad accounts can you see?" |
| `meta_account_summary` | Account totals for a date range | "How did act_1234567890 do last month? What was the ROAS?" |
| `meta_campaigns` | Campaigns with status, objective, budget and performance, sorted by spend | "Which campaigns spent the most in the last 7 days, and at what cost per purchase?" |
| `meta_ad_sets` | Ad sets with status, optimization goal, budget and performance, optionally for one campaign | "Compare the ad sets of campaign 120000000000000001 this month." |
| `meta_ads` | Ads with creative title, body text, link, call to action, thumbnail URL and performance | "Show the copy of my five best and five worst ads by CPA." |
| `meta_insights_breakdown` | Performance split by `age`, `gender`, `age_gender`, `country`, `region`, `platform` or `placement`, at account, campaign, ad set or ad level | "Where did my spend go by placement last week, and which placement had the best CTR?" |
Notes on Meta data, also returned inside the responses:
- `purchases` and `leads` use Meta's deduplicated `purchase` and `lead` action types. The raw action types overlap (`purchase`, `omni_purchase`, `offsite_conversion.fb_pixel_purchase`); do not add them up.
- `thumbnail_url` is a temporary signed link from Meta's CDN and expires.
- Reach does not add up across breakdown rows, and Meta may withhold or model some breakdown values for privacy.
---
## Privacy
- It runs on your machine (or your server) and talks only to `graph.facebook.com`.
- No telemetry, no analytics, no phone-home. We (Climent Media) receive nothing: no data, no usage counts, no errors.
- Tokens are never logged. Error messages pass through a redaction step that removes your token, your app secret and anything shaped like a Meta or Google token.
- Your MCP client (Claude, Cursor...) does see the data the tools return, under that client's own privacy terms.
## Limits
- **Read-only.** It cannot pause ads, change budgets, edit audiences or create anything. Ask it and the model will tell you it can't, and how to do it in Ads Manager.
- One token per server, so one set of ad accounts.
- Defaults to Marketing API **v25.0**, not the newest, because that is the version proven in production with these exact requests. On 2026-12-04 Meta's [Marketing API changelog](https://developers.facebook.com/docs/marketing-api/marketing-api-changelog) lists v25.0 as available until **23 February 2027** (the Graph API changelog says TBD). Set `META_GRAPH_API_VERSION=v27.0` before then; the next release will move the default.
- Large accounts: lists return one page (up to `max_rows`) and say when they are truncated. Very long date ranges on big accounts can hit Meta's "reduce the amount of data" error; shorten the range.
- This package's own test suite mocks every request; it has not itself been run against the live API. The default API version, the authentication (Authorization header plus `appsecret_proof`) and the fields this server asks for mirror an integration that has called the live Meta API every day in production (as of 2026-12-04). Please report anything that behaves differently.
## Need more?
This server is a good way to *look*. When you want to *act*:
- **[Climent Ads](https://climentmedia.com/?utm_source=github&utm_medium=readme&utm_campaign=climent-meta-ads-mcp)** is our hosted product: no Meta app or token of your own, Meta Ads and Google Ads for many clients in one place, account audits, and changes to campaigns that a human approves before they are applied.
- **[Climent Media](https://climentmedia.com/?utm_source=github&utm_medium=readme&utm_campaign=climent-meta-ads-mcp)** is the agency behind it, if you would rather have people run your ads.
## Develop
```bash
npm install
npm test # node:test, every API call mocked, no credentials needed
node bin/cli.js --help
```
## License
Apache-2.0. See [LICENSE](LICENSE). Not affiliated with or endorsed by Meta. Facebook, Instagram and Meta are trademarks of Meta Platforms, Inc.
TDQS
Scored across 6 tools
Each tool maps to a distinct level of the Meta hierarchy (account, campaign, ad set, ad) or a distinct aggregation mode (summary totals vs. dimensional breakdown), so misselection is unlikely. There is mild overlap between meta_account_summary and meta_insights_breakdown or the per-level performance fields, but the descriptions make the boundary clear.
All tools share a consistent meta_ prefix and resource-oriented naming, which reads predictably. The verb style deviates slightly (meta_list_accounts uses a verb, while meta_account_summary and meta_campaigns are noun forms), but the pattern remains readable.
Six tools is well-scoped for a read-only Meta Ads reporting server: one per hierarchy level, plus account listing, summary, and breakdown. Nothing appears redundant or padded.
The surface covers the core reporting lifecycle from account discovery through campaign/ad set/ad performance and dimensional breakdowns, with no obvious dead ends for analysis. Minor gaps exist, such as no daily/time-series trend option and no creative preview beyond a thumbnail URL.