Meta Ads MCP Server
Provides tools for managing Facebook/Meta ad accounts through the Graph Marketing API — listing and inspecting campaigns, ad sets, ads, creatives and audiences, pulling performance insights with date ranges and breakdowns, creating and updating entities (paused by default, with dry-run validation), and diagnosing delivery issues.
Core integration with the Meta (Facebook) Marketing API across multiple client ad accounts: browse and inspect account structure (campaigns, ad sets, ads), query performance insights with flexible date ranges, breakdowns and side-by-side comparisons, create and manage campaigns, ad sets, ads, link creatives, custom/lookalike audiences and uploaded image/video assets, and run campaign, ad set and ad diagnostics for delivery issues. All writes default to PAUSED, support dry-run, and use archiving instead of deletion.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Meta Ads MCP Server
A locally-hosted MCP server for managing Meta (Facebook) Ads across multiple client ad accounts via Claude Desktop, Claude Code, and other MCP clients.
Features
Browse and inspect ad account structure (campaigns, ad sets, ads)
Query performance insights with flexible date ranges and breakdowns
Create and manage campaigns, ad sets, ads, creatives, and audiences
Diagnose delivery issues with campaign, ad set, and ad diagnostics
Compare performance across entities side-by-side
Multi-account support for agency workflows
All output formatted as markdown for LLM readability
Related MCP server: meta-ads-manager-mcp
Prerequisites
Python 3.12+
Meta developer account with Marketing API access (see setup guide below)
Installation
git clone https://github.com/tomleelong/MetaAdsMCP.git
cd MetaAdsMCP
uv syncGetting a Meta Access Token
If you don't have Meta developer credentials yet, follow these steps:
1. Create a Meta App
Go to developers.facebook.com and log in
Click My Apps > Create App
Select Other as the use case, then Business as the app type
Name your app and click Create App
2. Add Marketing API
In your app dashboard, click Add Product
Find Marketing API and click Set Up
3. Generate a User Access Token (for development)
Go to Graph API Explorer
Select your app from the dropdown
Click Generate Access Token
Grant the required permissions:
ads_read,ads_managementCopy the token — this is a short-lived token (expires in ~1 hour)
4. Exchange for a Long-Lived Token (60 days)
curl -X GET "https://graph.facebook.com/v25.0/oauth/access_token?\
grant_type=fb_exchange_token&\
client_id=YOUR_APP_ID&\
client_secret=YOUR_APP_SECRET&\
fb_exchange_token=YOUR_SHORT_LIVED_TOKEN"The response contains a access_token field with your long-lived token (valid for 60 days).
5. (Recommended) Create a System User Token
For a non-expiring token suitable for production use:
Go to Business Manager > Business Settings
Navigate to Users > System Users
Click Add to create a new system user
Assign the system user to your ad accounts with appropriate permissions
Click Generate New Token, select your app, and grant
ads_readandads_managementThis token does not expire
Required Permissions
Permission | Purpose |
| Read campaigns, ad sets, ads, insights, audiences, creatives |
| Create and update campaigns, ad sets, ads, creatives, audiences |
Configuration
Copy the example environment file and fill in your credentials:
cp .env.example .envEnvironment Variables
Variable | Required | Default | Description |
| Yes | — | Meta API access token |
| Yes | — | Meta App ID from app dashboard |
| Yes | — | Meta App Secret from app dashboard |
| No | — | Default ad account ID (with |
| No |
| Meta Graph API version |
Usage
Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"meta-ads": {
"command": "uv",
"args": ["--directory", "/path/to/MetaAdsMCP", "run", "python", "-m", "meta_ads_mcp"],
"env": {
"META_ACCESS_TOKEN": "your_token_here",
"META_APP_ID": "your_app_id",
"META_APP_SECRET": "your_app_secret",
"META_DEFAULT_AD_ACCOUNT_ID": "act_your_account_id"
}
}
}
}Claude Code
Add to your project's .mcp.json:
{
"mcpServers": {
"meta-ads": {
"command": "uv",
"args": ["run", "python", "-m", "meta_ads_mcp"],
"cwd": "/path/to/MetaAdsMCP"
}
}
}Permissions
All tools include MCP tool annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) so clients can make informed permission decisions. However, Claude Code requires explicit allow rules — annotations alone don't auto-approve tools.
Within this project: The project-level .claude/settings.json auto-allows read-only tools (get_*, list_*, compare_performance). Write tools require approval on each use.
From other projects: Project-level permissions don't apply. To allow all tools globally, add to ~/.claude/settings.json:
{
"permissions": {
"allow": [
"mcp__meta-ads__*"
]
}
}Or for read-only tools only:
{
"permissions": {
"allow": [
"mcp__meta-ads__get_*",
"mcp__meta-ads__list_*",
"mcp__meta-ads__compare_performance"
]
}
}Security Considerations
This MCP server cannot modify account access, user permissions, login credentials, billing, or payment methods. There are no tools for account administration — a compromised server cannot lock anyone out of their account.
Worst-case impact if credentials are compromised:
Risk | Details |
Financial | Creating campaigns/budgets could spend money once activated |
Disruption | Pausing or archiving campaigns, ad sets, or ads |
Data exposure | Reading account performance, targeting details, and audience information |
Safety guards:
All new campaigns, ad sets, and ads default to PAUSED status
Write tools accept
dry_run=Trueto validate without executingNo delete operations — use archive (
ARCHIVEDstatus) insteadBudget changes show before/after comparison in output
Available Tools (36)
Accounts (2)
Tool | Description |
| List all accessible ad accounts |
| Get detailed info for a specific ad account |
Campaigns (5)
Tool | Description |
| List campaigns with status filtering |
| Get detailed campaign info |
| Create a new campaign (defaults to PAUSED) |
| Update campaign name, budget, status, or schedule |
| Diagnose delivery issues and get recommendations |
Ad Sets (5)
Tool | Description |
| List ad sets with optional campaign filter |
| Get detailed ad set info including targeting |
| Create ad set with targeting, budget, schedule |
| Update ad set settings |
| Diagnose issues with learning stage info |
Ads (5)
Tool | Description |
| List ads with optional filters |
| Get detailed ad info with creative reference |
| Create a new ad with creative reference |
| Pause, activate, or archive an ad |
| Review feedback, delivery checks, and issues |
Insights (5)
Tool | Description |
| Flexible insights query with date range, breakdowns, level |
| Account-level performance summary |
| Campaign performance with period comparison |
| Compare entities side-by-side |
| Age, gender, placement, or device breakdowns |
Creatives (4)
Tool | Description |
| List ad creatives for an account |
| Get creative details including thumbnail and body |
| Create a link ad creative with page, image, CTA |
| Update creative name, URL tags, or status |
Audiences (4)
Tool | Description |
| List custom and lookalike audiences |
| Get audience details including size and status |
| Create website, customer list, or app audiences |
| Create a lookalike from an existing audience |
Assets (6)
Tool | Description |
| Upload an image file, returns hash for use in creatives |
| Upload a video from local file or URL |
| List ad images for an account |
| Get image details by hash |
| List ad videos for an account |
| Get video details by ID |
Safety Patterns
All write operations follow these safety conventions:
PAUSED by default — newly created campaigns, ad sets, and ads start as PAUSED
Dry run support — pass
dry_run=Trueto validate parameters without making changesArchive, not delete — use status
ARCHIVEDinstead of deleting entitiesBudget display — update operations show before/after values for budget changes
Budgets in dollars — pass budgets as dollar strings (e.g.,
"50.00"); conversion to cents is handled internally
Troubleshooting
Common Meta API errors and how to resolve them:
Error Code | Cause | Fix |
17, 32, 613 | Rate limit exceeded | Wait a few minutes and retry |
190 | Token expired or invalid | Generate a new access token |
200, 10 | Insufficient permissions | Ensure token has |
100 | Invalid parameter | Check parameter values and formats |
2, 4 | Temporary Meta API issue | Retry after a few minutes |
When errors occur, the server includes the error code and an actionable suggestion in the output.
Architecture
src/meta_ads_mcp/
__init__.py
__main__.py # Entry point
server.py # FastMCP server with lifespan management
config.py # Environment-based configuration
client.py # Async Meta API client (single SDK interface)
models.py # Pydantic v2 models for all entity types
formatting.py # Markdown formatters for LLM output
tools/
__init__.py # get_client() context helper
_write_helpers.py # Shared write utilities (budget, validation, etc.)
_insights_helpers.py # Date preset resolution, period comparison
accounts.py # Account listing and info
campaigns.py # Campaign CRUD + diagnostics
adsets.py # Ad set CRUD + diagnostics
ads.py # Ad CRUD + diagnostics
insights.py # Performance reporting and analytics
creatives.py # Creative CRUD
audiences.py # Audience creation and listingKey design decisions:
Tools return markdown — never raw JSON or SDK objects
Single API client —
MetaAdsClientis the only SDK interface; tools never call the SDK directlyAsync wrapping —
asyncio.to_thread()wraps synchronous SDK callsPydantic models — intermediate layer between SDK responses and formatted output
Multi-account — tools accept
account_id; server has a configurable default
Example Queries
Once configured, you can ask Claude things like:
"Show me all active campaigns for account act_123456789"
"What's the ROAS for Campaign X over the last 30 days?"
"Compare performance between Campaign A and Campaign B this quarter"
"Break down ad set performance by age and gender"
"Create a new traffic campaign called 'Spring Sale 2026' with a $50/day budget"
"Pause all ads in the 'Test Campaign' ad set"
"List all custom audiences with more than 10,000 people"
"What diagnostics issues does my campaign have?"
"Create a lookalike audience based on my website visitors in the US"
"Create a link ad creative with a SHOP_NOW CTA"
"Show this quarter's insights compared to last quarter"
Development
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=meta_ads_mcp
# Lint
uv run ruff check .
# Format
uv run black .
# Type check
uv run mypy src/See docs/testing.md for the full testing guide including live tests and MCP Inspector usage.
Testing with MCP Inspector
npx @modelcontextprotocol/inspector uv run python -m meta_ads_mcpLicense
Apache-2.0
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Analyze, edit and launch Meta (Facebook and Instagram) ads from Claude, ChatGPT, Cursor or Codex. Query insights and campaign health, change budgets, bids, status and targeting with undo, bulk-launch many ads across campaigns and ad sets from a live ad's settings, and duplicate by post to keep social proof. Choose per ad account what the agent may do and what waits in the Agent Inbox for approval. Requires a paid Ads Uploader account with MCP access.
Meta Ads MCP server: run Facebook and Instagram campaigns, ad sets, ads and reports from AI.
Meta, TikTok, LinkedIn, Snapchat and Reddit ads in Claude. Connect an ad account first.
The simplest way to manage your Meta (Facebook and Instagram) ad accounts with your AI agent.
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to manage Facebook and Instagram advertising campaigns through the Meta Marketing API. Supports full campaign lifecycle management, performance analytics, audience targeting, and creative optimization.-
- AlicenseAqualityCmaintenanceEnables users to create, manage, and monitor Meta (Facebook/Instagram) ad campaigns directly from Claude using natural language.13137 PyPI17MIT
- FlicenseNot gradedqualityDmaintenanceEnables Claude to fetch and analyze Meta ad accounts, campaigns, ad sets, ads, and performance insights via the Meta Marketing API.-
- FlicenseNot gradedqualityDmaintenanceConnects Claude with the Meta Marketing API to analyze and manage Facebook/Instagram ad campaigns, including retrieving insights, updating campaign status, and listing accounts.-