All articles
Tutorial 10 min read

How to Set Up Your AI Marketing Agent with Codex [2026]

A

Adspirer Team

Share Y
How to Set Up Your AI Marketing Agent with Codex [2026]
Summary

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.

Info

This is Part 2 of a 3-part series.


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)
Tip

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:

Terminal window
bash <(curl -fsSL https://raw.githubusercontent.com/amekala/ads-mcp/main/plugins/codex/adspirer/install.sh)

This installs:

ComponentLocationPurpose
MCP Server~/.codex/config.tomlConnects Codex to Adspirer’s 100+ advertising tools via OAuth
Agent Config~/.codex/agents/performance-marketing-agent.tomlDefines the agent’s behavior, default prompt, and permissions
5 Skills~/.agents/skills/adspirer-*/SKILL.mdProven workflows for each task type
Safety Rulesrules/campaign-safety.rulesBlocks direct API calls to ad platforms

After installation, restart Codex to load the new configuration.

Prefer manual setup?

If you want to install each component individually:

Terminal window
# Add MCP server
codex mcp add adspirer --url https://mcp.adspirer.com/mcp
# Clone and install skills + agent
git clone https://github.com/amekala/ads-mcp.git /tmp/ads-mcp
mkdir -p ~/.agents/skills
cp -r /tmp/ads-mcp/plugins/codex/adspirer/skills/adspirer-ads ~/.agents/skills/
cp -r /tmp/ads-mcp/plugins/codex/adspirer/skills/adspirer-setup ~/.agents/skills/
cp -r /tmp/ads-mcp/plugins/codex/adspirer/skills/adspirer-performance-review ~/.agents/skills/
cp -r /tmp/ads-mcp/plugins/codex/adspirer/skills/adspirer-write-ad-copy ~/.agents/skills/
cp -r /tmp/ads-mcp/plugins/codex/adspirer/skills/adspirer-wasted-spend ~/.agents/skills/
# Install agent config
mkdir -p ~/.codex/agents
cp /tmp/ads-mcp/plugins/codex/adspirer/agents/performance-marketing-agent.toml ~/.codex/agents/

Then add to ~/.codex/config.toml:

[features]
multi_agent = true
[agents.performance-marketing-agent]
description = "Brand-specific performance marketing agent."
config_file = "agents/performance-marketing-agent.toml"

See the full Codex setup documentation for details.


Step 2: Authenticate with Adspirer

Verify the MCP server is installed:

Terminal window
codex mcp list

You should see adspirer in the output (it may show “Unsupported” for auth — that’s normal before login). Now authenticate:

Terminal window
codex mcp login adspirer

A 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:

Terminal window
codex mcp list

adspirer 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:

Terminal window
cd ~/Clients/YourBrand # or wherever your brand docs live
codex

Then tell the agent to set up your workspace:

Brand Workspace Setup

Set up my brand 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 docs

The AGENTS.md file is the agent’s brain. Here’s what a typical one contains:

SectionContentSource
Brand OverviewWhat you sell, who you sell to, industryYour docs + Adspirer
Brand VoiceTone, language style, prohibited wordsYour docs
Target AudiencesAudience segments with targeting parametersYour docs + campaigns
Active PlatformsConnected platforms, campaign countsAdspirer
Budget & GuardrailsMonthly budget, CPC caps, CPA targetsYour docs + campaigns
KPI TargetsPrimary goals and target metricsYour docs
Performance SnapshotLast 30 days across all platformsAdspirer
Key FindingsTop campaigns, wasted spend, opportunitiesAdspirer 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.

Skill: $adspirer-ads

The main skill. Handles campaign creation, performance analysis, keyword research, budget optimization, ad extensions, and audience analysis across all 4 platforms.

Workflow: Check connection → Research (keywords/audiences) → Validate assets → Create campaign (PAUSED) → Verify structure

Campaign Creation

Create a Google Ads search campaign for my SaaS product. Budget $75/day. Research keywords first, then create the campaign with sitelinks and callout extensions.

Skill: $adspirer-performance-review

Runs a cross-platform performance scorecard. Pulls metrics from all connected platforms, compares against your KPI targets in AGENTS.md, and identifies top performers, underperformers, and strategy drift.

Performance Review

Run a performance review for the last 30 days across all platforms. Compare against my KPI targets and flag any strategy drift.

Skill: $adspirer-wasted-spend

Finds money leaks across your accounts. Identifies keywords spending without converting, creatives with declining performance, and audiences with poor ROI.

Wasted Spend Audit

Find wasted spend across all my ad platforms for the last 14 days. Show me what’s spending without converting and total up potential monthly savings.

Skill: $adspirer-write-ad-copy

Generates brand-voice ad copy using your AGENTS.md brand guidelines and real performance data. Knows what headlines and descriptions have worked in your account.

Write Ad Copy

Write Google Search ad copy for my new product launch. Use my brand voice from AGENTS.md. Generate 15 headlines and 4 descriptions that fit character limits.

Skill: $adspirer-setup

Bootstraps or refreshes your brand workspace. Run this when you first connect, when you add new ad platforms, or when you add new brand docs.

Refresh Setup

Refresh my brand workspace — I connected Meta Ads since last setup. Pull the new data and update AGENTS.md.

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

RuleHow It Works
Campaigns created PAUSEDAll create_* tools default to PAUSED status. Nothing goes live without your explicit approval.
User confirmation for spendThe agent asks before creating campaigns or changing budgets.
Read-before-writeConnection 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 retriesIf campaign creation fails, the agent reports the error. It doesn’t retry and risk duplicate campaigns.
Post-creation verificationAfter creating a campaign, the agent verifies ad groups, keywords, and ads are properly attached.
Info

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

Terminal window
codex run performance-marketing-agent

The 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:

ModeFile AccessTool CallsBest For
Read-onlyRead onlyApproval needed for eachReviewing performance, learning the system
Auto (default)Read + edit in working dirAuto-approved in scopeCampaign creation, keyword management
Full AccessRead anywhere + networkAuto-approvedBulk 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

MCP server not found

Run codex mcp add adspirer --url https://mcp.adspirer.com/mcp and restart Codex. Verify with codex mcp list.

Authentication failed or expired

Run codex mcp login adspirer to re-authenticate. A browser window opens for OAuth. If it doesn’t open automatically, check your terminal for a URL to copy.

Skills not showing

Verify installation: ls ~/.agents/skills/ should show adspirer-ads, adspirer-setup, adspirer-performance-review, adspirer-write-ad-copy, and adspirer-wasted-spend. If missing, re-run the installer.

'No ad platforms connected' error

Connect your ad platforms at adspirer.com. The agent needs at least one connected platform (Google Ads, Meta Ads, LinkedIn Ads, or TikTok Ads) to work.

Rate limit hit

Check your Adspirer tier. Free: 15 tool calls/month. Plus: 150. Pro: 600. Max: 3,000. A daily performance check uses 2-5 calls. If you’re running daily autonomously, you’ll need at least the Plus plan. See pricing →


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.

Info

Ready to start? Sign up for Adspirer (free tier: 15 tool calls/month) and install the Codex plugin with one command.

Get started free →


AI Agents Automation PPC MCP

More articles to read