- Zero-dependency Node 18+ email generator, validator, and MCP server - 46 core + 18 MCP tests passing - Researched client-support matrix and traceable rule registry - Fallback-first interactive components (accordion, carousel, tabs) - Per-platform agent instruction shims (AGENTS.md, CLAUDE.md, etc.)
Email development agent
Generates table-based, inlined-CSS HTML emails from a structured brief, validates them against a researched client-support matrix, and emits a client-compatibility report alongside each email.
Zero dependencies. Node 18+.
- Phase 1 research:
RESEARCH.md— 96 numbered engineering rules, an 18-feature × 8-client support matrix, and 8 flagged source contradictions. Every rule cites the Nimble MCP call that produced it. - Progress log:
PROGRESS.md
Every rule the agent applies traces back to a rule ID in RESEARCH.md. src/rules.js is the
enforcement of that: the validator may only emit a finding whose ID is registered there with a
RESEARCH.md section reference, and a test asserts it.
Usable three ways: MCP server, CLI, or library. Setup for every major AI coding
platform is in docs/INTEGRATIONS.md.
Usage
MCP server
node mcp/server.js # stdio
Pre-configured for Claude Code (.mcp.json), Cursor (.cursor/mcp.json) and VS Code Copilot
(.vscode/mcp.json) — they pick it up on open. Claude Desktop, Windsurf, Cline, Zed and Continue
need a one-line config; snippets are in docs/INTEGRATIONS.md.
Implemented directly against the protocol — no SDK, so there is still nothing to install.
| Tool | Purpose |
|---|---|
generate_email |
Brief → validated HTML + compatibility report |
validate_email_html |
Check existing email HTML against the rule set |
lookup_client_support |
Query the support matrix (y/n/a/u + caveat notes) |
lookup_rules |
List enforced rules with severity and RESEARCH.md reference |
get_brief_schema |
Brief schema, block shapes, and a worked example |
Resources expose RESEARCH.md, README.md, PROGRESS.md and both example briefs, so any host can
audit why a rule was applied.
CLI
node bin/email-agent.js build briefs/product-update.json
node bin/email-agent.js build briefs/spring-collection.json
node bin/email-agent.js build briefs/spring-collection.json --esp klaviyo --out out/klaviyo
npm test
Options: --out <dir> (default out), --esp <name>, --strict (fail on warnings too).
Exit code is non-zero if any error-level rule is violated, so it drops into CI or a pre-send check.
Library
import { generateEmail } from './src/index.js';
const { html, report, validation } = generateEmail(brief, { esp: 'generic' });
What it produces
| Brief | Output | Result |
|---|---|---|
briefs/product-update.json |
non-interactive email | PASS — 0 errors, 0 warnings |
briefs/spring-collection.json |
CSS-interactive accordion + carousel with static fallback | PASS — 0 errors, 0 warnings |
Each build writes <name>.html and <name>.report.md.
The design constraint everything else follows from
Phase 1 turned up one finding that dictates the whole interactive architecture (RESEARCH.md
R-INT-02):
Gmail renders
<input type="checkbox">and<input type="radio">on all four platforms (supporty) but does not support:checkedon any of them (supportn).
So the obvious accordion — hide content, reveal on :checked — renders in Gmail as a clickable
control that does nothing, with the content permanently unreachable. Worse than no accordion.
The agent builds fallback-first instead (R-INT-09). All content is visible in the DOM by
default; the collapse exists only in a rule keyed on :checked:
input:not(:checked) ~ table .ea-acc-body{display:none}
A client that doesn't support :checked has an invalid simple selector in that rule, so the whole
rule is dropped and every panel stays open. Clients that sanitise CSS (Gmail) strip it to the same
effect. Clients that strip <input> entirely (Orange, SFR, LaPoste) leave nothing for ~ to match.
Every failure path fails open — the worst outcome is a longer, fully readable static email.
:checked is attached to a type selector rather than a class because Outlook.com and Outlook
mobile support it on type selectors only (R-INT-04, matrix note N1).
:target is never used: it's unsupported in both Apple Mail and Gmail (R-INT-01), which makes it
strictly worse than the checkbox family despite being the more commonly suggested technique.
Layout
The highest-value mechanical rule is R-LAY-02, from Microsoft's own documented Word CSS categories:
width, height, padding and border longhands only apply to <table>, <td>, <h1>, <ul>,
<li> — never <div>, <p> or <span>. The renderer puts all spacing on cells and the validator
rejects any violation.
ESP handling
Klaviyo cannot carry a CSS-hack interactive email: it doesn't support the ~ operator and
interactive CSS blocks preview generation (R-ESP-01). Rather than emit a template that errors on
import, the agent flattens interactive blocks to static content and records the decision as a
visible transform:
R-ESP-01 Target ESP is Klaviyo, which does not support the ~ operator and errors on
interactive CSS. 2 interactive block(s) were flattened to static content
rather than emitting a template that would fail on import.
All panel and slide content survives the flattening; a test asserts it.
Brief format
{
"meta": { "title": "…", "preheader": "…", "lang": "en-GB", "dir": "ltr",
"esp": "generic", "width": 600 },
"brand": { "pageBackground": "#eceef2", "surface": "#fdfdfb", "text": "#1f2430",
"muted": "#525b6b", "accent": "#1f4ed8", "accentText": "#fdfdfb",
"border": "#d7dbe3" },
"blocks": [ /* … */ ]
}
Block types: heading · text · image · button · divider · spacer · accordion ·
carousel · footer.
The agent modifies briefs in two cases, and never silently — both are printed by the CLI and listed in the report:
- R-DARK-04 — pure
#ffffffbackgrounds and#000000text are snapped to near-neutrals. Force-inverting clients (Gmail, Yahoo, AOL) flip pure values to their exact opposites, which is precisely the case that produces a contrast failure. - R-DOC-02 — a missing
meta.langbecomeslang="und", with a note telling you to set a real language code.
Validation
Runs before the email is returned. Error-level findings are surfaced, not swallowed.
Checked mechanically: document skeleton (R-DOC-01…09), Word CSS categories (R-LAY-02), flexbox/grid,
margin:auto, display:block on <td>, <style> and document size budgets, media-query shape,
@font-face, image alt/dimensions/format, linked-image accessible names, Gmail's url()
style-stripping hazard, pure black/white, role="presentation" on every table, <h1> count, link
text, WCAG contrast, :target, input hiding, fallback-first construction, script/form/video, and
the Klaviyo-specific rules.
Two honest limits, both documented in RESEARCH.md:
- The scanner is regex-based over markup the agent generated itself. It is not a general-purpose HTML parser and would not be trustworthy against arbitrary third-party HTML.
- Contrast is computed from the render-time colour model rather than re-derived from the cascade, because regex cannot resolve inheritance. The render-time pairs are exact, so this is the more accurate route — but text over an image has no computable ratio and is not checked (G-05).
Unknown features fail closed (G-04): anything used but absent from the matrix is reported as unknown rather than assumed safe.
What "tested" means here
Per RESEARCH.md §6, and stated in every report:
- Verified — the HTML satisfies every mechanically checkable rule. The validator asserts this.
- Predicted — per-client rendering, derived from the matrix. Not observed.
- Unverified — real rendering and real interaction in real clients. Still required.
Litmus and Email on Acid return static screenshots, so they cannot confirm that an interaction actually functions. Interactive claims need real-device testing, and the agent never describes its own output as "tested in Gmail".
Tests
npm test — 64 tests: 46 core plus 18 MCP.
Most of the core suite is adversarial: it feeds the validator deliberately broken input and asserts
the specific rule fires, because a validator that passes everything is worthless. Included: the
naive hide-by-default accordion (must trip R-INT-09), padding on a div, :target, pure
white/black, missing alt, low contrast, webp, @font-face, and a matrix-integrity check asserting
the Gmail :checked trap is still encoded as found.
The MCP suite spawns the real server and speaks JSON-RPC over stdio, because in-process tests would miss the failure modes that actually break MCP integrations — stdout pollution, framing bugs, answering a notification. It covers version negotiation, recovery from malformed JSON, tool-level vs protocol-level error handling, and asserts stdout stays clean even with debug logging enabled.
Layout of the repo
src/matrix.js Phase 1 §4 support matrix as data, with per-cell notes
src/rules.js rule registry — the RESEARCH.md ↔ code traceability link
src/color.js WCAG contrast + dark-mode-safe palette normalisation
src/brief.js brief schema, validation, normalisation
src/html.js escaping and table helpers
src/interactive.js accordion + carousel, fallback-first
src/render.js document assembly and content blocks
src/validate.js the validator
src/report.js client-compatibility report
src/index.js public API + ESP routing
src/mcp-tools.js transport-agnostic tool definitions and handlers
mcp/server.js MCP stdio server
bin/email-agent.js CLI
briefs/ two example briefs
tests/run.js core suite
tests/mcp.js MCP protocol suite
docs/INTEGRATIONS.md per-platform setup
AGENTS.md canonical instructions for AI coding agents
src/mcp-tools.js imports nothing MCP-specific, so the same handlers can be mounted on another
transport without touching the agent's logic.