MCP Hub
Back to servers

EmailMCP

AI agent email — 23 tools free to read inbox, 28 paid to send. $9.99/mo. Token auto-provisioned.

Registry
Updated
May 2, 2026
AgenticEmailService



AgenticEmailService

emailmcp

Self-hosted SendGrid — powered by AI.

Your own email infrastructure. One MCP command provisions a cloud VPS, WireGuard tunnel, DKIM/SPF/DMARC, Let's Encrypt TLS, and authoritative DNS. No third-party email provider needed.

Or use it as a universal email client with 9 providers. Your choice.


npm version License: MIT Node 18+ MCP Tests CI


Works with



Autonomous Mode  •  Provider Mode  •  Rules Engine  •  Install  •  API Docs


Two Modes

Self-Hosted (Autonomous Mode) — your own SendGrid

You:  "Set up my email server"
AI:   Creating OVH VPS in GRA11... done. IP: 51.38.x.x
      WireGuard config saved. Run: sudo wg-quick up ~/.emailmcp/wg-email.conf

You:  [connects WireGuard]
You:  "Resume setup"
AI:   Tunnel verified. Add these 2 DNS records at your registrar:
        NS   emailrelay.xyz  →  ns1.emailrelay.xyz
        A    ns1.emailrelay.xyz  →  51.38.x.x

You:  [adds DNS records]
You:  "Resume setup"
AI:   DNS propagated. TLS cert obtained. SMTP verified.
      Your email server is live.

You:  "Add company.com as a sending domain"
AI:   DKIM keys generated. Add these 4 records to company.com:
        MX    company.com  →  mail.company-com.emailrelay.xyz
        TXT   company.com  →  v=spf1 include:company-com.emailrelay.xyz -all
        CNAME emailmcp._domainkey.company.com  →  emailmcp._domainkey.company-com.emailrelay.xyz
        TXT   _dmarc.company.com  →  v=DMARC1; p=reject; adkim=s; aspf=s

You:  "Send hello@company.com a welcome email"
AI:   Sent. DKIM ✅ SPF ✅ DMARC ✅

What you get:

  • Dedicated clean IP on a $3/mo VPS (OVH, Vultr, Hetzner, DigitalOcean)
  • WireGuard tunnel — email flows through your IP, not a shared pool
  • DKIM signing with your own 2048-bit RSA keys
  • SPF hard fail (-all) — only your IP authorized
  • DMARC strict alignment (adkim=s; aspf=s)
  • Authoritative DNS on the VPS (CoreDNS) — you are your own nameserver
  • Let's Encrypt TLS for SMTP STARTTLS
  • PTR / reverse DNS set automatically
  • Local mailbox storage — AI reads inbox via MCP, no IMAP needed
  • Multi-tenant: add unlimited sending domains, each with its own DKIM keys
  • Health monitoring with auto-restart

No SendGrid. No Mailgun. No monthly email bills. Your infrastructure, your keys, your data.

Provider Mode — 9 providers, zero lock-in

Same tool, different backend. Use any email provider:

Switch providers by changing one env var. Read inbox via IMAP with real-time IDLE push notifications.


Rules Engine

Email rules with MCP-triggered actions. Like server-side rules, but your AI controls them:

You:  "Create a rule: when emails from *@vip-client.com arrive, flag as VIP and forward to ceo@company.com"
AI:   Rule created: VIP Client Alert (priority 10)
      Match: from=*@vip-client.com
      Actions: flag(vip), forward(ceo@company.com)

8 action types: forward, auto_reply, webhook, flag, move, mcp_tool, log, reject

Enterprise patterns tested:

  • Multi-department routing (sales/support/billing with different auto-replies)
  • Cascading escalation (L1 → L2 → L3 with stop flags)
  • Compliance (legal hold, GDPR data subject request detection, SOX flagging)
  • DLP (flag emails containing sensitive patterns)
  • Phishing protection (reject known bad domains)
  • Audit trail (webhook every email to your audit system)
  • Batch processing (50 concurrent emails, zero errors)

Rules fire on both autonomous inbound SMTP and IMAP IDLE real-time notifications.


IMAP IDLE — Real-Time Push

