Skip to main content

MCP server for Facebook/Meta Ads API integration enabling programmatic access to Meta Ads data

Project description

Facebook/Meta Ads MCP Server

smithery badge

This project provides an MCP server acting as an interface to the Meta Ads, enabling programmatic access to Meta Ads data and management features.

Your browser does not support the video tag.

Easy One-Click Setup

For a simpler setup experience, we offer ready-to-use installers:

👉 Download installer - https://gomarble.ai/mcp

Join our community for help and updates

👉 Slack Community - AI in Ads

Try Google ads mcp server also

👉 Google Ads MCP - Google Ads MCP

What It Does

  • Installs and configures the MCP server locally
  • Automatically handles environment setup
  • Prompts for Meta token authentication during the process which is optional
  • If Meta access token is not provided then connect to GoMarble's server to create the token on your behalf

Important Disclaimer

This setup does not require you to manually obtain a Meta Developer Access Token.

Instead, it connects securely to GoMarble's server to create the token on your behalf. GoMarble does not store your token — it is saved locally on your machine for use with the MCP server.


Setup

Prerequisites

  • Python 3.10+
  • Dependencies listed in requirements.txt
  1. (Optional but Recommended) Create and Activate a Virtual Environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    

    Using a virtual environment helps manage project dependencies cleanly[Source].

  2. Install Dependencies:

    pip install -r requirements.txt
    
  3. Obtain Meta Access Token: Secure a Meta User Access Token with the necessary permissions (e.g., ads_read). You can generate this through the Meta Developer portal. Follow this link.

Usage with MCP Clients (e.g., Cursor, Claude Desktop)

To integrate this server with an MCP-compatible client, add a configuration(Claude) similar to the following. Replace YOUR_META_ACCESS_TOKEN with your actual token and adjust the path to server.py if necessary.

{
  "mcpServers": {
    "fb-ads-mcp-server": {
      "command": "python",
      "args": [
        "/path/to/your/fb-ads-mcp-server/server.py",
        "--fb-token",
        "YOUR_META_ACCESS_TOKEN"
      ]
      // If using a virtual environment, you might need to specify the python executable within the venv:
      // "command": "/path/to/your/fb-ads-mcp-server/venv/bin/python",
      // "args": [
      //   "/path/to/your/fb-ads-mcp-server/server.py",
      //   "--fb-token",
      //   "YOUR_META_ACCESS_TOKEN"
      // ]
    }
  }
}

Restart the MCP Client app after making the update in the configuration.

(Note: On Windows, you might need to adjust the command structure or use cmd /k depending on your setup.)

Debugging the Server

Execute server.py, providing the access token via the --fb-token argument.

python server.py --fb-token YOUR_META_ACCESS_TOKEN

Available MCP Tools

This MCP server provides tools for interacting with META Ads objects and data:

Tool Name Description
Account & Object Read
list_ad_accounts Lists ad accounts linked to the token.
get_details_of_ad_account Retrieves details for a specific ad account.
get_campaign_by_id Retrieves details for a specific campaign.
get_adset_by_id Retrieves details for a specific ad set.
get_ad_by_id Retrieves details for a specific ad.
get_ad_creative_by_id Retrieves details for a specific ad creative.
get_adsets_by_ids Retrieves details for multiple ad sets by their IDs.
Fetching Collections
get_campaigns_by_adaccount Retrieves campaigns within an ad account.
get_adsets_by_adaccount Retrieves ad sets within an ad account.
get_ads_by_adaccount Retrieves ads within an ad account.
get_adsets_by_campaign Retrieves ad sets within a campaign.
get_ads_by_campaign Retrieves ads within a campaign.
get_ads_by_adset Retrieves ads within an ad set.
get_ad_creatives_by_ad_id Retrieves creatives associated with an ad.
Insights & Performance Data
get_adaccount_insights Retrieves performance insights for an ad account.
get_campaign_insights Retrieves performance insights for a campaign.
get_adset_insights Retrieves performance insights for an ad set.
get_ad_insights Retrieves performance insights for an ad.
fetch_pagination_url Fetches data from a pagination URL (e.g., from insights).
Activity/Change History
get_activities_by_adaccount Retrieves change history for an ad account.
get_activities_by_adset Retrieves change history for an ad set.

(Note: Most tools support additional parameters like fields, filtering, limit, pagination, date ranges, etc. Refer to the detailed docstrings within server.py for the full list and description of arguments for each tool.)

(Note: If your Meta access token expires, you'll need to generate a new one and update the configuration file of the MCP Client with new token to continue using the tools.)

Dependencies

License

This project is licensed under the MIT License.


Installing via Smithery

To install Facebook Ads Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @gomarble-ai/facebook-ads-mcp-server --client claude

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fb_mcp_bratrax-1.0.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fb_mcp_bratrax-1.0.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file fb_mcp_bratrax-1.0.0.tar.gz.

File metadata

  • Download URL: fb_mcp_bratrax-1.0.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for fb_mcp_bratrax-1.0.0.tar.gz
Algorithm Hash digest
SHA256 123e7af46b5e2195e0bd4e56222aa5caf463eb1aec12a73bd7832b48c0ebd099
MD5 7a53af5669a69e93b8f013304f3bb90d
BLAKE2b-256 4cafe8eefdaad04703bdb84ab02a7371d71af39c421800f98634b8929e05c539

See more details on using hashes here.

File details

Details for the file fb_mcp_bratrax-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fb_mcp_bratrax-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for fb_mcp_bratrax-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2ac40813893a39f001593459f6579f5cf47630cc5aeb2af007c87c23abfc700
MD5 1b0a18d1fb61e4c258c43cf68cab8ea5
BLAKE2b-256 8ccc26171aa71e9bcd52a748d66cdcbc978e1ff28e6f8fb300d3a3288e94bc70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page