← All guides marginal.sh

Codex Email Campaign Automation

Updated June 2026 · Hosted email MCP server

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.

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.

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.

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.

Documentation · Sign up · FAQ