Running email A/B tests in n8n with the marginal MCP
If you orchestrate workflows in n8n and want your AI agents to test subject lines without hand-coding ESP calls, the n8n email A/B test MCP pattern lets an agent generate variants, launch a managed send, and act on results — all through marginal's hosted endpoint.
Why pair n8n with an email MCP server
n8n is great at moving data between systems, but it doesn't know how to design a subject line A/B test or decide a winner. marginal is an email MCP server built for AI agents: it exposes four focused tools — generate_variants, launch_test, get_results, and recommend_next — over a single hosted endpoint.
By calling marginal from an agent node, your n8n workflow can trigger a full experiment lifecycle. The agent reasons about copy and timing; marginal handles managed sends, open/click tracking, and within-test lift metrics.
- Endpoint: https://marginal.sh/mcp
- Auth: Bearer API key (marg_live_...)
- No self-hosting — marginal is fully hosted
- Free tier covers 100 experiments per month
A typical subject line A/B test flow
Most n8n teams trigger marginal from a scheduled or webhook-driven workflow that hands context to an AI agent. The agent then walks the four tools in order, producing a subject line A/B test the agent can monitor and learn from.
- generate_variants — draft several subject line candidates from a brief
- launch_test — send the managed test to your audience split
- get_results — pull open/click tracking and lift between variants
- recommend_next — let the agent decide the next iteration
Connecting marginal to your agent runtime
marginal speaks the Model Context Protocol, so any MCP-capable client can drive these tools. While n8n orchestrates the surrounding workflow, the agent step itself connects to marginal the same way an MCP client like Cursor, Claude Desktop, Claude Code, Windsurf, Cline, Continue, Zed, or OpenAI Codex would.
Point your agent at https://marginal.sh/mcp, supply the Bearer API key, and the four tools become callable. This keeps AI agent email marketing logic in one place instead of scattered across custom HTTP nodes.
- Registry identifier: sh.marginal/mcp
- Works with any MCP-compatible agent client
- Docs and setup details: https://marginal.sh/docs/
Tips for reliable n8n email A/B test MCP runs
Because marginal returns structured results, it's easy to branch your n8n workflow on the outcome — for example, routing a winning variant to a broader send or queueing recommend_next for a follow-up experiment.
- Store the test ID from launch_test so later nodes can fetch results
- Poll get_results on a delay node so tracking data has time to accumulate
- Use recommend_next to feed the next generate_variants brief automatically
- Watch your monthly experiment count against the free tier limit
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