Facebook Ad Library MCP Server & CLI

A free, open source Facebook Ad Library MCP server and CLI that lets Claude Code, Codex, Cursor and other AI agents research the ads any brand runs on Facebook and Instagram.

Navid Moazzezby Navid Moazzez·Updated 30 de set. de 2026·9 min read
~/facebook-ad-library-mcp-cli
$ claude
Claude Code v2.1.220
>
Rate this tool

This free Facebook Ad Library MCP server and CLI gives your AI real access to Meta's Ad Library: every ad running on Facebook, Instagram, Messenger, Threads and Audience Network, for any advertiser in any country. It searches by keyword or advertiser, pulls every creative and copy variant of an ad, and remembers what a brand ran last time, so it can tell you what changed.

It's one install with 2 ways in. Claude, Codex, Cursor or any other MCP app calls its 9 tools for you, and the same tools work as a CLI that agents like Claude Code, Codex and OpenCode run, or that you type yourself.

Here's what the Facebook Ad Library MCP server and CLI is, how to set it up in each app, and every tool it has.

What is the Facebook Ad Library MCP server & CLI?

The Facebook Ad Library MCP server & CLI is a free, open source program that lets AI agents research the ads any brand is running on Facebook and Instagram for you, in 2 ways. The MCP server is what an AI app like Claude, Codex or Cursor connects to, through MCP (Model Context Protocol), the open standard AI apps use to call outside tools.

You ask in plain language. Your AI picks the right tool, and the server makes the call to Meta's public Ad Library, the way a browser reads it.

The CLI is the same program as commands. facebook-ad-library-cli search-ads --query "cold plunge" --country US runs the same code your AI runs when you ask what a market is advertising, whether an agent like Claude Code runs it or you do.

What can you ask it?

Once it's set up, you ask the way you'd ask an assistant. These are real prompts it handles:

Try asking
What ads is this brand running right now, and which has been live longest?
Show me every hook this competitor is testing this month, grouped by angle.
Compare 2 competitors: who runs more creative, and who refreshes it faster?
Find advertisers running cold plunge ads in the UK, ranked by ad count.
What changed for this advertiser since last week?
This ad has run for 8 months. Read the copy and tell me why it works.

The fifth one shows why this is useful. The Ad Library only shows what's running now, and the server keeps its own snapshot, so it can tell you what started and what stopped.

How to install the Facebook Ad Library MCP server

Pick your app in the box at the top of this page. Each one is a single command or a pasted block, with no account and no key.

Before you start0/2

Pro tip: The Ad Library is public, so there's nothing to sign in to. The free backend reads it the way your browser does, on your own computer.

Set up the Facebook Ad Library

There's no account and no key. The only setup is the browser the free backend drives.

Install Chromium once0/2

A search on the free backend takes 30 to 60 seconds, because it opens the Ad Library and scrolls it like a person would. Meta slows you down if you run a lot of searches in a row, so wait a few minutes when results come back empty.

Optional: EU spend and reach

Meta's official Ad Library API publishes spend, impressions and demographics for ads delivered in the EU and for political ads anywhere. It's free: create an app at developers.facebook.com, generate an access token and set it as META_ADS_ARCHIVE_TOKEN. get_eu_transparency then returns data, and everything else works without it.

Check that it works

Run the doctor. It launches the browser, runs a real search and tells you whether ads came back.

npx -y @thenavidm/facebook-ad-library-mcp-cli doctor

If Chromium won't launch, run npx playwright install chromium. If Meta served a captcha, wait a few minutes and try again.

Use the Facebook Ad Library CLI

The CLI is the same 9 tools as commands. AI agents that run commands, like Claude Code, Codex and OpenCode, use it on their own, and you can type the same commands in a terminal or a script.

Every tool name becomes a command with dashes, so search_ads runs as facebook-ad-library-cli search-ads.

npm install -g @thenavidm/facebook-ad-library-mcp-cli
facebook-ad-library-cli
facebook-ad-library-cli search-ads --query "cold plunge" --country GB --limit 10
facebook-ad-library-cli list-advertisers --query "Ridge"
facebook-ad-library-cli diff-advertiser --page-id 112577918783959

The bare facebook-ad-library-cli lists every command, and facebook-ad-library-cli <command> --help shows what a command takes. Nothing asks for a confirm check, because nothing here writes.

These flags work on every command:

FlagWhat it does
--jsonPrints JSON
--compactPrints the JSON on one line
--agentMachine mode: JSON, compact, no prompts and no color
--select a,b.cKeeps only those fields, and a dotted path goes deeper
--confirmLets a write that asks first go ahead

A script can branch on the exit code:

Exit codeWhat it means
0It worked
2The command was typed wrong
3There's no ad with that ID
4A provider rejected its key
5The Ad Library or a provider failed
7You hit a rate limit, or a provider ran out of credits
10A backend isn't set up, like a missing key or Chromium

