How to get ad reports with OpenAI Codex

Connect each ad platform to Codex as an MCP server, ask for the report once, then schedule it with codex exec -o reports/latest.md. Meta's and Google's official servers read the campaigns you already run; Hypesonic reads the ones it launches.

By Grace Kong·Updated ·7 min read

Get a weekly ad report from your agent

TL;DR

  • By where the campaign runs: existing Meta campaigns through Meta's official Ads MCP (free, open beta since April 29, 2026); Google Ads through Google's self-hosted Ads MCP, which reads with GAQL; campaigns Hypesonic launched on Meta, TikTok, Pinterest, Reddit, LinkedIn, streaming TV or billboards through Hypesonic; anything else from a CSV export in the folder.

  • Each server is two commands, for example codex mcp add meta-ads --url https://mcp.facebook.com/ads and codex mcp login meta-ads; grant Meta only ads_read and the agent can report but not change anything.

  • GA4 joins the same report through Google's analytics-mcp server (run_report, read-only scope), so one file can set ad spend next to site conversions.

  • To post the report to Slack, send reports/latest.md to an incoming webhook from the cron line after codex exec finishes.

  • Since January 12, 2026, Meta's Insights API no longer returns 7-day or 28-day view attribution, so view-through conversions in those windows drop out of every API report.

Which data source covers which campaigns?

Codex reports on whatever its MCP servers can read, so connect one per platform you spend on.

CampaignsConnect in CodexWhat it readsCost and setup
Meta campaigns you already runMeta Ads MCP: codex mcp add meta-ads --url https://mcp.facebook.com/ads, then codex mcp login meta-adsSpend and results for the ad accounts you pick; with only ads_read it cannot change anythingFree; open beta since April 29, 2026, and Meta says not every ad account has access yet. Add --oauth-client-id with your Meta app ID if sign-in asks for one
Google AdsGoogle's Ads MCP, run locally with Python and a Google Cloud projectAny report you can write in GAQL (Google Ads Query Language)Free, open source; self-hosted
Google Analytics 4codex mcp add analytics -- pipx run analytics-mcp with Application Default CredentialsGA4 reports, funnels and conversions with the analytics.readonly scopeFree, open source
Campaigns Hypesonic launchedcodex mcp add Hypesonic --url https://www.hypesonic.com/mcpSpend and results on Meta, TikTok, Pinterest, Reddit, LinkedIn, streaming TV and billboards, plus breakdowns of any adFree to connect; paid breakdowns are priced first
Anything elseNo server: export a CSV from the ad platform into exports/Whatever the export holdsFree; you refresh the file

Sources: Meta, ads MCP server, googleads/google-ads-mcp, googleanalytics/google-analytics-mcp, Codex docs, MCP, read Dec 3, 2026.

Set up the servers in Codex

Add each server once and sign in; the CLI, IDE extension and ChatGPT desktop app share the config.

codex mcp add meta-ads --url https://mcp.facebook.com/ads
codex mcp login meta-ads
codex mcp add analytics -- pipx run analytics-mcp
codex mcp add Hypesonic --url https://www.hypesonic.com/mcp
codex mcp login Hypesonic

For scheduled runs, put the servers in the project's .codex/config.toml and mark the project trusted: Codex loads project-defined MCP servers for codex exec only in trusted projects, and exits with an error if a required MCP server fails to start (Codex docs, non-interactive mode). Run each codex mcp login once on that machine so the job has a valid sign-in; add --no-browser on a server without one (Codex docs, MCP). Codex waits 60 seconds per tool call by default, which is enough for reports. Setup for every agent: connect the Hypesonic MCP.

The exact request, interactive and scheduled

Ask once in the terminal; when the report is right, put the same words in a scheduled job.

Pull last week's spend and results for our Meta campaigns from meta-ads,
and sessions and purchases by source from analytics for the same dates.
Rank ads by cost per purchase.
Break down the top 3 and bottom 3 ads: what each shows and says in the first seconds.
Write ./reports/$(date +%F).md: what to scale, what to cut, 3 tests for next week.
State the attribution setting the results use.

Unattended, every Monday at 8 am, then posted to Slack:

0 8 * * 1  cd ~/marketing && codex exec "Write this week's ad report as in reports/TEMPLATE.md" -o reports/latest.md && jq -n --rawfile t reports/latest.md '{text:$t}' | curl -s -X POST -H 'Content-type: application/json' -d @- "$SLACK_WEBHOOK_URL"

codex exec prints progress to stderr and only the final message to stdout; -o writes that final message to a file, and --json switches stdout to JSON Lines. It runs in a read-only sandbox by default, which suits a job that only reads results (Codex docs). The Slack post happens in the cron line, outside Codex, through a Slack incoming webhook (Slack docs). For email, pipe the same file to your mail command.

What Codex does, step by step

