The short answer
An AI agent for Facebook ads is only as good as what it reads. A model left alone writes the average of the internet; one grounded in ads that already crossed $50k in estimated spend writes from structures the market has paid for. The build is small: Claude (Agent SDK or the Messages API MCP connector), the Ad Radar MCP server with six read-only tools, a system prompt that forces citations, and a brief template. Code for both routes is below.
In this article11 sections
Two kinds of AI agent for Facebook ads
"AI agent for Facebook ads" covers two different products, and mixing them up is the most common reason a build disappoints.
| Buying agent | Creative-strategy agent | |
|---|---|---|
| Question it answers | "What should I do with my budget?" | "What should we make next?" |
| Data it needs | Your ad account: spend, CPA, ROAS, delivery | What is already winning in your market: scripts, hooks, angles, formats |
| Typical connection | An account MCP server, such as Meta's Ads AI Connectors | An ad research MCP server or data API |
| Output | Budget moves, pauses, reports | Concepts, briefs, scripts, test plans |
The buying side has an official path now: Meta opened its Ads AI Connectors, a hosted MCP server, in open beta in April 2026 (our Meta ads MCP comparison covers it). It reads your reporting and edits campaigns well, but your account can only tell the agent what your ads did. It cannot tell it what to try next.
That is the expensive question. In an Andromeda-era account, creative is the lever with the biggest effect, and the bottleneck is the supply of genuinely new concepts. This guide builds the creative-strategy agent: Claude, grounded in a corpus of Meta ads that already proved themselves, producing concepts that cite their evidence.
Why grounding beats a clever prompt
Ask a model with no data for "five Facebook ad concepts for a magnesium sleep supplement" and you will get five competent, familiar ideas: a problem-agitate-solve script, a testimonial, a founder story, a before/after, a listicle. They are familiar because they are the average of everything the model has read. That is the problem. The average is what everyone in your niche is already running.
Our own data shows the cost of that drift. In our analysis of AI creative strategy, on a board of 2,443 winning Meta ads, the most common narrative angle (root cause, 34% of ads) had the lowest top-tier rate of the major angles, 8.0%. Common and winning are not the same thing, and a model left alone optimizes for common.
Grounding fixes three things at once:
- The examples are survivors. If every ad the agent reads has passed $50k in estimated spend, every structure it borrows has had real money behind it.
- Patterns are measured, not assumed. The agent can check whether a hook pattern reaches the top tier more often than the baseline before it recommends it.
- Everything is checkable. Each concept cites the ads it came from, with brand, opening line, estimated spend and days running, so a human can open them in one click.
A raw Ad Library scrape does not give you this. It returns every ad, tests and failures included, with no spend for commercial ads and no transcripts. An agent reading it is grounded in noise. You need a source where the filtering is already done.
The data layer: Ad Radar over MCP or REST
The Ad Radar Facebook ads API is built for exactly this layer. It serves Meta ads (Facebook and Instagram) with $50k+ estimated spend, built from the public Meta Ad Library and refreshed daily. Each ad carries headline, body, CTA, the full video transcript, estimated spend, score, tier (winner or rising), days running, variants, public media URLs and tags on ten dimensions: hook pattern, hook mechanism, narrative angle, reader awareness, proof level, production format, video type, landing page type, niche and CTA type.
2,761
Meta ads with $50k+ estimated spend
782
brands
10
tag dimensions per ad
6
MCP tools, read-only
The same key works over REST and over the MCP server at https://app.ad-radar.dev/api/mcp. For an agent, MCP is the natural fit, because the tools are already shaped for a model:
| MCP tool | REST twin | What the agent uses it for |
|---|---|---|
list_taxonomy | GET /taxonomy | Learn the valid tag values before filtering |
search_ads | GET /ads/search | Find winners by niche, tags, days live, text in copy or transcript |
get_ad | GET /ads/{key} | Read one ad in full before quoting it |
winning_patterns | GET /patterns | Check which tag values beat the baseline, with lift and sample size |
advertiser_hooks | GET /brands/{id}/hooks | Read a competitor's hook, mechanism and angle mix |
get_swipe_prompt | n/a | Get a brief that maps a winner's structure onto your product |
One MCP tool call is one request, the same as one REST call.
The agent's job, step by step
Before code, write the procedure down. A creative-strategy run that produces usable output follows the same six steps a good strategist does:
- Vocabulary. Call
list_taxonomyonce so every later filter uses exact values. - Market scan.
search_adsin the niche, winners first, then rising ads (the next winners), sorted by score. - Deep reads.
get_adon the five to eight closest matches to the product; split each script into hook, problem, mechanism, proof, offer, CTA. - Pattern check.
winning_patternsfor the format you plan to make, to see which hooks, angles and proof levels beat the baseline and which sit below it. - Competitor read.
advertiser_hookson the two or three brands you compete with, to find what they repeat (and what nobody in the niche uses). - Concepts. Three to five concepts, each built on a cited winner's structure, adapted to the product, with a hook line, a 30-second script and a test hypothesis.
get_swipe_promptgives a ready brief for the strongest one.
The system prompt encodes these steps and, more importantly, the rules: cite every claim, label spend as estimated, never invent an ad.
Route 1: Claude Agent SDK
The Claude Agent SDK is Claude Code packaged as a library: the agent loop, context management and tool permissions are handled for you. Remote MCP servers go in mcpServers with type: "http" and an Authorization header, and MCP tools are allowed by name in the form mcp__<server>__<tool>, with a wildcard for a whole server.
// strategist.ts npm i @anthropic-ai/claude-agent-sdk
// run: AD_RADAR_KEY=... npx tsx strategist.ts
import { query } from "@anthropic-ai/claude-agent-sdk";
const SYSTEM = `You are a creative strategist for Meta ads. You work only from
the Ad Radar tools. Procedure:
1. list_taxonomy once. Use exact tag values in every filter.
2. search_ads in the product's niche: winners first, then rising, by score.
3. get_ad on the 5-8 closest matches. Split each script into hook, problem,
mechanism, proof, offer, CTA.
4. winning_patterns for the planned format. Note lift and sample size.
5. advertiser_hooks for each named competitor.
6. Write 4 concepts. Each concept must cite the adKey, brand, opening line,
estimated spend and days running of the winner it is built on.
Rules: label every spend figure "estimated". Never invent an ad, a number or a
quote: if a tool did not return it, do not write it. Prefer patterns with lift
above 1.3 and at least 20 ads behind them. Flag any concept that copies an
angle all three competitors already use.`;
const BRIEF = `Product: magnesium glycinate sleep gummies, $39, subscription.
Customer: women 35-55 who wake at 3am. Competitors: [brand A], [brand B].
Format: 30-second UGC video. Output: markdown, one section per concept.`;
for await (const message of query({
prompt: BRIEF,
options: {
systemPrompt: SYSTEM,
mcpServers: {
"ad-radar": {
type: "http",
url: "https://app.ad-radar.dev/api/mcp",
headers: { Authorization: `Bearer ${process.env.AD_RADAR_KEY}` },
},
},
allowedTools: ["mcp__ad-radar__*"],
},
})) {
if (message.type === "assistant") {
for (const block of message.message.content) {
if (block.type === "tool_use") console.error("→", block.name);
}
}
if (message.type === "result" && message.subtype === "success") {
console.log(message.result);
}
}
The console.error line prints each tool call as it happens, so you can see the agent follow the procedure: mcp__ad-radar__list_taxonomy, then search_ads, a run of get_ad calls, winning_patterns, advertiser_hooks. If it skips the pattern check or the deep reads, tighten the system prompt rather than the brief.
The Agent SDK also ships built-in tools (file read and write, bash, web search). For this agent you only need the Ad Radar tools, and allowedTools grants exactly those. Run it from cron or a CI job each week with a fresh brief per product line.
Route 2: the Messages API MCP connector
If you would rather not run the Agent SDK, the Messages API can connect to a remote MCP server itself. The connector needs two parts together: an mcp_servers entry with the URL and your key as authorization_token, and an mcp_toolset entry in tools that references the server by name, under the beta flag mcp-client-2025-11-20. Anthropic makes the MCP calls server side and runs the loop within the request.
# strategist.py pip install anthropic
# run: ANTHROPIC_API_KEY=... AD_RADAR_KEY=... python strategist.py
import os
import anthropic
SYSTEM = open("strategist_system.txt").read() # the same rules as above
BRIEF = """Product: magnesium glycinate sleep gummies, $39, subscription.
Customer: women 35-55 who wake at 3am. Competitors: [brand A], [brand B].
Format: 30-second UGC video. Output: markdown, one section per concept."""
client = anthropic.Anthropic()
with client.beta.messages.stream(
model="claude-opus-5-5",
max_tokens=32000,
betas=["mcp-client-2025-11-20"],
system=SYSTEM,
mcp_servers=[{
"type": "url",
"url": "https://app.ad-radar.dev/api/mcp",
"name": "ad-radar",
"authorization_token": os.environ["AD_RADAR_KEY"],
}],
tools=[{"type": "mcp_toolset", "mcp_server_name": "ad-radar"}],
messages=[{"role": "user", "content": BRIEF}],
) as stream:
message = stream.get_final_message()
for block in message.content:
if block.type == "mcp_tool_use":
print("→", block.name)
elif block.type == "text":
print(block.text)
Streaming keeps a long run from hitting request timeouts. The response interleaves mcp_tool_use and mcp_tool_result blocks with the final text, so the same log of tool calls is available for review. Check Anthropic's MCP connector docs for the current beta flag before you ship, since connector betas are versioned.
Route 3: REST, when you want to control the reads
Some teams prefer a deterministic pipeline: code fetches the evidence, the model only writes. Pull the winners yourself, then hand them to the model in one prompt:
// evidence.mjs: the 20 strongest winning video ads that talk about sleep
const BASE = "https://app.ad-radar.dev/api/v1";
const headers = { Authorization: `Bearer ${process.env.AD_RADAR_KEY}` };
const ads = await fetch(`${BASE}/ads/search?q=sleep&tier=winner&format=video&sort=score&limit=20`, { headers })
.then((r) => r.json());
const patterns = await fetch(`${BASE}/patterns?format=video`, { headers }).then((r) => r.json());
const evidence = ads.data.map((a) => ({
adKey: a.adKey,
brand: a.brand,
estSpend: a.spendEstimate,
days: a.metrics.daysRunning,
variants: a.metrics.variants,
tags: a.tags.map((t) => `${t.dimension}:${t.label}`),
script: a.transcript,
}));
console.log(JSON.stringify({ evidence, doThis: patterns.doThis.slice(0, 15) }, null, 2));
That is two requests per run, and the output drops straight into a prompt. q matches the headline, body, brand and full transcript; to scope by brand category instead, take a slug from GET /taxonomy and pass category. It trades the agent's ability to dig deeper for predictability. Many teams use both: the pipeline for the weekly batch, the agent for open questions.
Prompts that make the agent useful
The system prompt does most of the work. Four rules matter more than any others:
- Cite or cut. "Every concept must cite the adKey, brand, opening line, estimated spend and days running of the winner it is built on." Without this, the model blends sources and you cannot check anything.
- Read before quoting. "Call get_ad before you quote a hook." Search results carry the opening line; the full script is in the ad record.
- Respect sample size. "Prefer patterns with lift above 1.3 and at least 20 ads behind them."
winning_patternsreturns both, so the agent can tell a real edge from a fluke. - Look for the gap. "Flag any concept that copies an angle all your named competitors already use." This is the step that pushes the agent off the average.
Then ask for an output a team can act on. A concept template that works:
## Concept 2: "The 3am clock"
Built on: [adKey] · [brand] · opener "[verbatim]" · est. $[x] · [n] days · [v] variants
Why it wins: hook pattern [x] (lift [y], [n] ads), awareness [x], proof [x]
Our version:
Hook (0-3s): ...
Problem (3-10s): ...
Mechanism (10-18s): ...
Proof (18-25s): ...
CTA (25-30s): ...
Test: vs our current control; success = hook rate above [x]% and CPA within [y]% by day 7
Risk: [competitor] runs a similar angle; differentiate on [x]
Our AI creative brief guide goes deeper on brief structure, and the Claude research walkthrough shows a full interactive session with the same tools.
What a run costs
Model tokens. A typical run reads 15 to 30 ads in full plus pattern tables, which lands around 60,000 to 120,000 input tokens, and writes 3,000 to 6,000 tokens of concepts. Anthropic's pricing page lists Claude Opus 5.5 at $4 per million input tokens and $20 per million output, and Claude Sonnet 5.5 at $2 and $10 (checked November 2026). At 100,000 input and 5,000 output tokens that is about $0.50 a run on Opus 5.5 and $0.25 on Sonnet 5.5.
Data. Each MCP tool call or REST call is one request. A full run is usually 10 to 20 requests. Weekly runs for five product lines use about 400 requests per 4-week period.
| Plan | Price, every 4 weeks | Requests | Fits |
|---|---|---|---|
| Builder | $299 | 10,000 | An in-house agent, weekly runs for many product lines, use inside your own product; includes the web app |
| Scale | $799 | 50,000 | Agents for many clients, /feed to keep a local mirror, higher rate limit |
| Reseller | From $2,000 | Custom | Full export, resale, white-label |
Over quota you get a 429 with an upgrade link, never an overage charge. Compare that with building the evidence layer yourself: scrapers, daily snapshots, video downloads, transcription, a tag taxonomy, a performance model, and months of history you cannot backfill. The ad spy tool architecture guide lays out what that involves. For an agent, the data is the moat, and it is the part not worth rebuilding.
Checks before you trust the output
An agent grounded in winners is far better than one guessing, but a human still owns the decision. Three quick checks per run:
- Open two cited ads. The
links.radarandlinks.libraryfields go straight to them. If the opener in the concept does not match the ad, the agent blended sources; tighten "cite or cut". - Read the lift and sample size behind each recommended pattern. A lift of 2.4 on 58 ads from 31 advertisers is a signal; a lift of 3.0 on six ads is a hunch.
- Ask what the customer would say. Angles come from customer research. The agent finds the structures that win; your reviews, calls and support tickets supply the words.
Start building
The best AI agent for Facebook ads creative is a small one: Claude, six tools, a strict system prompt and a brief template, reading only ads that already crossed $50k in estimated spend. Start on Builder, paste one of the two scripts above, and your first run returns four concepts with the winning ads behind each one cited. The full endpoint and tool reference is in the API docs, and setup for Claude Desktop, claude.ai and ChatGPT is on the MCP page.
Figures marked as estimated spend come from Ad Radar's model of engagement on public Meta Ad Library ads. They are estimates, labeled as such, and are best used to rank ads against each other. How the board is built.