How to Set Up Your AI Marketing Agent with Codex [2026]
Adspirer Team
This is the hands-on setup guide for building your AI marketing agent with OpenAI Codex. You’ll install the Adspirer plugin (one command), create your brand workspace (AGENTS.md + STRATEGY.md), understand the 5 skills, configure safety rules, and run your first autonomous performance check. By the end, your agent will be running.
In Part 1, we covered why an AI marketing agent is different from an AI assistant — persistent brand knowledge, strategy memory, specialized skills, autonomous scheduling. Now we build it.
The setup takes about 10 minutes. Most of that time is the brand workspace creation, where the agent scans your brand docs and pulls live data from your ad accounts to build its knowledge base. The actual installation is one command.
This is Part 2 of a 3-part series.
- Part 1: How to Build an AI Marketing Agent for Paid Media
- Part 2 (this post): Setting up your agent with Codex
- Part 3: How to Run Facebook & Instagram Ads with Your Codex AI Agent
Prerequisites
Before you start, make sure you have:
- OpenAI Codex CLI installed (installation guide)
- Git installed (the installer clones from GitHub)
- Node.js 18+ (for the MCP server)
- An Adspirer account (free to start)
- At least one ad platform account: Google Ads, Meta Ads, LinkedIn Ads, or TikTok Ads
- A ChatGPT Plus, Pro, Business, or Enterprise subscription (Codex requires an OpenAI paid plan)
Don’t have Codex yet? Install it with npm i -g @openai/codex. It’s open source and runs locally on macOS and Linux (Windows via WSL). See the OpenAI Codex documentation for details.
Step 1: Install the Adspirer Plugin
The one-command installer sets up everything — the MCP server connection, all 5 skills, the agent config, and safety rules:
bash <(curl -fsSL https://raw.githubusercontent.com/amekala/ads-mcp/main/plugins/codex/adspirer/install.sh)This installs:
| Component | Location | Purpose |
|---|---|---|
| MCP Server | ~/.codex/config.toml | Connects Codex to Adspirer’s 100+ advertising tools via OAuth |
| Agent Config | ~/.codex/agents/performance-marketing-agent.toml | Defines the agent’s behavior, default prompt, and permissions |
| 5 Skills | ~/.agents/skills/adspirer-*/SKILL.md | Proven workflows for each task type |
| Safety Rules | rules/campaign-safety.rules | Blocks direct API calls to ad platforms |
After installation, restart Codex to load the new configuration.
Step 2: Authenticate with Adspirer
Verify the MCP server is installed:
codex mcp listYou should see adspirer in the output (it may show “Unsupported” for auth — that’s normal before login). Now authenticate:
codex mcp login adspirerA browser window opens. Sign in with your Adspirer account (or create one free) and link your ad platform accounts — Google Ads, Meta Ads, LinkedIn Ads, and/or TikTok Ads. The connection uses OAuth 2.1, and your ad account credentials are never stored locally. See the security documentation for details.
After authenticating, verify:
codex mcp listadspirer should now show as enabled.
Step 3: Create Your Brand Workspace
This is where the agent becomes yours. Navigate to your brand’s project folder and launch Codex:
cd ~/Clients/YourBrand # or wherever your brand docs livecodexThen tell the agent to set up your workspace:
Or invoke the skill directly with $adspirer-setup.
What Happens During Setup
The setup skill runs a comprehensive bootstrap process:
Scans Your Local Files
The agent looks for brand documents in your folder — .md, .txt, .csv, .yaml, .json, .pdf files. Brand guidelines, media plans, competitor analyses, audience research — anything it finds gets absorbed into the brand context. Tip: Drop your brand docs into the folder before running setup. The more context you provide, the better the agent performs.
Connects to Your Ad Accounts
Calls Adspirer to check which ad platforms are connected and pulls account-level metadata — account names, IDs, active campaign counts.
Pulls Live Performance Data
Pulls the last 30 days of campaign performance across all connected platforms. This becomes the baseline the agent uses for future comparisons.
Creates AGENTS.md
Builds the brand context file — your brand overview, target audiences, brand voice guidelines, connected platforms, budget guardrails, KPI targets, performance snapshot, and key findings. This file is what makes the agent brand-aware.
Creates STRATEGY.md
Initializes the strategy playbook where strategic decisions will be saved across sessions. Starts empty, but fills up as you analyze campaigns and confirm findings.
What Your Workspace Looks Like After Setup
~/Clients/YourBrand/├── AGENTS.md # Brand context — everything the agent knows about you├── STRATEGY.md # Strategy directives — persists across sessions├── brand-guidelines.pdf # Your existing docs (if you added any)└── media-plan.xlsx # Your existing docsThe AGENTS.md file is the agent’s brain. Here’s what a typical one contains:
| Section | Content | Source |
|---|---|---|
| Brand Overview | What you sell, who you sell to, industry | Your docs + Adspirer |
| Brand Voice | Tone, language style, prohibited words | Your docs |
| Target Audiences | Audience segments with targeting parameters | Your docs + campaigns |
| Active Platforms | Connected platforms, campaign counts | Adspirer |
| Budget & Guardrails | Monthly budget, CPC caps, CPA targets | Your docs + campaigns |
| KPI Targets | Primary goals and target metrics | Your docs |
| Performance Snapshot | Last 30 days across all platforms | Adspirer |
| Key Findings | Top campaigns, wasted spend, opportunities | Adspirer analysis |
Every time the agent runs a task, it reads AGENTS.md first. This is how it knows your brand without you re-explaining it every session.
Step 4: Understand the 5 Skills
Your agent has 5 specialized skills — each is a proven workflow that enforces the right tool sequence for a specific task type. You don’t need to remember their names; describe what you want and Codex matches the right skill automatically.
For the complete skill reference with all parameters and workflows, see the skill documentation.
Step 5: Safety Rules
When an AI agent operates autonomously, safety is critical. Codex’s .rules files enforce safety at a deeper level than skill instructions — they block dangerous operations before they reach the AI.
What’s Protected
| Rule | How It Works |
|---|---|
| Campaigns created PAUSED | All create_* tools default to PAUSED status. Nothing goes live without your explicit approval. |
| User confirmation for spend | The agent asks before creating campaigns or changing budgets. |
| Read-before-write | Connection check → research → validate → create. Can’t skip steps. |
| Direct API blocked | .rules files block curl to ad platform APIs. Everything goes through Adspirer’s authenticated pipeline. |
| No automatic retries | If campaign creation fails, the agent reports the error. It doesn’t retry and risk duplicate campaigns. |
| Post-creation verification | After creating a campaign, the agent verifies ad groups, keywords, and ads are properly attached. |
Bottom line: Autonomous doesn’t mean uncontrolled. The agent analyzes, recommends, and alerts — but you make the final spending decisions. See the capabilities and safety documentation for the full safety model.
Step 6: Your First Autonomous Workflow
Let’s set up the most valuable autonomous workflow — a daily performance check that runs every morning without you opening any tool.
Configure the Daily Check
Edit your agent’s default prompt in ~/.codex/agents/performance-marketing-agent.toml:
[agent]name = "performance-marketing-agent"description = "Daily ad performance monitoring and analysis"
[agent.default_prompt]text = """Pull yesterday's performance across all my connected ad platforms.Compare each campaign to the previous 7-day average.Flag any campaigns where:- CPA increased more than 30%- Spend increased more than 50% without proportional conversion increase- CTR dropped below 1%- Frequency exceeded 3.0 (Meta/LinkedIn)
Check STRATEGY.md for any active directives that might affect recommendations.Give me a prioritized summary with the top 3 actions I should take today."""Run It
codex run performance-marketing-agentThe agent reads AGENTS.md for brand context, pulls performance data from all connected platforms via Adspirer, compares against your KPI targets, checks STRATEGY.md for strategic directives, and produces a prioritized summary.
What You Get
The agent returns a structured performance report — no dashboard clicking, no CSV exports, no spreadsheet building. Every metric compared to your targets, every anomaly explained, every recommendation backed by data.
And tomorrow morning, it runs again automatically.
Approval Modes
Codex has 3 approval modes that control how much autonomy the agent gets:
| Mode | File Access | Tool Calls | Best For |
|---|---|---|---|
| Read-only | Read only | Approval needed for each | Reviewing performance, learning the system |
| Auto (default) | Read + edit in working dir | Auto-approved in scope | Campaign creation, keyword management |
| Full Access | Read anywhere + network | Auto-approved | Bulk operations across multiple accounts |
For advertising, Auto mode is the sweet spot. Read operations (pulling performance data, analyzing campaigns) run automatically. Write operations (creating campaigns, changing budgets) prompt you for confirmation. This matches the safety model — the agent handles analysis autonomously but defers to you for spending decisions.
Troubleshooting
What’s Next
Your agent is installed, authenticated, and running. The brand workspace is created. You’ve got 5 skills, safety rules, and your first autonomous workflow configured.
In Part 3: How to Run Facebook & Instagram Ads with Your Codex AI Agent, we go deeper — building a Meta Ads specialist role with creative fatigue monitoring, audience optimization, campaign ideation pipelines, and the compounding knowledge effect that makes the agent smarter over time.
Ready to start? Sign up for Adspirer (free tier: 15 tool calls/month) and install the Codex plugin with one command.
Related Articles
- How to Build an AI Marketing Agent for Paid Media — Part 1: The concept and why it matters
- How to Run Facebook & Instagram Ads with Your Codex AI Agent — Part 3: Channel-specific role development
- How to Run Facebook & Instagram Ads with ChatGPT — The assistant approach
- How to Run Facebook & Instagram Ads with Claude AI — Claude’s deep reasoning approach
- What Is MCP (Model Context Protocol)? — The protocol behind all of this
- PPC Automation with ChatGPT and Claude — Automating paid search workflows
More articles to read
How to Build an AI Marketing Agent for Paid Media [2026]
Why AI marketing agents are replacing dashboards for paid media. What an advertising brain looks like, how it differs from AI assistants, and what it takes to build one.
How to Set Up Your AI Marketing Agent with Claude Code [2026]
Install the Adspirer plugin, create your brand workspace, configure sub-agents, and run your first ad performance check — all from the Claude Code CLI.