Facebook Ad Library MCP Server

Facebook Ad Library MCP Server

fbadlibrarymcpserver•bystincodes

A Model Context Protocol server that provides access to Facebook's Ad Library through web scraping and exposes a single MCP tool for searching advertisements with filtering options.

License: ISC•Runtime: Awaiting documentation review•Category: search web

WHAT IT DOES

  • •Exposes a single MCP tool called search_ads for searching Facebook ads with optional filters.
  • •Supports filtering by company, start and end dates, and keywords, with limits up to 100 ads per search.
  • •Extracts ad data including advertiser, content, dates, impressions, spend, and platforms.
  • •Returns results sorted by date ascending, descending, or relevance.

BEST FOR

  • •Researching and analyzing a company's advertising activity over a specified date range.
  • •Searching ad content by keywords such as product or campaign terms.

ABOUT FBADLIBRARYMCPSERVER

Facebook Ad Library MCP Server is cataloged as an MCP server attributed to stincodes. A Model Context Protocol server that provides access to Facebook's Ad Library through web scraping and exposes a single MCP tool for searching advertisements with filtering options. It is categorized under search web. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: ISC. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Facebook Ad Library MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How many ads can a single search return?

The limit parameter defaults to 50 and has a maximum of 100 ads per search.

Does the server require authentication to connect?

No authentication is required.

How does the server avoid Facebook's anti-bot detection?

It runs in non-headless mode and uses techniques such as a virtual display, natural navigation mimicking human browsing, and simplified browser configuration.

上游原版 README

在 GitHub 查看同一版本原文

README.md · c42fe689cf89 · 采集于 2026-11-13 10:53:40 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Facebook Ad Library MCP Server

A Model Context Protocol (MCP) server that provides access to Facebook's Ad Library through web scraping. This server exposes a single MCP tool for searching advertisements with comprehensive filtering options.

Features

  • MCP-compliant: Built using the official MCP SDK
  • Comprehensive ad data: Extracts advertiser, content, dates, impressions, spend, and more
  • Advanced filtering: Filter by company, date range, and keywords
  • Smart pagination: Auto-scrolling to retrieve up to 100 ads per search
  • Flexible sorting: Sort by date (ascending/descending) or relevance

Installation

  1. Clone the repository:
git clone <repository-url>
cd FbAdLibraryMCPServer
  1. Install dependencies:
npm install
  1. Install Playwright browsers:
npx playwright install

Usage

Development

npm run dev

Production

npm run build
npm start

The server will start on port 3000 (configurable via PORT environment variable).

API Documentation

MCP Tool: search_ads

Search for Facebook ads with optional filters.

Parameters:

  • company (string, optional): Company/advertiser name to filter by
  • start_date (string, optional): Start date in YYYY-MM-DD format
  • end_date (string, optional): End date in YYYY-MM-DD format
  • keywords (array of strings, optional): Keywords to search in ad content
  • limit (integer, optional): Maximum ads to return (default: 50, max: 100)
  • order (string, optional): Sort order - "date_desc", "date_asc", or "relevance" (default: "date_desc")

Example Tool Call:

{
  "tool": "search_ads",
  "arguments": {
    "company": "Nike",
    "start_date": "2024-01-01",
    "end_date": "2024-01-31",
    "keywords": ["running", "shoes"],
    "limit": 10,
    "order": "date_desc"
  }
}

Response Format:

{
  "ads": [
    {
      "id": "unique_ad_identifier",
      "advertiser": "Company Name",
      "content": "Ad text content",
      "start_date": "Jan 15, 2024",
      "end_date": "Feb 15, 2024",
      "impressions": "1,000-5,000",
      "spend": "$100-$500",
      "platforms": ["Facebook"],
      "creative_url": "https://...",
      "demographics": {"targeting": "..."},
      "scraped_at": "2024-01-20T10:30:00Z"
    }
  ]
}

MCP Client Connection

Connect to the server using any MCP-compatible client:

HTTP Transport:

  • URL: http://localhost:3000/mcp
  • Method: POST
  • Headers: Content-Type: application/json

Health Check:

  • URL: http://localhost:3000/healthz
  • Method: GET

Architecture

  • MCP Server (src/index.ts): Express HTTP server hosting MCP protocol
  • Search Handler (src/mcp/searchAdsHandler.ts): Core business logic
  • Web Scraper (src/scraper/scrapeFacebookAds.ts): Playwright-based Facebook scraper
  • Filters (src/utils/filters.ts): Date parsing and filtering utilities

Performance Considerations

  • Rate Limiting: Built-in delays between requests to avoid blocking
  • Pagination: Auto-scrolling with intelligent stopping conditions
  • Browser Management: Proper cleanup of Playwright browser instances
  • Memory Efficiency: Streaming data processing where possible

Anti-Bot Detection Countermeasures

This server successfully bypasses Facebook's anti-bot detection through:

  • Virtual Display (Xvfb): Runs non-headless browsers in cloud environments
  • Natural Navigation: Mimics human browsing patterns (homepage → Ad Library)
  • Simplified Browser Config: Avoids complex "stealth" techniques that trigger detection
  • Smart Timeout Handling: 30-second browser launch timeout with fallback mechanisms
  • Production-Optimized: Different behavior in production vs development environments

Known Limitations

  • Runs in non-headless mode to avoid detection
  • Limited to 100 ads per search to prevent timeouts
  • Date formats depend on Facebook's display format
  • Subject to Facebook's anti-bot measures
  • Respects Facebook's rate limiting through built-in delays
  • Does not store personal user data
  • Intended for research and analysis purposes
  • Users should comply with Facebook's Terms of Service

Dependencies

  • @modelcontextprotocol/sdk: MCP protocol implementation
  • playwright: Web scraping automation
  • date-fns: Date parsing and manipulation
  • express: HTTP server framework
  • zod: Runtime type validation

Deployment (Fly.io)

  1. Install flyctl:
curl -L https://fly.io/install.sh | sh
export FLYCTL_INSTALL="/root/.fly"
export PATH="$FLYCTL_INSTALL/bin:$PATH"
  1. Deploy to Fly.io:
flyctl auth signup
flyctl launch --no-deploy
flyctl secrets set NODE_ENV=production
flyctl deploy
  1. Live Deployment:
    • App URL: https://fbadlibrarymcpserver.fly.dev
    • Health check: https://fbadlibrarymcpserver.fly.dev/healthz
    • MCP endpoint: https://fbadlibrarymcpserver.fly.dev/mcp (POST only)
    • Test endpoint: https://fbadlibrarymcpserver.fly.dev/test-search (GET/POST)

Connection Details

Public URL: https://fbadlibrarymcpserver.fly.dev

Quick Test: https://fbadlibrarymcpserver.fly.dev/test-search?company=Nike&limit=3

MCP Client Configuration:

{
  "transport": "http",
  "url": "https://fbadlibrarymcpserver.fly.dev/mcp",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json, text/event-stream"
  }
}

Authentication: None required

License

ISC

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Facebook Ad Library MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/fbadlibrarymcpserver)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related search web MCP Servers

Alternative and complementary servers in the same category

View all in search web →

An MCP server that merges Google Search Console history with a live first-party crawl of your site to produce a prioritised, evidence-backed technical SEO audit inside Claude, complete with paste-ready fixes.

Repository stats unavailable
Search & Web Research

An MCP server that offers intelligent web search using OpenAI reasoning models, with support for fast iterations and deep research.

94
Search & Web Research