Pull, rank, break down, then write.

  1. Pulls spend and results from each connected server: Meta Ads MCP for existing Meta campaigns, Google's servers for Google Ads and GA4, Hypesonic for the campaigns it launched, and any CSV in exports/.
  2. Ranks the ads by the number you name, such as cost per purchase.
  3. Breaks down the top and bottom ads with Hypesonic's Ad Analysis API, if Hypesonic is connected, which watches each one and describes what it shows and says.
  4. Writes the verdict: what to scale, what to cut, what to test.
  5. Saves the file and compares it with last week's report in the same folder.
  6. Reports what the run cost from spend_get. Any step that costs money gets a quote with estimate: true first, and your approval mode decides whether Codex asks.

What a finished report looks like

A dated markdown file your team can read in GitHub, Slack or an editor. The template you keep in reports/TEMPLATE.md fixes its shape:

# Ad report, week of [date]
Attribution: 7-day click, 1-day view

| Channel | Spend | Purchases | Cost per purchase | vs last week |
| Meta    | ...   | ...       | ...               | ...          |
| Google  | ...   | ...       | ...               | ...          |
| GA4 site purchases by source: ...

## Top 3 and bottom 3 ads
[ad name]: spend, cost per purchase, click-through rate, what the first seconds show

## What the winners share
## Scale / Cut / Test (each with ad names)

Each week's file sits next to the last, so trends show up without a dashboard.

Benchmarks to read the report against

A number only means something next to a baseline.

MetricBenchmarkSource
Facebook click-through rate (CTR), traffic campaigns1.93% (cost per click, or CPC, $0.60)LocaliQ
Facebook CTR, lead campaigns2.70% (CPC $1.80)LocaliQ
Facebook lead conversion rate8.54% of clicksLocaliQ
US Facebook CPM$21.47 (Oct 2026) to $25.32 (Nov 2026)Birch
TikTok median CPM$4.08Quimby, citing Triple Whale
TikTok median cost per purchase$17.07Quimby, citing Triple Whale

The CPM jump from October to November is about 18% (our math): Black Friday advertisers enter the auction, so a weekly report in late November should not read a higher CPM as an ad problem.

Data limits that change your numbers

Meta changed what its reporting API returns in 2026.

  • View attribution: from January 12, 2026 the Insights API stopped returning the 7-day view and 28-day view windows (Meta for Developers). Reports built on them will show fewer conversions.
  • History: total values stay available for up to 37 months, but unique-count fields and hourly breakdowns go back 13 months, and frequency breakdowns 6 months.
  • Practical rule: pick one attribution setting, write it in the report, and keep it the same every week.

Where Codex is strong and weak for reporting

Strong at repeatable files; not a live dashboard.

  • Strong: codex exec runs from scripts and scheduled jobs and writes the report to a file you choose.
  • Strong: reports live next to last week's, so "what changed?" is a file comparison.
  • Weak: unattended runs cannot answer an approval prompt; keep scheduled jobs to reporting, and launch changes interactively.
  • Weak: no charts unless you ask Codex to write a script that draws them.
  • Weak: Meta's server is in beta and not every ad account has access yet; keep a CSV export as the fallback.

Questions

Can Codex report on Meta campaigns I already run?

Yes. Connect Meta's official Ads MCP at mcp.facebook.com/ads with codex mcp add and sign in with Facebook; with only ads_read granted, Codex can read results but change nothing. Campaigns launched through Hypesonic report through Hypesonic.

Can Codex pull Google Ads and GA4 data into the same report?

Yes, with Google's open-source Ads MCP for Google Ads and its analytics-mcp server for GA4. Both run on your machine with Google Cloud credentials.

How do I schedule an ad report with Codex?

Use codex exec with your prompt from cron or a CI job, and -o to write the final message to a file. Project MCP servers load only in trusted projects.

Why do my Meta conversions look lower in API reports?

Since January 12, 2026 the Insights API no longer returns 7-day and 28-day view attribution, so view-through conversions in those windows drop out.

How far back can I report on Meta ads?

Total values go back up to 37 months. Unique-count fields and hourly breakdowns go back 13 months, and frequency breakdowns 6 months.

Sources

  1. 1OpenAI Codex docs, MCP · accessed Nov 30, 2026
  2. 2OpenAI Codex docs, non-interactive mode · accessed Nov 30, 2026
  3. 3Meta for Developers, Ads Insights API metric availability updates · Oct 16, 2025
  4. 4LocaliQ, Facebook advertising benchmarks · Sep 2026
  5. 5Birch, Facebook advertising costs (Oct $21.47, Nov $25.32 CPM) · Nov 2026 data, read Dec 3, 2026
  6. 6Quimby Digital, TikTok ad costs 2026 (Triple Whale data) · Nov 2026
  7. 7Meta, ads MCP server · read Dec 3, 2026
  8. 8GitHub, googleads/google-ads-mcp README · read Dec 3, 2026
  9. 9GitHub, googleanalytics/google-analytics-mcp README · read Dec 3, 2026
  10. 10Slack docs, sending messages using incoming webhooks · read Dec 3, 2026

Get a weekly ad report from your agent

Keep reading