No polling. Instant notification when new email arrives:

You:  "Watch my work and personal email for new messages"
AI:   Watching work (me@company.com) and personal (me@gmail.com)
      New emails trigger rule evaluation automatically.

[New email arrives]
AI:   New email in work: "Server Down Alert" from monitoring@infra.com
      → Rule "L2 Infrastructure" matched → forwarded to infra-team@company.com

Works with any IMAP provider. Multi-account. Auto-reconnect on disconnect.


Install

Option A: npx (zero setup)

{
  "mcpServers": {
    "email": {
      "command": "npx",
      "args": ["-y", "emailmcp"],
      "env": {
        "DEFAULT_PROVIDER": "autonomous",
        "EMAIL_DOMAIN": "company.com"
      }
    }
  }
}

Option B: Clone for autonomous mode

git clone https://github.com/nfodor/emailmcp.git
cd emailmcp && npm install
cp .env.example .env
# Set DEFAULT_PROVIDER=autonomous and EMAIL_DOMAIN

Then ask your AI: "Set up my email server"

Provider mode (any of 9 providers)

{
  "mcpServers": {
    "email": {
      "command": "npx",
      "args": ["-y", "emailmcp"],
      "env": {
        "DEFAULT_PROVIDER": "mailgun",
        "MAILGUN_API_KEY": "key-your-api-key",
        "MAILGUN_DOMAIN": "mg.yourdomain.com",
        "FROM_EMAIL": "noreply@yourdomain.com",
        "IMAP_HOST": "imap.gmail.com",
        "IMAP_EMAIL": "you@gmail.com",
        "IMAP_PASSWORD": "your-app-password"
      }
    }
  }
}

See .env.example for all provider configs (Mailgun, SendGrid, SES, Gmail, Resend, SMTP, MailHog, Autonomous).


MCP Tools

Email

ToolDescription
send_emailSend with text/HTML, attachments, CC, BCC. Provider override per-call.
send_template_emailHandlebars templates (built-in: welcome, notification, test)
validate_emailFormat + MX record verification
read_inboxIMAP or local autonomous mailbox with filters
get_mailbox_statusTotal / unread / recent counts

Rules

ToolDescription
create_email_ruleMatch conditions + actions (forward, auto_reply, webhook, mcp_tool, etc.)
list_email_rulesAll rules with hit counts
update_email_ruleEnable/disable, change priority/match/actions
delete_email_ruleRemove a rule

Real-Time

ToolDescription
start_idle_watchIMAP IDLE push on one or all accounts
stop_idle_watchStop watching
get_idle_statusConnection status, new email counts

Autonomous Server

ToolDescription
provision_startCreate cloud VPS + WireGuard + DKIM keys
provision_resumeResume from where you left off (phased wizard)
provision_statusWhich phases complete, what's next
add_sending_domainAdd customer domain, get 4 DNS records
list_sending_domainsAll domains with verification status
create_mailboxCreate local mailbox (sales@, support@, etc.)
setup_autonomous_securityGenerate DKIM/SPF/DMARC
get_dns_recordsAll required DNS records for a domain
verify_autonomous_setupTest DNS, DKIM, SMTP end-to-end
start_health_monitorTunnel + SMTP + DNS + IP reputation checks

Infrastructure

ToolDescription
list_cloud_providersPricing: OVH $3/mo, Vultr $2.50/mo, Hetzner $3.79/mo, DO $4/mo
regenerate_zone_fileFull CoreDNS zone with all customer subdomains
request_email_ipWireGuard IP provisioning queue

Architecture

                     ┌─────────────────────────────┐
                     │     Cloud VPS ($3/mo)        │
                     │                               │
Internet ──► port 25 ──► WireGuard ──────────────────┼──► Your Machine
                     │     ▲                         │     │
                     │     │ CoreDNS (port 53)       │     ▼
                     │     │ Let's Encrypt TLS       │   EmailMCP
                     │     │ iptables forwarding     │   ├── SMTP Receiver
                     └─────┼─────────────────────────┘   ├── Mailbox Store
                           │                              ├── Rules Engine
                           │                              ├── DKIM Signer
                      WireGuard                           ├── MCP Server
                      Tunnel                              └── Local API :41924
                           │
                     ┌─────┼───────┐
                     │  Your Machine│
                     │              │
                     │  Claude/     │
                     │  Cursor/     │◄──── MCP Protocol
                     │  Codex       │
                     └──────────────┘

