Agent Mail Gateway — Claude Code MCP server: setup and features
A self-hosted Docker proxy that gives AI assistants controlled access to mailboxes. It filters contacts, converts email to Markdown, and checks outgoing drafts.
Open on GitHubWhat Agent Mail Gateway does
The service operates as a single Docker container sitting between your AI assistants and your standard mail server. Rather than exposing raw IMAP or SMTP passwords, you issue an isolated API token tied to a single address. The gateway strips heavy HTML and delivers incoming text as Markdown, trimming prompt size.
Protection applies in both directions. Incoming mail undergoes virus scans, spoofing checks, and prompt injection filters before the agent ever sees it. Before an outgoing message leaves, built-in heuristics catch missing attachments, blank bodies, and unresolved placeholders. You can also connect a local model via Ollama to evaluate outgoing tone and enforce custom communication guidelines.
Never attach your personal inbox to this gateway: unapproved senders get moved to the trash folder automatically. Each assistant needs a dedicated address on your mail domain.
What it helps with
- Restrict agent access to a single inbox using dedicated API keys instead of server passwords
- Convert incoming rich emails into Markdown to reduce context token consumption
- Intercept outgoing messages containing missing attachments, empty bodies, or leftover draft markers
- Process and respond to calendar invites across common email clients
- Inspect inbound correspondence for prompt injections, suspicious attachments, and forged senders
Example prompts for the agent
- Check for any unread incoming messages from approved senders and summarize them in Markdown.
- Draft a reply to the latest thread, attach
report.csv, and run the safety checks before sending. - Send a meeting invitation for tomorrow at 15:00 UTC to the project team and track their replies.
How to install Agent Mail Gateway
Install
The MCP registry has no launch command for it: see the repository README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Agent Mail Gateway
How do you deploy Agent Mail Gateway?
Run the service container via Docker Compose using docker-compose.yml, config.yaml, and .env. Then point your MCP client to the gateway over Streamable HTTP or through the stdio bridge.
Why avoid giving an agent direct IMAP and SMTP credentials?
Handing raw credentials lets the model access your entire inbox, exposing data to prompt injections from unknown senders. The gateway isolates the agent to a single mailbox with an individual API key and applies strict sender allowlists.
What checks does the gateway run before an email leaves?
It stops accidental duplicate sends, empty messages, and emails that reference an attachment without one attached. You can also enforce custom natural-language policies or hook in a local LLM to review outgoing text.