Connect Meta Ads to Claude Code
Step-by-step guide to connect your Meta ad account to Claude Code via MCP Server. Pull campaign data, analyze performance, and get recommendations - directly from your terminal. No Pipeboard, no third party. Direct connection to the Meta Marketing API.
What you'll learn
- How to create a safe, non-expiring System User Token
- How to install the Meta Ads MCP Server locally (no third-party services)
- How to connect the MCP to Claude Code with one command
- The difference between
ads_read(basic) andads_management(advanced) permissions - 53 tools available after connecting - from analytics to campaign management
- Common troubleshooting issues and how to fix them
Contents
Why Connect Meta to Claude Code
ChatGPT can write ad copy for you. But it can't log into your Meta account, pull real numbers, and tell you which campaign to kill.
Claude Code with MCP can. It connects directly to the Meta Marketing API, pulls live data (CPM, CPC, CTR, ROAS), analyzes performance, and gives recommendations based on real data - not made-up numbers.
The connection runs locally on your machine. No proxy server, no third party, no subscription fees. Data flows directly from Meta to you.
Create a Meta Developer App
If you already have a Meta developer app, skip to the next section.
- Go to
developers.facebook.com/apps - Click "Create App"
- Select "Other" then "Business"
- Name your app (e.g., "My Ads MCP")
- Connect your Business Portfolio
- Under Use Cases, select "Create & manage ads"
Generate a System User Token (safe + permanent)
This is the most important step. Instead of generating a personal token that expires in 1-2 hours, we'll create a System User Token that never expires and isn't tied to your personal Facebook account.
- Go to
business.facebook.com/settings - Left sidebar: Users > System users
- Select an existing System User or create a new one (with Employee role)
- Click "Generate token"
- Select your app
- Choose permissions (see Part 07 - Permissions)
- Click "Generate Token"
- Copy the token and save it somewhere safe!
Why System User?
- Never expires - unlike personal tokens that expire in 1-2 hours
- Read-only option -
ads_readcan't modify or delete anything - Not tied to your personal account - separate from your Facebook profile
- Revocable anytime from Business Manager
Install the Meta Ads MCP Server
Run in your terminal:
git clone https://github.com/brijr/meta-mcp.git meta-ads-mcp
cd meta-ads-mcp
npm install @modelcontextprotocol/sdk@1.25.2 --save-exact
npm installImportant: You must pin the SDK version to 1.25.2 - newer versions break the server due to schema format changes.
Connect to Claude Code
Run in your terminal (replace YOUR_TOKEN with the token you copied):
claude mcp add meta-ads --scope user \
-e META_ACCESS_TOKEN=YOUR_TOKEN \
-- npx tsx /path/to/meta-ads-mcp/src/index.tsReplace /path/to/ with the full path to where you cloned the project. After running the command, restart Claude Code.
Verify It Works
After restarting Claude Code, ask:
"Show me all my ad accounts"If everything is working, you'll see a list of your ad accounts with name, currency, and timezone.
More things you can ask:
"List my active campaigns"
"Analyze last week's performance"
"What's the ROAS for each campaign?"
"Which campaign is most profitable and which should I kill?"
"Compare campaign A vs campaign B"
"Show me audience breakdown by age and gender"Permissions - Basic vs Advanced
When generating the token, you choose which permissions to grant. Three tiers:
| Tier | Permissions | What You Get |
|---|---|---|
| Ads only | ads_read | View campaigns, analyze performance, reports, breakdowns |
| Ads + Instagram (recommended for dashboard) | ads_read + business_management + pages_show_list + pages_read_engagement + instagram_basic + instagram_manage_insights | Everything above + Instagram post analytics, stories, reels, reach, followers |
| Full (management) | All above + ads_management + pages_manage_ads | Also manage campaigns, create audiences, upload creatives |
For the workshop dashboard: use the second tier (Ads + Instagram) for the full picture.
What You Get After Connecting
53 tools available via the MCP:
- View: Campaigns, ad sets, ads, audiences, creatives
- Analyze: ROAS, CPM, CPC, CTR, cost per lead, comparisons
- Breakdowns: Segment by age, gender, placement, device, country
- Date Ranges: Today, yesterday, last 7/30/90 days, custom range
- Manage (advanced): Pause/resume campaigns, update budgets, create campaigns
- Audiences (advanced): Create Custom and Lookalike audiences, estimate size
- Creative (advanced): Upload images, create ads, A/B tests, preview ads
- Diagnostics: Account health check, error resolution, API v23 compliance
Everything runs locally. Data flows directly from Meta API to your machine. No third party, no proxy server, no subscription fees.
Troubleshooting
Run claude mcp list and look for meta-ads:
- Connected - all good
- Failed to connect - check:
- Is the token valid? (not expired, not truncated)
- Is the path to
src/index.tscorrect? - Did you install
@modelcontextprotocol/sdk@1.25.2? - Is
npx tsxavailable?
"Invalid token" error:The token expired or isn't authorized. Go back to Business Manager > System Users > Generate Token and create a new one.
SDK error:If you see errors about "Zod schema" or "ToolAnnotations", the SDK version is wrong. Run npm install @modelcontextprotocol/sdk@1.25.2 --save-exact.