Inbound: Internet → VPS port 25 → WireGuard → your machine → mailbox store → AI reads via MCP

Outbound: AI sends via MCP → DKIM signed → WireGuard → VPS clean IP → recipient MX

DNS: VPS runs CoreDNS as authoritative nameserver for your service domain


Provisioning Flow (Phased Wizard)

No chicken-and-egg. Each phase waits for its prerequisites:

PhaseWhat happensUser action
1Create VPS, get IP, generate WireGuard configNone (automatic)
2Verify WireGuard tunnelsudo wg-quick up ~/.emailmcp/wg-email.conf
3Show DNS records (now we have the real IP)Add 2 records at registrar
4Verify DNS, obtain Let's Encrypt certNone (automatic after propagation)
5Full verification: tunnel + SMTP + DNSNone (automatic)

State saved to ~/.emailmcp/provision-state.json. Run provision_resume after each action.


API Docs

When the local API is running (autonomous mode), Swagger UI is at:

http://127.0.0.1:41924/api-docs

Raw OpenAPI spec: http://127.0.0.1:41924/api-docs/swagger.json

Covers both the REST API and all MCP tools.


Development

git clone https://github.com/nfodor/emailmcp.git
cd emailmcp && npm install
npm test                     # 1266 tests, 103 sections
npm run test:watch           # Auto-rerun on changes

Test categories

CategoryTests
Core (Config, Logger, RateLimiter, UsageTracker)96
Provider Factory & Base107
IMAP Reader73
Email Auth (DKIM/SPF/DMARC)15
Threading & SMTP Forwarding137
Templates25
SMTP Provider22
Multi-Account IMAP14
Autonomous Provider24
Mailbox Store36
DNS Records29
Rules Engine57
IMAP IDLE14
Cloud Provisioning30
Sending Domain Manager34
DKIM Sign/Verify (real SMTP)32
SPF Validation (simulated)15
DMARC Alignment (simulated)24
Full Chain (DKIM→SPF→DMARC)18
E2E: Real SMTP → Store → MCP80
E2E: Rules (enterprise patterns)71
Total1266

E2E tests run real SMTP servers, send real emails via nodemailer, fire real rules, and verify the full pipeline. No mocks.

See CONTRIBUTING.md for how to write tests and add features.


Cloud Provider Pricing

ProviderPlanPricePTRDNS
OVHd2-2€3/monativenative (subdomain delegation)
Vultrvc2-1c-1gb$2.50/monative
Hetznercx22€3.79/monative
DigitalOceans-1vcpu-512mb$4/movia namevia DO DNS

All you need is WireGuard on the VPS. The cheapest VM handles it.


Troubleshooting

ProblemFix
AI doesn't see email toolsRestart client after config change
WireGuard won't connectCheck VPS firewall allows UDP 51820
DNS not propagatingWait up to 60 min. Run provision_resume to re-check.
DKIM failingRun setup_autonomous_security to regenerate keys
Emails going to spamCheck IP reputation: get_health_status shows blocklist checks
Rate limit hitAdjust RATE_LIMIT_HOURLY / RATE_LIMIT_DAILY in .env
IMAP connection failsUse app-specific password. Check port 993.

Backstory: Why I built this

I wrote my first Windows email client in 1992, when internet email was barely a thing. Three decades later, email is still the only truly decentralized communication protocol that survived.

But email got captured. SendGrid, Mailgun, SES — they're great products, but you're sending through someone else's infrastructure, on their shared IPs, under their rules. Your deliverability depends on their reputation.

AgenticEmailService gives you the SendGrid experience — DKIM, SPF, DMARC, dedicated IP, domain authentication — but self-hosted. One cheap VPS, one WireGuard tunnel, full control. Your AI provisions it, manages it, and sends through it.

Email deserves to be sovereign again. This is one step toward that.


License

MIT — use it however you want.


Built by nfodor • Powered by MCP


Reviews

No reviews yet

Sign in to write a review