MCP server or CLI: which one?

Both are the same program with the same 9 tools. The difference is when your AI pays for them, in the tokens it reads.

Every message, in an app that loads every tool
MCP server
4,200 tokens
CLI
Nothing
Every message, in Claude Code
MCP server
740 tokens
CLI
Nothing
When Facebook Ad Library comes up
MCP server
Nothing more, or in Claude Code the tools it picks
CLI
3,400 tokens, once
20 messages with Facebook Ad Library in 1, every tool loaded
MCP server
84,000 tokens
CLI
3,400 tokens
Works in Claude Desktop's chat
MCP server
Yes
CLI
No, there's no terminal there
Works in a script, a cron job or CI
MCP server
No
CLI
Yes

An app that loads every tool up front sends the full list with every message, whether you mention Facebook Ad Library or not. Claude Code doesn't by default: its tool search sends only the tool names and the server's instructions, and loads a tool's full definition when your AI reaches for it.

The CLI costs nothing until Facebook Ad Library comes up. Then your agent reads its skill file once and runs the commands it needs. With the skill added, Claude Code also lists its one-line description with every message, about 170 tokens.

When the whole conversation is about Facebook Ad Library, the gap closes. Then the MCP server is the better experience, because you ask in plain language and your AI never has to look up a command.

How to spend less

In Claude Code, leave tool search on, which it is unless you've set ENABLE_TOOL_SEARCH=false.

Turn the server off when you aren't researching ads, with your AI app's own switch.

Or install the CLI and connect the server later, on the days it earns its place. Every tool stays in reach, and the standing cost drops to nothing.

Every number here was measured on September 27, 2026 in Claude Code 2.1.257 with Claude Opus 5. It's the same one-line prompt with and without the server connected, once with tool search off so every tool loads, and once with Claude Code's default. The skill was measured the same way, and other apps and models count tokens a little differently.

What you get for every ad

The Ad Library is a web app, and Meta hands it every ad as structured data. The server reads that data rather than the page's text, so nothing is lost on the way.

FieldWhat you get
CreativesAll of them, with HD and SD video links
PlatformsFacebook, Instagram, Messenger, Threads and Audience Network
DestinationThe real landing page, query string included
Call to actionThe button, like Shop now, straight from the data
PaginationA real cursor, plus Meta's own count of matching ads

What the Ad Library can't tell you

No performance data exists. Conversions, revenue, cost per acquisition and return on ad spend aren't public for another advertiser, from any source.

What you can read is how long an ad has run. An ad live for 6 months is probably working, because advertisers turn off ads that lose money, but that's a guess worth testing, not a measurement.

Spend and reach are usually empty. Meta publishes them only for ads delivered in the EU and for political ads, so an empty value on a US store's ad is the right answer.

Creative links expire, because Meta's media links are short-lived. Download what you want to keep when you find it.

Every Facebook Ad Library tool

All 9 tools, grouped the way the repo groups them. Every one only reads: the server can't post, can't spend and can't reach an ad account.

Searching ads

search_ads
What it does
Search Meta's public Ad Library by keyword, or list every ad from one advertiser by passing page_id.
Kind
Reads
list_advertisers
What it does
Resolve a brand name to the advertiser Pages actually running ads for it, ranked by how many ads each is running.
Kind
Reads
get_ad
What it does
Fetch a single ad by its Ad Library ID, with every creative, all copy variants, the full destination URL and any transparency data.
Kind
Reads
transcribe_ad
What it does
Speech to text for a video ad, so its spoken script becomes readable.
Kind
Reads
ad_library_url
What it does
Turn a set of filters into the public Ad Library URL, so a person can open the same search in a browser and check the results independently.
Kind
Reads

Seeing an ad

view_ad_creative
What it does
Return the actual images from one ad so you can see them, rather than only reading its copy.
Kind
Reads

Tracking changes

diff_advertiser
What it does
Compare an advertiser's ads now against the last time this server looked, and report what they started and stopped running.
Kind
Reads

EU spend and reach

get_eu_transparency
What it does
Spend, impressions, reach and demographic breakdown from Meta's official Ad Library API.
Kind
Reads

Status

backend_status
What it does
Which backend is serving requests, whether it costs money per call, and which optional features are available in this configuration.
Kind
Reads

Is the Facebook Ad Library MCP server safe?

There's nothing to undo, because nothing here writes. Every tool reads Meta's public archive, so there's no read-only setting to turn on.

The one thing it stores is the snapshot diff_advertiser compares against, on your own computer.

⚠️

Watch out: Ad copy is written by advertisers, and some of it is written to persuade. The server hands it to your AI as data to study, so treat any instruction inside an ad as part of the ad.

