meta-ads-mcp
MCP server for Meta Ads (Facebook Ads) that provides tools for account discovery, campaign/adset/ad creation, custom audiences, status updates, performance reporting, and A/B testing.
README
Meta Ads MCP Server
A Model Context Protocol (MCP) server built with Python and fastmcp to integrate Meta Ads (Facebook Ads) Graph API directly with AI coding assistants (like Antigravity and Claude Desktop).
This server maps Meta Ads API calls directly to easy-to-use, semantic tools for account discovery, campaign/adset/ad creation, custom audiences, status updates, campaign performance queries, placement breakdowns, demographic breakdowns, video retention analysis, and statistical A/B significance testing.
๐ Table of Contents
- Features & Tool Directory
- Step 1: Prerequisites & Credentials
- Step 2: Local Installation
- Step 3: Registering with Antigravity IDE
- Step 4: Registering with Claude Desktop
- Step 5: Verifying the Connection
- Step 6: Pushing to GitHub
๐ ๏ธ Features & Tool Directory
The server exposes 21 semantic tools categorized into 5 main groups:
1. Account Discovery
list_accounts: Lists all accessible Facebook ad accounts including IDs, names, statuses, currencies, and total spent.
2. Performance Reporting (Level-specific & Segmented)
All reporting tools support outputting results as a Markdown Table (default), CSV, or raw JSON.
get_campaign_performance: Fetch campaign-level insights (impressions, clicks, CTR, spend, CPC, conversions, conversion values).get_adset_performance: Fetch adset-level performance details.get_ad_performance: Fetch ad-level performance and creative insights.get_device_performance: Segment campaign performance by device platform (mobile, desktop, etc.).get_geo_performance: Segment campaign performance by country.get_placement_performance: Segment performance by publisher platform (Facebook/Instagram), placement position (Feeds/Stories), and device platform.get_demographic_performance: Segment campaign performance by age and gender demographics.get_video_performance: Fetch detailed video-specific plays, average watch time, and watched retention milestones (25%, 50%, 75%, 95%, 100% video completions).get_creative_report: Merges ad creative details (title, body, text copy, image thumbnail) with performance metrics.
3. Audiences & Forms Management
list_custom_audiences: List remarketing lists, customer list audiences, and website pixel audiences.create_lead_form: Create Meta Lead Generation Instant Forms on a Facebook Page.
4. Advanced Analytics & A/B Testing
analyze_cross_campaign_performance: Runs cross-campaign health checks, details best/worst performing campaigns, and suggests concrete budget reallocation or creative refresh strategies.analyze_ab_test: Conducts statistical z-score calculations comparing CTR, CVR, and CPA between two campaigns (control vs variation) and indicates statistical significance (90%, 95%, 99% confidence levels).
5. Campaign & Creative Creations
create_campaign: Create new campaigns (supports objectives likeOUTCOME_TRAFFIC,OUTCOME_SALES,OUTCOME_LEADS,OUTCOME_AWARENESS,OUTCOME_ENGAGEMENT,OUTCOME_APP_PROMOTION).create_adset: Create adsets containing schedules, optimization goals, targeting specs, and budgets.create_ad_creative: Prepare ad creative layouts linked to a page.create_ad: Spin up ads under your adsets with your creatives.
6. Status Mutation
update_campaign_status: Activate (ACTIVE) or pause (PAUSED) campaigns.update_adset_status: Activate or pause adsets.update_ad_status: Activate or pause ads.
๐ Step 1: Prerequisites & Credentials
To use the Meta Ads MCP Server, you need to obtain credentials from the Meta Developer platform.
1.1 Generate a Facebook Access Token
- Go to the Meta for Developers Portal.
- Create a new App (choose Business or Other depending on your business requirements).
- Set up the Marketing API product inside the app dashboard.
- Navigate to Marketing API -> Tools.
- Select the required permissions:
ads_readads_managementbusiness_management
- Click Generate Token and copy the access token.
1.2 Locate Ad Account ID
- Navigate to your Meta Ads Manager.
- In the account dropdown, copy the 15-digit Ad Account ID (e.g.
123456789012345).
๐ป Step 2: Local Installation
-
Navigate to the project directory:
cd C:\Users\prala\.gemini\antigravity-ide\scratch\meta-ads-mcp -
Create a virtual environment:
python -m venv venv -
Install required packages:
.\venv\Scripts\pip install -r requirements.txt -
Create your
.envcredentials file by creating a file named.envin the root of the project directory with the following contents:# Meta Graph API Credentials META_ADS_ACCESS_TOKEN=EACJye51NVHcBO6... (your token) META_ADS_AD_ACCOUNT_ID=act_1234567890... (your ad account ID, optional)
โ๏ธ Step 3: Registering with Antigravity IDE
To integrate the Meta Ads MCP Server directly with your Google Antigravity IDE assistant:
- Ensure your
.envfile is populated with your active Meta credentials. - Execute the registration script inside your virtual environment:
.\venv\Scripts\python configure_antigravity_mcp.py - This script will read credentials from
.envand configure them inside the Antigravity global configuration file (C:\Users\prala\.gemini\config\mcp_config.json). - Restart your Antigravity IDE (or rebuild your agent connections) to load the new server. You will see 21 tools prefixed with
mcp_meta-ads_*registered.
โ๏ธ Step 4: Registering with Claude Desktop
To use the connector locally with your Claude Desktop client:
- Execute the local registration script:
.\venv\Scripts\python configure_local_mcp.py - The script will write your local
.envand automatically add themeta-adsserver block into your Claude Desktop configuration file (%APPDATA%\Claude\claude_desktop_config.json). - Restart your Claude Desktop App to apply the configuration.
๐งช Step 5: Verifying the Connection
You can verify that the server is functional and authenticating correctly with the Meta API:
5.1 Run the Automated Test Client
Run the verification script to confirm all 21 tools are successfully registered in FastMCP:
.\venv\Scripts\python test_client.py
Expected Output:
Importing Meta Ads MCP Server...
Successfully loaded MCP Server!
Server Name: Meta Ads MCP Server
Checking registered MCP tools:
1. Tool name: list_accounts
Description: List all Meta Ad Accounts accessible...
...
21. Tool name: analyze_ab_test
Description: Perform a statistical A/B test analysis...
Total Tools Registered: 21
Dry-run validation PASSED: Server script compiles and registers all endpoints successfully.
5.2 Test Active Account Fetching
Verify that your access token is valid and can retrieve real data:
.\venv\Scripts\python -c "import server; print(server.list_accounts())"
This should print a JSON array listing all your active ad accounts, their status codes, and currency configurations.
๐ค Step 6: Pushing to GitHub
To push the codebase and documentations to your remote GitHub repository:
- Go to your GitHub account (
pralayasimha23). - Create a new public/private repository named
meta-ads-mcp. - Run the automated Git push script:
.\venv\Scripts\python push_to_github.py
This script will initialize Git, commit all code, configure the remote origin, and push the repository to https://github.com/pralayasimha23/meta-ads-mcp.git.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.