Meta Ads MCP Server
Provides access to Meta Marketing API for comprehensive ad analytics and AI-powered video creative analysis.
README
Meta Ads MCP Server
A Model Context Protocol (MCP) server that provides access to Meta Marketing API for comprehensive ad analytics and AI-powered video creative analysis.
Quick Start (Claude Code)
claude mcp add --transport http meta-ads https://sp-meta-ads-mcp.fly.dev/mcp
Then ask:
"Show me campaign performance for last 7 days"
Claude will prompt you to authenticate with Facebook automatically.
Manual Configuration
Edit ~/.config/claude-code/mcp.json:
{
"mcpServers": {
"meta-ads": {
"url": "https://sp-meta-ads-mcp.fly.dev/mcp",
"transport": "http"
}
}
}
Features
- Facebook OAuth Authentication with multi-user session isolation
- 18 MCP Tools for ad analytics, creative analysis, and comparisons
- AI Video Analysis via Gemini AI with Firestore caching
- StreamableHTTP Transport for remote MCP connections
Available Tools (18)
Performance Analytics
| Tool | Description |
|---|---|
get-account |
Ad account info and summary metrics |
get-performance |
Unified metrics at campaign/adset/ad level with relevance diagnostics |
get-video-metrics |
Video completion funnel, engagement depth, retention scoring |
get-demographics |
Breakdowns by age, gender, country, device, platform, placement |
get-creative-fatigue |
Daily frequency/CTR trends with fatigue scoring |
get-creative-performance |
Aggregate performance by creative ID across ads |
list-custom-conversions |
Available custom conversion events |
Creative Analysis
| Tool | Description |
|---|---|
get-ad-creative-text |
Extract ad copy (primary, headline, description) |
analyze-video-creative |
AI scene-by-scene analysis of Meta video ads |
batch-analyze-video-creative |
Parallel AI analysis of multiple video ads |
analyze-video-url |
Analyze video from URL (Google Drive, Dropbox, direct) |
analyze-image-url |
Analyze image from URL |
analyze-ad-themes |
Cluster ads by messaging theme correlated with performance |
Comparisons
| Tool | Description |
|---|---|
compare-time-periods |
A/B time period analysis |
compare-entities |
Rank campaigns/adsets/ads side by side |
Account & Setup
| Tool | Description |
|---|---|
get-saved-audiences |
List saved targeting audiences |
get-facebook-pages |
List linked Facebook pages |
list-ad-sets |
List ad sets in a campaign |
Run Locally
Prerequisites
- Node.js 24+
- Meta/Facebook Developer Account with an ad account
- Facebook App with OAuth configured
Optional (for video analysis):
- Google Cloud Storage bucket
- Firestore database
- Gemini API key or Vertex AI
Setup
git clone https://github.com/superpower-growth/meta-ads-mcp.git
cd meta-ads-mcp
cp .env.example .env
# Edit .env with your credentials
npm install
npm run build
npm start
For local development without OAuth, set REQUIRE_AUTH=false in .env.
Environment Variables
See .env.example for full documentation. Key variables:
| Variable | Description |
|---|---|
META_ACCESS_TOKEN |
Long-lived token from Graph API Explorer |
META_AD_ACCOUNT_ID |
Ad account ID (format: act_123456789) |
FACEBOOK_APP_ID |
From Facebook App Settings |
FACEBOOK_APP_SECRET |
From Facebook App Settings |
SESSION_SECRET |
Random 32+ char secret (openssl rand -base64 32) |
REQUIRE_AUTH |
true for OAuth, false for local dev |
Video Analysis (Optional)
| Variable | Description |
|---|---|
GEMINI_API_KEY |
Gemini API key (or use Vertex AI) |
GOOGLE_SERVICE_ACCOUNT_JSON |
GCP service account key |
GCS_BUCKET_NAME |
GCS bucket for video staging |
FIRESTORE_CACHE_TTL_HOURS |
Cache TTL (default: 24) |
Deployment
Docker
docker build -t meta-ads-mcp .
docker run -d -p 3000:3000 --env-file .env meta-ads-mcp
Fly.io
fly deploy
API Endpoints
| Endpoint | Description |
|---|---|
GET /health |
Health check (no auth) |
GET /mcp |
MCP SSE streaming |
POST /mcp |
MCP request/response |
GET /mcp-metadata |
MCP server metadata for claude add |
Troubleshooting
"Session not found" after redeployment — Restart Claude Code to reconnect. Tokens are persisted in Firestore.
"Unauthorized" errors — Sessions last 24 hours. Re-authenticate by restarting Claude Code.
Meta API errors — Verify your token has ads_read permission and META_AD_ACCOUNT_ID has the act_ prefix.
License
MIT
Built with the Model Context Protocol SDK
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.