Socket
Book a DemoInstallSign in
Socket

meta-ads-mcp

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meta-ads-mcp

Model Context Protocol server for Meta Marketing API integration

1.1.0
latest
npmnpm
Version published
Weekly downloads
19
72.73%
Maintainers
1
Weekly downloads
ย 
Created
Source

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.

๐Ÿš€ 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

npm install -g meta-ads-mcp

Option 2: From Source

git clone https://github.com/your-org/meta-ads-mcp.git
cd meta-ads-mcp
npm install
npm run build

๐Ÿ”ง Quick Setup

1. Get Meta Access Token

  • Create a Meta App at developers.facebook.com
  • Add Marketing API product
  • Generate an access token with ads_read and ads_management permissions

CleanShot 2025-06-17 at 15 52 35@2x

2. Configure Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "meta-ads": {
      "command": "npx",
      "args": ["-y", "meta-ads-mcp"],
      "env": {
        "META_ACCESS_TOKEN": "your_access_token_here"
      }
    }
  }
}

3. Restart Claude Desktop

The server will be available for use with Claude.

๐Ÿ› ๏ธ Usage Examples

Campaign Management

Create a new traffic campaign named "Holiday Sale 2024" with a $50 daily budget
List all active campaigns and show their performance for the last 7 days
Pause all campaigns with CPC above $2.00

Analytics & Reporting

Compare the performance of my top 3 campaigns over the last 30 days
Export campaign performance data for last quarter as CSV
Show me daily performance trends for campaign 123456 over the last 14 days

Audience Management

Create a lookalike audience based on my best customers targeting US users
Estimate the audience size for females aged 25-45 interested in fitness
Show me the health status of all my custom audiences

Creative Management

Create an ad creative with title "Summer Sale" and preview it for mobile feed
Set up an A/B test comparing different headlines for my campaign

๐Ÿ“š Resources Access

The server provides rich contextual data through MCP resources:

  • meta://campaigns/{account_id} - Campaign overview
  • meta://insights/account/{account_id} - Performance dashboard
  • meta://audiences/{account_id} - Audience insights
  • meta://audience-health/{account_id} - Audience health report

๐Ÿ”ง Configuration

Environment Variables

# Required
META_ACCESS_TOKEN=your_access_token_here

# Optional
META_APP_ID=your_app_id
META_APP_SECRET=your_app_secret
META_BUSINESS_ID=your_business_id
META_API_VERSION=v23.0
META_API_TIER=standard  # or 'development'

Advanced Configuration

See Configuration Guide for detailed setup options.

๐Ÿ“– Documentation

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Claude AI     โ”‚โ—„โ”€โ”€โ–บโ”‚ MCP Server       โ”‚โ—„โ”€โ”€โ–บโ”‚ Meta Marketing  โ”‚
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚ API             โ”‚
โ”‚ - Natural       โ”‚    โ”‚ - Authentication โ”‚    โ”‚                 โ”‚
โ”‚   Language      โ”‚    โ”‚ - Rate Limiting  โ”‚    โ”‚ - Campaigns     โ”‚
โ”‚ - Tool Calls    โ”‚    โ”‚ - Error Handling โ”‚    โ”‚ - Analytics     โ”‚
โ”‚ - Resource      โ”‚    โ”‚ - Data Transform โ”‚    โ”‚ - Audiences     โ”‚
โ”‚   Access        โ”‚    โ”‚ - Pagination     โ”‚    โ”‚ - Creatives     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Core Components

  • Meta API Client: Handles authentication, rate limiting, and API communication
  • Tool Handlers: 40+ tools for comprehensive Meta API functionality
  • 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:

npm test

Test with example client:

npx tsx examples/client-example.ts

Health check:

# In Claude:
Check the health of the Meta Marketing API server

๐Ÿค Contributing

  • Fork the repository
  • Create a feature branch: git checkout -b feature/new-feature
  • Make your changes and add tests
  • Run the test suite: npm test
  • Submit a pull request

Development Setup

git clone https://github.com/your-org/meta-ads-mcp.git
cd meta-ads-mcp
npm install
npm run dev  # Start in development mode

๐Ÿ“„ License

MIT License - see LICENSE for details.

๐Ÿ†˜ Support

๐Ÿท๏ธ Version History

v1.0.6 (Latest)

  • โœ… Using Meta Graph API v23.0 (latest version)
  • โœ… Added support for Outcome-Driven Ad Experience (ODAE) objectives
  • โœ… Added campaign-level budget optimization support
  • โœ… Added bid strategy options (LOWEST_COST_WITHOUT_CAP, LOWEST_COST_WITH_BID_CAP, COST_CAP)
  • โœ… Removed deprecated insights metrics per Meta API v19.0 changes
  • โœ… Enhanced campaign creation with bid cap and budget optimization features

v1.0.5

  • โœ… Fixed ad set creation to use correct account endpoint
  • โœ… Improved error handling for campaign operations

v1.0.4

  • โœ… Enhanced campaign management features
  • โœ… Improved API error responses

v1.0.3

  • โœ… Added docker support
  • โœ… Improved deployment options

v1.0.2

  • โœ… Fixed entry point issue for npx compatibility
  • โœ… Added detailed startup debugging logs
  • โœ… Improved error handling and diagnostics

v1.0.1

  • โœ… Enhanced debugging capabilities
  • โœ… Better error reporting

v1.0.0

  • โœ… Complete Meta Marketing API integration
  • โœ… 40+ tools and resources
  • โœ… Advanced rate limiting
  • โœ… Comprehensive error handling
  • โœ… Multi-account support
  • โœ… Production-ready security

Built with โค๏ธ for the AI-powered advertising future

Keywords

mcp

FAQs

Package last updated on 24 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.