Meta Ads MCP
Provides tools for reading Meta (Facebook) Ads campaign, ad-set, and ad performance data, including listing ad accounts, retrieving campaigns/ad sets/ads, fetching insights, and generating a performance summary with heuristic flags for review.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Meta Ads MCP show me a performance summary for my ad account"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Meta Ads MCP
Meta Ads MCP is a minimal, read-only Python MCP server that pulls Meta (Facebook) Ads campaign, ad-set, and ad performance so a human can spot problems and adjust them in Ads Manager earlier. It never changes budgets, statuses, or creatives.
Tools
Tool | Purpose |
| List the Meta ad accounts available to the configured access token. |
| Get campaigns for an explicit or configured default ad account. |
| Get ad sets beneath an account or campaign parent. |
| Get ads beneath an account, campaign, or ad-set parent. |
| Get raw Meta performance metrics for an object and reporting period. |
| Rank campaigns by spend and flag performance symptoms for review. |
The flags from performance_summary are HEURISTIC signals, not diagnoses.
Conversions and ROAS are platform-reported (Meta attribution), not incremental;
a holdout or lift test is required to claim incrementality.
Related MCP server: mlg-meta-mcp
Prerequisites
Python 3.10 or newer
Meta credentials
Create a Meta app at Meta for Developers.
Add the Marketing API to the app.
Generate a long-lived User access token with the
ads_readpermission and access to the required ad account.Find the ad account ID in Ads Manager. It must use the
act_<digits>form, such asact_123456789.
Meta's screens and access-token options can change. Follow the official Marketing API Get Started documentation for the current screens. Treat the access token as a secret.
Quick setup
One command does the whole setup:
python -m meta_ads_mcp setupFor the full walkthrough - creating the Meta app, redirect URI rules, giving teammates access, and a troubleshooting table - see docs/SETUP.md.
It asks for the app id and app secret (the secret is never echoed), writes
.env with owner-only permissions, runs the browser login, lists the ad
accounts the token can read so you pick one from a numbered menu, and registers
the server in claude_desktop_config.json (backing up any existing file).
Restart Claude Desktop afterwards.
If META_ACCESS_TOKEN is already set in .env, setup offers to keep it and
skips the login entirely. Useful options:
Option | Purpose |
| Patch a different MCP client config. |
| Command the client should launch. |
| Write to a different dotenv file. |
The manual route below is still supported if you would rather set each piece yourself.
Environment setup
Copy the template and fill in your credentials:
Copy-Item .env.example .envThere are two ways to supply the token. Pick one.
Route A - paste a token
META_ACCESS_TOKEN=your-long-lived-user-access-token
META_AD_ACCOUNT_ID=act_123456789
META_GRAPH_API_VERSION=v23.0A system user token from Business Manager (Business Settings > Users > System Users) never expires and needs no login flow. A manually generated user token expires in about 60 days.
Route B - browser login
Put the app credentials in .env and leave META_ACCESS_TOKEN blank:
META_APP_ID=your-app-id
META_APP_SECRET=your-app-secret
META_AD_ACCOUNT_ID=act_123456789Then authorize in a browser:
python -m meta_ads_mcp loginThe command opens the Facebook Login dialog, receives the redirect on
http://localhost:8721/callback, exchanges the code for a long-lived token,
and caches it at ~/.local/share/meta-ads-mcp/token.json (%LOCALAPPDATA%
equivalent via XDG_DATA_HOME) with owner-only permissions. The server picks
that cached token up automatically, so no token ever needs to sit in a config
file.
http://localhost:8721/callback must be listed under Facebook Login >
Settings > Valid OAuth Redirect URIs on the app. Change the port or scheme
with META_OAUTH_REDIRECT_URI if needed.
If Meta rejects a localhost redirect URI, use the paste flow instead - it uses Meta's own desktop redirect page and needs no registered URI:
python -m meta_ads_mcp login --pasteLog in, then copy the full URL from the browser address bar and paste it back at the prompt.
Related commands:
Command | Purpose |
| Show the cached token's expiry. |
| Delete the cached token. |
Meta issues no refresh tokens, so a long-lived user token lasts about 60 days;
rerun login when status shows it near expiry. Only a system user token
(route A) avoids re-authorizing entirely.
META_ACCESS_TOKEN always wins over the cached token when both are present.
META_GRAPH_API_VERSION is optional and defaults to v23.0. The .env file
is git-ignored; never commit it.
Install
Create a virtual environment and install the package with its development dependencies:
python -m venv .venv
.venv\Scripts\python.exe -m pip install -e ".[dev]"If you already use uv, the install step can instead be:
uv pip install -e ".[dev]"uv is optional and is not required.
Run
From an activated virtual environment, start the stdio server with:
python -m meta_ads_mcpThe installed console entry point is also meta-ads-mcp. A stdio MCP server
waits on standard input, so it is normally launched by an MCP client rather
than run interactively.
MCP client configuration
For Claude Desktop, add a server entry under mcpServers in
claude_desktop_config.json. Replace the example path and credentials:
{
"mcpServers": {
"meta-ads": {
"command": "C:\\Users\\your-name\\path\\to\\meta-ads-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "meta_ads_mcp"],
"env": {
"META_ACCESS_TOKEN": "your-long-lived-user-access-token",
"META_AD_ACCOUNT_ID": "act_123456789"
}
}
}
}For Claude Code, put the equivalent configuration in the project-level
.mcp.json; it mirrors the Desktop configuration:
{
"mcpServers": {
"meta-ads": {
"command": "C:\\Users\\your-name\\path\\to\\meta-ads-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "meta_ads_mcp"],
"env": {
"META_ACCESS_TOKEN": "your-long-lived-user-access-token",
"META_AD_ACCOUNT_ID": "act_123456789"
}
}
}
}The token and account ID can live in the client's env block instead of
.env. Keep client configuration containing a real token private.
If you used browser login (route B), omit META_ACCESS_TOKEN from the env
block entirely - the server reads the cached token from
~/.local/share/meta-ads-mcp/token.json. Leaving a placeholder string there
would override the cached token and every call would fail with an auth error.
Graph API version
The server pins Graph API v23.0 by default. If Meta deprecates that version,
set META_GRAPH_API_VERSION to a current supported version.
Smoke test
After filling .env, run the manual real-network check:
python scripts/smoke_test.pyIt lists up to five accessible ad accounts and up to five campaigns from the configured default account.
Security
Never commit .env or paste the access token into logs, issues, or chat. The
server and all six tools are read-only.
The app secret is used only for the server-side code exchange and is never put
in a URL sent to the browser. The cached token file is written with 0600
permissions inside a 0700 directory, and the login flow validates the OAuth
state value with a constant-time comparison before exchanging any code.
Development
Run the test suite with:
pytestAvailable Tools
6 toolsget_adsARead-onlyIdempotent
Get ads beneath an account, campaign, or ad-set parent.
Args: params: Parent object ID, maximum result count, and JSON or Markdown response format.
Returns:
A rendered {"success": bool, "data": list[object] | null, "error": string | null} envelope containing ad identifiers, names,
statuses, ad-set IDs, and campaign IDs.
Use this to inspect ads for a known hierarchy parent. Do not use it for performance metrics or to create, edit, pause, or delete ads.
Inputs: params (required). Returns: result
get_adsetsARead-onlyIdempotent
Get ad sets beneath an account or campaign parent.
Args: params: Parent account or campaign ID, maximum result count, and JSON or Markdown response format.
Returns:
A rendered {"success": bool, "data": list[object] | null, "error": string | null} envelope containing ad set identifiers,
names, statuses, campaign IDs, and daily budgets.
Use this to inspect the ad-set hierarchy for a known parent. Do not use it for performance metrics or to create, edit, pause, or delete ad sets.
Inputs: params (required). Returns: result
get_campaignsARead-onlyIdempotent
Get campaigns for an explicit or configured default ad account.
Args: params: Optional account ID, maximum result count, and JSON or Markdown response format.
Returns:
A rendered {"success": bool, "data": list[object] | null, "error": string | null} envelope containing campaign identifiers,
names, statuses, objectives, and budgets.
Use this for an account-level campaign inventory. Do not use it for performance metrics or for campaign creation, edits, or status changes.
Inputs: params (required). Returns: result
get_insightsARead-onlyIdempotent
Get raw Meta performance metrics for an object and reporting period.
Args: params: Object ID, aggregation level, either a date preset or custom since/until range, maximum row count, and response format.
Returns:
A rendered {"success": bool, "data": list[object] | null, "error": string | null} envelope containing raw Meta insight rows
with spend, delivery, click, action, and purchase ROAS fields.
Use this for flexible read-only metric retrieval at account, campaign, ad-set, or ad level. Do not use it to modify delivery or to infer causal lift from platform-attributed results.
Inputs: params (required). Returns: result
list_ad_accountsARead-onlyIdempotent
List Meta ad accounts available to the configured access token.
Args: params: Maximum result count and JSON or Markdown response format.
Returns:
A rendered {"success": bool, "data": list[object] | null, "error": string | null} envelope containing account identifiers,
names, statuses, and currencies.
Use this to discover an account ID before account-scoped reads. Do not use it to inspect campaigns or to create, update, or delete ad accounts.
Inputs: params (required). Returns: result
performance_summaryARead-onlyIdempotent
Rank campaign performance and flag heuristic symptoms for review.
Args: params: Optional account ID, reporting preset, CTR, ROAS, and frequency thresholds, and JSON or Markdown response format.
Returns:
A rendered {"success": bool, "data": {"caveat": string, "truncated": bool, "campaigns": list[object]} | null, "error": string | null} envelope. Campaign records are sorted by
spend and include metric values plus zero or more heuristic flag
names.
Use this for read-only campaign triage, not as proof of causation or a verified diagnosis. Conversions and ROAS are platform-reported using Meta attribution, not incremental; a holdout or lift test is required to claim incrementality, and periods should be compared at similar spend. Do not use this tool to make delivery changes or assert causal campaign impact.
Inputs: params (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct resource (ad accounts, campaigns, ads, ad sets, insights, performance summary) with clear boundaries and explicit 'do not use' guidance, eliminating ambiguity.
Most tools follow a 'get_<resource>' pattern (get_campaigns, get_ads, get_insights, get_adsets), with one using 'list_' (list_ad_accounts) and another using a noun phrase (performance_summary), which is a minor inconsistency.
The 6 tools are well-scoped for a read-only Meta Ads analytics server, covering account discovery, hierarchical retrieval, insights, and a summary function without being excessive.
The surface is read-only and covers listing and insights, but lacks any create, update, or delete capabilities, and misses tools for single-object retrieval or ad account details beyond listing.
Maintenance
Related MCP Connectors
Meta Ads MCP server: run Facebook and Instagram campaigns, ad sets, ads and reports from AI.
Meta Ads MCP server: 10 tools for Facebook and Instagram reports, ads, Ad Library. Ads start paused.
Meta Ads MCP (Facebook + Instagram) - analyze performance, manage budgets, pause campaigns.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for managing and analyzing Meta Ads (Facebook/Instagram) with over 80 natural-language tools for AI agents like Claude Desktop.-
- AlicenseBqualityDmaintenanceMCP server for Meta Ads providing 30 tools for account discovery, campaign management, targeting research, and insights. Designed with LLM-friendly outputs and productivity features like cloning and bulk operations.311MIT
- AlicenseBqualityBmaintenanceRead-only MCP server for Meta Ads that lists and reads ad accounts, campaigns, ad sets, ads, ad images, creatives, and fetches insights at various levels.18MIT
- FlicenseNot gradedqualityBmaintenanceMCP server for the Meta Marketing API enabling ad performance reports and operational adjustments like pause/resume and budget changes on client ad accounts, with strict allowlist and read-only safeguards.-