All guides
Get started

Connect Facebook Ads to OpenAI Codex with AdChat

Add AdChat to the Codex CLI, IDE extension or ChatGPT desktop app with one URL and a browser sign-in. Ask about your Meta ads from the terminal.

Updated October 24, 2026

OpenAI Codex can connect to remote MCP servers, so you can ask it about your Facebook and Instagram ads, export numbers, or build reports while you work. This guide shows how to add AdChat to the Codex CLI. The same setup also works in the Codex IDE extension and the ChatGPT desktop app, because all three share one config file.

What you need

  • Codex installed (CLI, IDE extension or ChatGPT desktop app).
  • An AdChat account. Sign up. You can connect Facebook now or when you sign in from Codex.

How Codex connects

Codex supports remote "Streamable HTTP" MCP servers, which is what AdChat is. You add AdChat's URL, then sign in once in your browser. There's no key to copy.

Step 1: Add AdChat

Run:

bash
codex mcp add adchat --url https://mcp.adchat.app

Or open ~/.codex/config.toml (create it if it doesn't exist) and add:

toml
[mcp_servers.adchat]
url = "https://mcp.adchat.app"

If you only want AdChat in one project, put the same block in .codex/config.toml inside that project instead. Codex only reads project config for projects you've marked as trusted.

Step 2: Sign in

Run:

bash
codex mcp login adchat

A browser window opens. Sign in to AdChat, connect Facebook if you haven't yet, and click Allow. You only do this once. Codex stays connected as long as you use AdChat at least once every 90 days.

Step 3: Optional safety setting

Codex lets you decide when it should ask before using a server's tools. This setting makes it ask before any tool that isn't marked read-only:

toml
[mcp_servers.adchat]
url = "https://mcp.adchat.app"
default_tools_approval_mode = "writes"

Combined with AdChat's read-only default, that gives you two layers of protection.

Step 4: Check the connection

Run:

bash
codex mcp list

AdChat should appear in the list. Inside the Codex terminal app, type /mcp to see your active servers.

Step 5: Ask a question

Start codex and try:

Use AdChat to show my active Facebook campaigns with spend, results and cost per result for the last 7 days.

Or:

With AdChat, pull daily spend for my ad account over the last 30 days and write it to a CSV.

More ideas are in Your first 10 questions to ask.

Using the IDE extension or ChatGPT desktop app

Both read the same ~/.codex/config.toml, so if you did the steps above, AdChat is already there. You can also add it through the app:

  1. Open settings (the gear menu in the IDE extension, Settings in the desktop app) and select MCP servers.
  2. Click Add server, name it adchat, choose Streamable HTTP, and enter https://mcp.adchat.app.
  3. Save, then restart the extension or app and sign in when asked.

Can't sign in? Use your key as a bearer token

Signing in is the way to go. If it doesn't work where you run Codex, you can send your AdChat key as a header instead. Your key is in the dashboard and starts with adchat_. Save it in your shell profile (for example ~/.zshrc):

bash
export ADCHAT_KEY="adchat_..."

Then point Codex at it:

toml
[mcp_servers.adchat]
url = "https://mcp.adchat.app"
bearer_token_env_var = "ADCHAT_KEY"

Codex then sends Authorization: Bearer <your key> with each request. Treat the key like a password. If it ever leaks, roll it in the dashboard and update ADCHAT_KEY.

Troubleshooting

AdChat isn't listed. Check the table name is exactly [mcp_servers.adchat] (with an underscore) and that the TOML is valid.

AdChat is listed but calls fail with an auth error. Check the URL is exactly https://mcp.adchat.app. The old AdChat address no longer works. Update the URL, then run codex mcp login adchat again. If you use the bearer token instead, run echo $ADCHAT_KEY in the same terminal to check the variable is set.

"Write access is not enabled". That's AdChat's read-only default. Turn on Write Access in your dashboard only if you want Codex to make changes. See Turn on write access.

Requests get slowed down. Use through your own AI apps is unlimited, with a limit of 30 requests per minute.

FAQ

Is this the same as ChatGPT on the web? No. ChatGPT web uses its own Plugins setup. See Connect AdChat to ChatGPT.

What if my key leaks? This only matters if you use the bearer token. Click Roll API key in the API key section of the Claude & ChatGPT page. The old key stops working right away. Update ADCHAT_KEY with the new one.

Get going

Try it free for 7 days. No credit card needed. Questions? Email [email protected].

Try it on your own ad account

Connect your Meta ads to Claude, ChatGPT or our built-in chat in about a minute.

Start free for 7 daysNo credit card needed. Then $19/month. Cancel anytime.

Questions? Email me at [email protected]