How to run Meta ads from OpenAI Codex
Add an ad-running MCP (Model Context Protocol) server to Codex, point it at a product CSV, and it makes a folder of ads for each product and drafts one Meta campaign with an ad set per category, launching on your second yes.
By Grace Kong·Updated ·5 min read
Launch Meta ads for your whole catalog
TL;DR
Codex comes with every ChatGPT plan from Free to Enterprise, so Plus users, who cannot add a custom server in ChatGPT web, can launch from here (OpenAI).
Set default_tools_approval_mode = "writes" for the server and Codex asks before any tool that is not read-only, including every paid run.
Facebook lead campaigns averaged $27.39 per lead, from $12.30 for career services to $61.56 for dentists (lead benchmarks, Sep 2026).
Meta's average price per ad rose 9% in 2025 while impressions grew 12% (Meta results).
Set up Hypesonic in Codex
Add https://www.hypesonic.com/mcp as a remote MCP server named Hypesonic: two commands, or one table in config.toml.
codex mcp add hypesonic --url https://www.hypesonic.com/mcp codex mcp login hypesonic
Or add it to ~/.codex/config.toml:
[mcp_servers.hypesonic] url = "https://www.hypesonic.com/mcp" default_tools_approval_mode = "writes"
writesmakes Codex ask before any tool not marked read-only;promptasks before every call. A per-tool override goes intools.<tool>.approval_mode.- No browser on the machine?
codex mcp login hypesonic --no-browserprints a URL to open elsewhere. - The ChatGPT desktop app, Codex CLI and IDE extension share this config. ChatGPT on the web does not read it.
- A project can carry its own
.codex/config.toml, read only in trusted projects.
Source: OpenAI Codex docs, MCP.
Codex comes with ChatGPT Free, Go, Plus, Pro, Business, Edu and Enterprise (OpenAI), and it adds MCP servers from a file on your machine rather than a workspace plugin. You sign in to your Meta ad account through Hypesonic, with no developer app of your own. Setup for every agent: connect the Hypesonic MCP.
The exact request to type
Point Codex at the file, the output folder and the campaign shape.
Read ./catalog/top-20.csv (columns: sku, name, url, category, price). For each row, use Hypesonic to make 2 Meta ads from the url: one 4:5, one 9:16. Save to ./ads/meta/<sku>/ with primary text and headline in copy.txt. Draft one sales campaign, one ad set per category, $40 a day each. Quote everything and wait for my yes before generating and again before launch.
What Codex does, step by step
It treats the catalog as a work queue and checks in at the two money moments.
- Reads the CSV and the playbook with
playbook_get, and each endpoint's inputs withmodel_get. - Quotes one product, multiplies for the batch, and stops for your approval. A static ad costs about $0.20 to $0.75 to make with the
meta-static-adsplaybook. - Generates in groups: one
runcall takes up to 12 requests, each with its ownidempotency_key, so a re-run after an error never pays twice. - Collects results with
run_wait. Each wait returns within 45 seconds, inside Codex's 60-second default tool timeout, so you do not need to raisetool_timeout_secfor this job. - Saves files to the folders you named and writes the copy next to each ad.
- Drafts the campaign in your Meta ad account, shows ad sets and budgets, and launches on your second yes.
What you get back
A folder per product and a campaign you can trace back to it.
./ads/meta/<sku>/with the 4:5 and 9:16 images andcopy.txt.- A run log with run IDs and costs from
spend_get. - The campaign plan, then campaign, ad set and ad IDs. The agent pulls spend and results for the campaigns it runs.
- Because it is all files, the next request can be "make 2 more ads for the 5 products with the highest click-through rate" and Codex knows where everything is.
What a lead costs on Meta, by industry
Set each ad set's budget from the cost per result you expect, not a round number.
| Industry | Cost per click | Cost per lead | Weekly spend for 50 leads (our math) |
|---|---|---|---|
| Dentists | $5.70 | $61.56 | $3,078 |
| Beauty and personal care | $2.97 | $50.91 | $2,546 |
| Automotive, for sale | $2.01 | $35.52 | $1,776 |
| Education | $1.72 | $26.31 | $1,316 |
| Arts and entertainment | $0.88 | $14.59 | $730 |
| Real estate | $1.27 | $13.74 | $687 |
| Career and employment | $0.73 | $12.30 | $615 |
Source: LocaliQ Facebook ads benchmarks, lead campaigns, updated Sep 2026. Meta says an ad set leaves the learning phase after about 50 results in a week (Meta).
That is why a catalog batch should share budget: four ad sets at $40 a day spend $1,120 a week in total, enough for 50 leads only in the cheapest categories (our math). Prices are rising too: Meta's average price per ad grew 9% in 2025 while impressions grew 12% (Meta full-year 2025 results). Meta allows up to 75% over a daily budget on a given day, but no more than 7 times the daily budget in a week (Meta).
Where Codex is strong and weak for Meta ads
Built for batches and files; not built for a quick idea on your phone.
- Strong: bulk jobs from a CSV or a folder, with every output saved where you said.
- Strong: it has a shell, so Hypesonic's static and video playbooks run to the end, including browser typesetting and ffmpeg edits.
- Strong: available on every ChatGPT plan, including Plus.
- Weak: a terminal or IDE workflow; teammates who live in ChatGPT web will not see the thread unless you share the files.
- Weak: loose approval settings are risky; keep
writesorpromptfor a server that spends money.
Questions
Can Codex run Facebook ads?
With an MCP server that launches Meta campaigns, such as Hypesonic, yes. Codex asks before tool calls according to the approval mode you set for that server.
Do I need ChatGPT Business to use Hypesonic in Codex?
No. Codex is included in every ChatGPT plan from Free to Enterprise, and you add MCP servers in its own config file.
How do I add an MCP server to Codex?
Run codex mcp add with a name and --url, then codex mcp login. Or add an [mcp_servers.name] table with a url to ~/.codex/config.toml.
How much should each Meta ad set get per week?
Enough for about 50 results, since that is when Meta says learning ends. At the $27.39 average cost per lead that is about $1,370 a week (our math).
Sources
- 1OpenAI Codex docs, MCP · accessed Nov 30, 2026
- 2OpenAI Codex docs, pricing and plans · accessed Nov 30, 2026
- 3LocaliQ, Facebook advertising benchmarks · Sep 2026
- 4Meta Business Help, about the learning phase · accessed Nov 30, 2026
- 5Meta, full-year 2025 results (SEC exhibit 99.1) · Jan 2026
- 6Meta, ad pricing · accessed Nov 30, 2026
Launch Meta ads for your whole catalog
Keep reading
- IntegrationsCodex for marketing: running ad work from OpenAI CodexRead
- CostsHow much do Facebook ads cost in 2026?Read
- GuidesCan ChatGPT run Facebook ads? How to run Meta ads from ChatGPTRead
- GuidesHow to get ad reports with OpenAI CodexRead
- IntegrationsMeta Ads MCP: what Meta's official server can and can't doRead
- AI adsWhat an AI ad generator does, and how to pick oneRead