A Model Context Protocol (MCP) server that provides Facebook Ads functionality for Claude and other MCP clients. Access your Facebook advertising data, insights, and account information directly through natural language conversations.
🚀 Quick Start for Claude Desktop Usersnpm install -g facebook-ads-mcp-server2. Create Facebook Developer App
http://localhost:3002/auth/callback
Add this to your Claude Desktop MCP settings:
{ "mcpServers": { "facebook-ads": { "command": "facebook-ads-mcp", "env": { "FACEBOOK_APP_ID": "your_facebook_app_id", "FACEBOOK_APP_SECRET": "your_facebook_app_secret", "FACEBOOK_REDIRECT_URI": "http://localhost:3002/auth/callback" } } } }4. Restart Claude Desktop
After adding the configuration, restart Claude Desktop and start asking about your Facebook ads!
💬 Example Conversations with ClaudeOnce configured, you can ask Claude things like:
Clone and install dependencies:
cd facebook-ads-mcp npm install
Configure environment:
cp .env.example .env # Edit .env with your Facebook access token
Get Facebook Access Token:
ads_read
ads_management
business_management
# Development mode with auto-restart npm run dev # Production mode npm start
Add to your MCP client configuration:
{ "mcpServers": { "facebook-ads-mcp": { "command": "node", "args": ["src/index.js"], "cwd": "/path/to/facebook-ads-mcp", "env": { "FACEBOOK_ACCESS_TOKEN": "your_facebook_access_token" } } } }1. facebook_list_ad_accounts
Lists all Facebook ad accounts accessible with the provided credentials.
Parameters: None
Example:
// No parameters required {}
Response:
{ "adaccounts": { "data": [ { "name": "My Ad Account", "id": "act_1234567890" } ] }, "id": "user_id" }2. facebook_fetch_pagination_url
Fetches data from a Facebook Graph API pagination URL.
Parameters:
url
(string, required): The complete pagination URLExample:
{ "url": "https://graph.facebook.com/v18.0/act_123/insights?after=cursor_string&access_token=..." }3. facebook_get_details_of_ad_account
Gets details of a specific ad account based on requested fields.
Parameters:
act_id
(string, required): The ad account ID (e.g., "act_1234567890")fields
(array, optional): Fields to retrieveAvailable Fields:
name
, business_name
, age
, account_status
, balance
, amount_spent
attribution_spec
, account_id
, business
, business_city
brand_safety_content_filter_levels
, currency
, created_time
, id
Example:
{ "act_id": "act_1234567890", "fields": ["name", "account_status", "balance", "currency"] }4. facebook_get_adaccount_insights
Retrieves performance insights for a specified Facebook ad account.
Parameters:
act_id
(string, required): The ad account IDfields
(array, required): Performance metrics to retrievedate_preset
(string, optional): Predefined time range (last_7d, last_30d, etc.)level
(string, optional): Aggregation level (account, campaign, adset, ad)breakdowns
(array, optional): Result breakdown dimensions (placement, age, gender, country, etc.)action_breakdowns
(array, optional): Breakdown dimensions for actions/conversionstime_range
(object, optional): Custom time range with since/until datestime_increment
(string/number, optional): Time aggregation period (1=daily, 7=weekly, "monthly"=monthly)limit
(number, optional): Maximum results per pageafter
/before
(string, optional): Pagination cursorsExamples:
Basic Performance Data:
{ "act_id": "act_1234567890", "fields": ["impressions", "clicks", "spend", "ctr"], "date_preset": "last_30d", "level": "campaign" }
Performance by Placement with Conversions:
{ "act_id": "act_1234567890", "fields": ["spend", "actions", "conversions", "cost_per_action_type"], "breakdowns": ["placement"], "action_breakdowns": ["action_type"], "date_preset": "last_7d" }
Demographic Analysis (Age/Gender):
{ "act_id": "act_1234567890", "fields": ["spend", "actions", "conversions"], "breakdowns": ["age", "gender"], "action_breakdowns": ["action_type"], "date_preset": "last_7d" }
Daily Performance Breakdown:
{ "act_id": "act_1234567890", "fields": ["spend", "actions", "conversions", "date_start", "date_stop"], "time_increment": 1, // 1 = daily breakdown "date_preset": "last_30d" }🎯 Enhanced Conversion Tracking
This tool automatically enhances conversion tracking by:
Problem Solved: Custom events like start_trial
often don't appear in the Facebook API's actions
field but are available in the conversions
field. Previously, requests for only actions
would miss conversion events, leading to incomplete data.
Solution: When you request the actions
field, the system automatically includes conversions
as well, then uses a priority system:
conversions
field (higher fidelity data)actions
field if conversion data unavailableExample with Auto-Enhancement:
// Your request: { "fields": ["spend", "actions"] } // Automatically becomes: { "fields": ["spend", "actions", "conversions"] // conversions auto-added }
This ensures you capture conversion events like start_trial
, purchase
, and custom events that might only exist in the conversions field.
Retrieves activities for a Facebook ad account.
Parameters:
act_id
(string, required): The ad account IDfields
(array, optional): Activity fields to retrievesince
/until
(string, optional): Date range in YYYY-MM-DD formattime_range
(object, optional): Custom time range objectlimit
(number, optional): Maximum activities per pageExample:
{ "act_id": "act_1234567890", "fields": ["event_type", "event_time", "actor_name"], "since": "2024-01-01", "until": "2024-01-31" }
The server provides detailed error responses with appropriate error codes:
FACEBOOK_API_ERROR
: Facebook Graph API errorsVALIDATION_ERROR
: Parameter validation failuresTIMEOUT_ERROR
: Request timeout errorsINTERNAL_ERROR
: Server-side errors# Required FACEBOOK_ACCESS_TOKEN=your_facebook_access_token # Optional FACEBOOK_API_VERSION=v18.0 FACEBOOK_BASE_URL=https://graph.facebook.com MCP_SERVER_NAME=facebook-ads-mcp MCP_SERVER_VERSION=1.0.0 DEBUG=true LOG_LEVEL=info
# Run test script npm test
Ensure your access token has the following permissions:
ads_read
: Read ad account dataads_management
: Manage ad accounts (if needed)business_management
: Access business informationInvalid Access Token
API Rate Limiting
Permission Errors
Enable debug logging:
facebook-ads-mcp/
├── src/
│ ├── index.js # Main MCP server
│ ├── tools/ # Tool implementations
│ │ ├── list-ad-accounts.js
│ │ ├── fetch-pagination.js
│ │ ├── get-account-details.js
│ │ ├── get-account-insights.js
│ │ └── get-account-activities.js
│ ├── utils/ # Utilities
│ │ ├── facebook-api.js # Facebook API client
│ │ ├── validation.js # Parameter validation
│ │ └── error-handler.js # Error handling
│ └── schemas/
│ └── tool-schemas.js # JSON schemas
├── package.json
├── mcp.json # MCP configuration
└── README.md
📋 Claude Desktop Setup Guide Finding Your MCP Settings File
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%/Claude/claude_desktop_config.json
Complete Configuration Example
{ "mcpServers": { "facebook-ads": { "command": "facebook-ads-mcp", "env": { "FACEBOOK_ACCESS_TOKEN": "EAAxxxxxxxxxxxxx", "FACEBOOK_API_VERSION": "v23.0" } } } }
Server not starting?
No data returned?
ads_read
Permission errors?
For developers who want to modify or extend this server:
# Clone the repository git clone https://github.com/fortytwode/10xer.git cd 10xer # Install dependencies npm install # Copy environment template cp .env.example .env # Edit .env with your Facebook access token # Run in development mode npm run dev # Run tests npm test
Contributions are welcome! Please feel free to submit a Pull Request.
Status: ✅ Released in v1.2.0
facebook_get_ad_creatives
Live Use Cases:
Timeline: Current priority
Status: Next Up
Use Cases:
Timeline: 1-2 months
Status: Research phase
Technical Approach:
We welcome contributions to help build these features! Check our GitHub Issues for current development tasks.
MIT License
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4