How to connect Codex to an email MCP server
If you want your AI agent to draft subject lines, launch experiments, and read open and click metrics without leaving your editor, you can connect Codex to email MCP through marginal — a hosted email marketing MCP server built for exactly this workflow.
What you get when you connect Codex to email MCP
marginal exposes a small, focused set of tools over the Model Context Protocol so Codex can run a complete subject line A/B test loop. There's nothing to deploy: the endpoint is hosted at https://marginal.sh/mcp and authenticated with a Bearer API key.
- generate_variants — produce candidate subject lines for a campaign
- launch_test — start a managed send and split traffic across variants
- get_results — pull open/click tracking and within-test lift metrics
- recommend_next — let the agent decide the next move based on results
Configure Codex with your marginal API key
OpenAI Codex speaks MCP, so wiring it up to the marginal email MCP server is a configuration step rather than a coding project. Generate an API key (it looks like marg_live_...) from your marginal dashboard, then point Codex at the hosted endpoint.
Add the server to your Codex MCP configuration with the registry name sh.marginal/mcp and the endpoint https://marginal.sh/mcp. Supply the key as a Bearer credential so every tool call is authenticated. Once registered, the four tools appear to the agent automatically.
- Registry: sh.marginal/mcp
- Endpoint: https://marginal.sh/mcp
- Auth: Authorization: Bearer marg_live_...
- No self-hosting required — marginal is fully hosted
Run your first subject line A/B test from Codex
With the connection live, ask Codex to test a campaign in plain language. A typical flow asks the agent to generate several variants, launch a managed send, and then check back once data arrives. Because marginal reports within-test lift, the agent can compare variants on a fair basis instead of guessing.
This is what AI agent email marketing looks like in practice: the model owns the iteration loop, and you review the recommendation. Codex calls generate_variants, then launch_test, then get_results, and recommend_next closes the loop with a suggested winner or follow-up test.
- "Generate 5 subject lines for our onboarding email and start an A/B test"
- "Show me open and click rates with lift for test #1024"
- "Recommend the next variant to try based on these results"
Limits, docs, and next steps
The free tier includes 100 experiments per month, which is plenty for validating the workflow and running real subject line A/B tests on smaller lists. If you also work in Cursor, Claude Desktop, Claude Code, Windsurf, Cline, Continue, or Zed, the same marginal server connects there with identical configuration.
Full tool schemas, parameter details, and example payloads live in the documentation at https://marginal.sh/docs/.
- 100 experiments/month on the free tier
- Same endpoint works across all supported MCP clients
- Docs: https://marginal.sh/docs/
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