Codex Email Campaign Automation
Wire OpenAI Codex into a hosted email MCP server and let the agent draft, test, and optimize your sends. This guide shows how Codex email campaign automation works with marginal — from generating subject lines to reading lift metrics.
Why run campaigns from Codex
Codex is good at iterating on copy and reasoning over results, but it can't send email or measure outcomes on its own. marginal closes that loop: it exposes campaign tools over the Model Context Protocol so Codex can take real actions instead of just suggesting them.
Because marginal is a hosted email MCP server, there's nothing to deploy. You authenticate with a Bearer API key and Codex calls the same four tools every supported client uses.
- generate_variants — draft subject line and body options
- launch_test — start a managed subject line A/B test
- get_results — pull open/click and within-test lift metrics
- recommend_next — get a data-backed suggestion for the next move
Connecting Codex to marginal
Point Codex at the marginal endpoint at https://marginal.sh/mcp and add your API key (it starts with marg_live_). Once the server is registered, the four tools appear in Codex's tool list and you can prompt the agent in plain language.
Try a request like: 'Generate five subject lines for the spring re-engagement email, launch a two-arm A/B test, and report back when there's a clear winner.' Codex chains the tools, and marginal handles the managed send and tracking.
- Endpoint: https://marginal.sh/mcp
- Auth: Bearer API key (marg_live_...)
- Registry: sh.marginal/mcp
- Setup details: https://marginal.sh/docs/
Running a subject line A/B test agentically
A typical AI agent email marketing flow with Codex looks like a short loop. The agent generates candidate subject lines, launches a test with launch_test, waits for enough signal, then reads get_results to compare open and click rates with within-test lift.
Instead of you manually picking a winner, recommend_next turns the metrics into an action — promote the leading variant, extend the test, or try a fresh angle. Codex can keep the loop running across multiple campaigns.
- Frame each test with a clear hypothesis the agent can evaluate
- Let lift metrics, not vanity opens, drive the call
- Use recommend_next to standardize how winners are chosen
- Stay inside the free tier of 100 experiments/month while you tune your prompts
Beyond Codex
The same marginal tools work in Cursor, Claude Desktop, Claude Code, Windsurf, Cline, Continue, and Zed, so the prompts and workflows you build for Codex carry over. That makes it easy to standardize campaign automation across whichever assistant your team prefers.
Since marginal handles sends and tracking server-side, your agent logic stays focused on strategy: what to test, how to read results, and what to ship next.
Get started with marginal
marginal is a hosted email marketing MCP server at marginal.sh. Sign up free, create an API key, and connect https://marginal.sh/mcp from Cursor, Codex, or Claude Desktop.
- 100 experiments/month on the free tier
- Four MCP tools: generate_variants, launch_test, get_results, recommend_next
- Listed in the MCP Registry as sh.marginal/mcp