Connect Codex to Adflitz
Codex CLI and the Codex IDE extension share one MCP configuration. Keep the key in an environment variable so it never lands in a file, or sign in with OAuth instead.
Before you start
- Sign-in method: OAuth sign-in or API key. The server address is
https://adflitz.com/api/mcp. - For OAuth you need to be an owner or admin of the Adflitz workspace. Members can use an API key someone with that role created for them.
- For an API key create one under Settings, then API keys, and allow agents on the project under Settings, then Agents. The key is shown once, so put it straight into an environment variable.
- Pick the lowest permission that does the job. Access levels explains read, draft and publish.
Steps
- Create an API key in Adflitz (Settings, API keys) and allow agents on the project (Settings, Agents). Skip this if you use OAuth.
- Export the key and add the server with the commands below. For OAuth use the alternative commands instead.
- Start codex from the same shell so it can see the environment variable.
- Paste the check prompt into Codex.
Copy and paste
OpenAI's Codex CLI and IDE extension. Put the key in an environment variable and give Codex its name, so the key never lands in a config file. Or leave the variable out and sign in with OAuth.
export ADFLITZ_API_KEY=apk_YOUR_KEY codex mcp add adflitz --url https://adflitz.com/api/mcp \ --bearer-token-env-var ADFLITZ_API_KEY
Or sign in with OAuth instead of a key
codex mcp add adflitz --url https://adflitz.com/api/mcp codex mcp login adflitz
Check that it worked
Open a new conversation in Codex and paste this prompt. It only reads, so it is safe to run on a live account.
Check prompt
Use Adflitz to give me the workspace overview. List my projects, which ad platforms are connected and how many drafts are waiting for approval. Do not change anything.
A good answer names your workspace and plan, lists your projects with the permission each one grants, shows the connected platforms and tells you how many drafts are waiting. If the assistant says it cannot find an Adflitz tool, jump to troubleshooting below.
Troubleshooting
- Codex reads the key from the environment it starts in. Export ADFLITZ_API_KEY in the same shell (or your profile) before running codex.
- Equivalent config in ~/.codex/config.toml: a [mcp_servers.adflitz] table with url and bearer_token_env_var.
- 401 or “unknown or revoked”: send the whole key, starting with apk_, as a Bearer token with nothing around it. A revoked key never works again, so create a new one under Settings → API keys.
- The tools list is empty or calls say forbidden: open Settings → Agents and allow agents on the project, and give the key at least the permission the tool needs (read, draft or publish).
- The overview works but lists no ad accounts: connect them first, see Connect ad accounts.
What to ask next
- How did my ads do over the last 14 days? Group it by campaign and point out what needs attention.
- Draft a Search campaign for our two best services and file it as a draft for my approval.
- Which campaigns spent without results this week? Suggest what to pause and give me the reason for each.
- Save the three most useful competitor ads for this project to my swipe file.
Changes you ask for become drafts that you review first. Read Drafts and approvals to see how a draft is checked and approved.
Other clients
ChatGPTClaude.aiClaude CodeCursorGemini CLIPerplexityGrok BotHermes AgentOpenClawn8nAny other MCP client
Questions about connecting your AI or your ad accounts? Write to contact@adflitz.com or open the support page.