Your data

There's no server of ours in between. The free backend reads the Ad Library from your own computer, the same page anyone can open without signing in.

diff_advertiser keeps its snapshots in your app data folder, or wherever FBADS_STORE_DIR points. If you set a provider backend, your searches go to that provider instead, and whatever your AI reads goes to its own model provider, like anything you paste into a chat.

Facebook Ad Library MCP server settings

Every setting is optional, as an environment variable in your app's config. The free backend needs none of them.

FBADS_BACKEND
Default
browser
What it does
browser drives Chromium on your computer. scrapecreators and apify use those providers, billed per ad
SCRAPECREATORS_API_KEY
Default
none
What it does
Holds the key for the scrapecreators backend, which also enables transcribe_ad
APIFY_TOKEN
Default
none
What it does
Holds the token for the apify backend
META_ADS_ARCHIVE_TOKEN
Default
none
What it does
Unlocks EU spend, reach and demographics, free from Meta
FBADS_HEADED
Default
off
What it does
1 shows the browser, to see why a search came back empty
FBADS_RETRIES
Default
1
What it does
Retries when the browser comes back empty
FBADS_STORE_DIR
Default
your app data folder
What it does
Sets where diff_advertiser keeps its snapshots
FBADS_HTTP_TOKEN
Default
none
What it does
Sets the bearer token for --http

Troubleshooting

Run the doctor first. It names the step that failed and the fix.

What you seeWhat to do
"Chromium will not launch"Run npx playwright install chromium
"Meta served a captcha"Wait a few minutes, then search again
Empty results on every searchMeta is slowing this computer down. Wait, and search less often
Spend and reach are emptyThat's expected outside the EU and political ads
transcribe_ad says it needs a backendTranscription runs only on the scrapecreators backend

If the server doesn't show up in your app at all, run the command your app runs, in a terminal, and read the error.

More free tools for studying what works

Download the ads and videos you want to keep, or pull a transcript to read a video's script.

Facebook Ad Library MCP Server FAQs

Here are the questions people ask most about the Facebook Ad Library MCP server and CLI.

The Facebook Ad Library MCP server & CLI is a free, open source program that lets an AI app like Claude, Codex or Cursor research the ads any brand is running on Facebook and Instagram.

It has 9 tools for searching ads, reading one in full, tracking what changed and EU spend, and the same tools run as a CLI that agents like Claude Code and Codex use, or that you type yourself.

An MCP server is a standard way to give an AI app real access to a tool, so it can act instead of guessing.

MCP stands for Model Context Protocol, and Claude, Codex, Cursor and many other AI apps speak it.

The Facebook Ad Library CLI is the same program as the Facebook Ad Library MCP server, run as commands.

AI agents like Claude Code, Codex and OpenCode run them for you, and you can type them in a terminal or a script.

Use the Facebook Ad Library MCP server in an AI app with no terminal, like Claude Desktop's chat, and the CLI in a terminal, a script or a cron job.

In an AI app that can run commands, like Claude Code, Codex or Cursor, the CLI is the lighter choice, because it costs nothing until it runs.

Yes, the Facebook Ad Library MCP server is free and open source under the MIT license, and its default backend needs no account and no key.

The Ad Library itself is free for anyone to read.

No, the Ad Library is public, and the server reads it without signing in to anything.

The free backend opens the Ad Library in a real browser and scrolls it, which takes 30 to 60 seconds a search.

A provider backend answers in seconds, billed per ad.

Only for ads delivered in the EU and for political ads, through get_eu_transparency.

For other advertisers, Meta doesn't publish spend anywhere.

No, and nothing can, because performance data isn't public.

You can see which ads have run longest, which is a reasonable signal but not the same thing.

The Facebook Ad Library MCP server works with any app that speaks MCP.

That includes Claude Code, Claude Desktop, Codex, Cursor, VS Code, GitHub Copilot CLI, Gemini CLI, OpenCode, OpenClaw, Antigravity and Hermes.

Navid Moazzez built the Facebook Ad Library MCP server and maintains it.

The code is on GitHub under the MIT license, and the package is on npm.

Navid Moazzez

AI business strategist & AI OS builder

Navid Moazzez helps creators and founders master AI and build their own AI Operating System (AI OS) to automate their business and life.

Navid.me is reader-supported. When you buy through links on this site, I may earn an affiliate commission. Learn more.

More MCP servers & CLIs

Free AI newsletter

The most actionable AI newsletter for founders

Every week, get proven AI strategies, curated tools, and step-by-step systems to grow your audience, create better content, and build a profitable creator business.

No fluff, no filler, no BS. Just five minutes each week that might level up your online business and life.

P.S. Sign up now to get free access to my ultimate AI tools guide for creators.

Loved by 10,000+ readers