Allows for the full management of Facebook advertising, including campaign creation, ad set targeting, performance analytics, and custom audience management via the Meta Marketing API.
Enables interaction with Instagram advertising data to manage campaigns, ad creatives, and performance reporting alongside other Meta-owned platforms.
Provides comprehensive access to the Meta Marketing API for automated campaign lifecycle management, detailed analytics, audience generation, and creative optimization across Facebook and Instagram.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Meta Marketing API MCP ServerShow me performance insights for my active campaigns over the last 7 days"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Meta Marketing API MCP Server
A comprehensive Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with Facebook/Instagram advertising data through the Meta Marketing API. This server provides full campaign lifecycle management, analytics, audience targeting, and creative optimization capabilities.
โก Quick Start
1) Install
2) Configure (Claude Desktop / Cursor)
Create or edit your MCP config:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Minimal config:
If your app requires appsecret_proof, add META_APP_SECRET:
3) Restart your client
Claude Desktop: quit and reopen
Cursor: restart the IDE
4) Verify
๐ Features
Campaign Management
โ Create, update, pause, resume, and delete campaigns
โ Support for all campaign objectives (traffic, conversions, awareness, etc.)
โ Budget management and scheduling
โ Ad set creation with advanced targeting
โ Individual ad management
Analytics & Reporting
๐ Performance insights with customizable date ranges
๐ Multi-object performance comparison
๐ Data export in CSV/JSON formats
๐ฏ Attribution modeling and conversion tracking
๐ Daily performance trends analysis
Audience Management
๐ฅ Custom audience creation and management
๐ฏ Lookalike audience generation
๐ Audience size estimation
๐ Targeting recommendations and insights
๐ฅ Audience health monitoring
Creative Management
๐จ Ad creative creation and management
๐๏ธ Cross-platform ad previews
๐งช A/B testing setup and guidance
๐ธ Creative performance analysis
Enterprise Features
๐ Secure OAuth 2.0 authentication
โก Automatic rate limiting with exponential backoff
๐ Pagination support for large datasets
๐ก๏ธ Comprehensive error handling
๐ Rich MCP resources for contextual data access
๐ Multi-account support
๐ฆ Installation & Setup
Option 1: Direct Installation (Recommended)
Option 2: From Source
Option 3: Automated Setup (Easiest)
The setup script will:
โ Check system requirements
โ Validate your Meta access token
โ Create Claude Desktop configuration
โ Install dependencies
โ Test the connection
๐ง Configuration Guide
Step 1: Get Meta Access Token
Create a Meta App at developers.facebook.com
Add Marketing API product
Generate an access token with
ads_readandads_managementpermissionsIf your app requires
appsecret_proof, setMETA_APP_SECRET(see below)(Optional) Set up OAuth for automatic token refresh
Step 2: Configure Claude Desktop
Find your configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
If the file doesn't exist, create it with the following content:
Basic Configuration (Token-based):
Advanced Configuration (with OAuth + appsecret_proof):
Local Development Configuration:
If you've cloned the repository locally:
Step 3: Configure for Cursor
Cursor uses the same MCP configuration as Claude Desktop. Add the configuration to your Cursor settings:
Open Cursor Settings
Go to "Extensions" > "Claude"
Add the MCP server configuration in the JSON settings
Step 4: Restart Your Client
Claude Desktop: Completely quit and restart the application
Cursor: Restart the IDE
Step 5: Verify Setup
๐ Troubleshooting
Common Issues
1. "Command not found" or "npx" errors
2. Permission errors
3. Meta API connection issues
If the response says appsecret_proof is required, set META_APP_SECRET in your MCP server environment.
4. Check Claude Desktop logs
macOS:
~/Library/Logs/Claude/mcp*.logWindows:
%APPDATA%\Claude\logs\mcp*.log
5. Test the server manually
Debug Mode
Enable debug logging by adding to your environment:
๐ Web Deployment (Vercel)
For web applications, you can deploy this server to Vercel and expose an HTTP MCP endpoint:
Configuration:
Deploy to Vercel
Set environment variables in Vercel dashboard
Configure OAuth app in Meta Developer Console
Use the web endpoint:
https://your-project.vercel.app/api/mcp
MCP Client Configuration for Web:
Note: You need to authenticate against your deployment to get a session token.
Remote MCP Configuration (mcp-remote)
For Vercel deployments, use mcp-remote to bridge HTTP to stdio:
๐ ๏ธ Available Tools
This MCP server provides 25 comprehensive tools across all major Meta advertising categories:
๐ Analytics & Insights (3 tools)
get_insights- Get detailed performance metrics (impressions, clicks, ROAS, CTR, CPC, etc.)compare_performance- Side-by-side performance comparison of multiple campaigns/adsexport_insights- Export performance data in JSON or CSV formats
๐ Campaign Management (4 tools)
create_campaign- Create new advertising campaigns with full configuration (includes special_ad_categories)update_campaign- Modify existing campaigns (name, budget, status, etc.)pause_campaign- Pause active campaignsresume_campaign- Resume/activate paused campaigns
๐ฏ Ad Set Management (2 tools)
create_ad_set- Create ad sets with detailed targeting, budgets, and optimization goalslist_ad_sets- List and filter ad sets within campaigns
๐ฑ Ad Management (2 tools)
create_ad- Create individual ads within ad sets using creative IDslist_ads- List and filter ads by ad set, campaign, or account
๐ฅ Audience Management (4 tools)
list_audiences- List all custom audiences for an accountcreate_custom_audience- Create custom audiences from various sourcescreate_lookalike_audience- Generate lookalike audiences from source audiencesget_audience_info- Get detailed information about specific audiences
๐จ Creative Management (2 tools)
list_ad_creatives- List all ad creatives for an accountcreate_ad_creative- Create new ad creatives with rich specifications (supports external image URLs)
๐ง Account & Basic Tools (3 tools)
health_check- Comprehensive authentication and server status checkget_ad_accounts- List accessible Meta ad accountsget_campaigns- List campaigns with filtering options
๐ Authentication Tools (1 tool)
get_token_info- Token validation and information retrieval
๐ฉบ Diagnostic Tools (2 tools)
diagnose_campaign_readiness- Check campaign status and identify ad set creation issuescheck_account_setup- Comprehensive account validation and setup verification
๐ ๏ธ Usage Examples
Test the Connection
Analytics & Performance Insights
Campaign Management
Complete Campaign Setup (Campaign โ Ad Set โ Ads)
Troubleshooting & Diagnostics
Audience Management
Creative Management
Account Management
๐ Resources Access
The server provides rich contextual data through MCP resources:
meta://campaigns/{account_id}- Campaign overviewmeta://insights/account/{account_id}- Performance dashboardmeta://audiences/{account_id}- Audience insightsmeta://audience-health/{account_id}- Audience health report
๐ง Environment Variables
Required
Optional
๐ Documentation
All documentation is in this README (setup, configuration, and tools)
Example Configuration - Sample configuration file
๐๏ธ Architecture
Core Components
Meta API Client: Handles authentication, rate limiting, and API communication
Tool Handlers: 25 tools covering analytics, campaigns, ad sets, ads, audiences, creatives, and diagnostics
Resource Providers: Contextual data access for AI understanding
Error Management: Robust error handling with automatic retries
Rate Limiter: Intelligent rate limiting with per-account tracking
๐ Security & Best Practices
Token Security
โ Environment variable configuration
โ No token logging or exposure
โ Automatic token validation
โ Secure credential management
API Management
โ Rate limit compliance
โ Exponential backoff retries
โ Request validation
โ Error boundary protection
Data Privacy
โ Meta data use policy compliance
โ No persistent data storage
โ Secure API communication
โ Audit trail support
โก Performance
Rate Limits
Development Tier: 60 API calls per 5 minutes
Standard Tier: 9000 API calls per 5 minutes
Automatic Management: Built-in rate limiting and retry logic
Optimization
๐ Concurrent request processing
๐ฆ Efficient pagination handling
๐ฏ Smart data caching
โก Minimal memory footprint
๐งช Testing
Run the test suite:
Test with example client:
Health check:
๐ค Contributing
Fork the repository
Create a feature branch:
git checkout -b feature/new-featureMake your changes and add tests
Run the test suite:
npm testSubmit a pull request
๐ License
MIT License - see LICENSE for details.
๐ Support
Documentation: See this README
Issues: Open an issue on GitHub
Meta API: Refer to Meta Marketing API docs
MCP Protocol: See Model Context Protocol specification
Built for reliable Meta Marketing API automation with MCP.