Subject Line A/B Testing in OpenAI Codex
Connect OpenAI Codex to marginal's hosted email MCP server and run a full subject line A/B test without leaving your agent workflow. Codex calls the MCP tools, marginal handles the sends and tracking.
Connect OpenAI Codex to the marginal MCP server
marginal is a hosted email MCP server — there's nothing to deploy. Point OpenAI Codex at the endpoint, add your Bearer API key, and the subject line A/B testing tools become available to the agent.
Add the configuration below to your Codex MCP settings. Use a key in the marg_live_... format from your marginal dashboard.
- Registry: sh.marginal/mcp
- Endpoint: https://marginal.sh/mcp
- Auth: Bearer API key (marg_live_...)
- Free tier: 100 experiments/month
The subject line A/B test workflow in Codex
Once connected, an OpenAI Codex agent workflow can run an entire subject line A/B test through four MCP tools. You describe the campaign in natural language and Codex chains the calls, reading results between steps.
This keeps AI agent email marketing tasks inside the same loop where you're already writing code or drafting copy.
- generate_variants — draft several candidate subject lines for the test
- launch_test — start a managed send that splits the variants across your audience
- get_results — pull open/click tracking and within-test lift metrics
- recommend_next — let marginal suggest the follow-up based on observed performance
Prompting Codex for a clean A/B test
Give Codex enough context to call the tools correctly: the audience, the campaign goal, and how many variants you want. The agent translates that into generate_variants and launch_test calls, then waits before fetching results.
Because marginal tracks opens and clicks per variant, you can ask Codex to summarize which subject line A/B test winner had the strongest lift and why.
- Specify the number of subject line variants up front
- Tell the agent to launch only after you approve the generated variants
- Ask for lift metrics, not just raw opens, when reading get_results
- Use recommend_next to plan the next iteration automatically
Tips for reliable runs
Keeping the OpenAI Codex agent workflow predictable comes down to clear steps and waiting for real data before deciding a winner.
- Don't call get_results immediately — allow time for opens and clicks to accumulate
- Track your monthly experiment count against the free tier of 100
- Store the test ID returned by launch_test so Codex can resume later
- See https://marginal.sh/mcp and the docs at https://marginal.sh/docs/ for tool schemas
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