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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。