mail-mcp

by tecnologicachile

41 stars
246 downloads
Not rated
GitHub

Description

Most email MCP servers only read from IMAP. mail-mcp does everything: 30 tools for reading, searching, sending, replying, forwarding, and bulk operations across IMAP, SMTP, Microsoft Graph API, and Exchange Web Services. Multi-account, native OAuth2, built in Rust. Works with…

About

Most email MCP servers only read from IMAP. mail-mcp does everything: 30 tools for reading, searching, sending, replying, forwarding, and bulk operations across IMAP, SMTP, Microsoft Graph API, and Exchange Web Services. Multi-account, native OAuth2, built in Rust. Works with Gmail, Microsoft 365, Hotmail/Outlook.com…

Details

Author
tecnologicachile
GitHub stars
41
Downloads
246
Categories
Communication, Automation, Productivity, Other

- 18 IMAP read/write tools (vs. 3–5 typical)
- SMTP send, reply, forward with multipart support
- Microsoft Graph API and Exchange Web Services
- Native OAuth2 for XOAUTH2 authentication
- Multi-account and multi-provider configuration
- 64 unit + integration tests, zero release-build warnings

<p align="center">
<h1 align="center">mail-mcp</h1>
<p align="center">
<strong>Production-ready email MCP server for AI agents</strong><br>
IMAP + SMTP + EWS + Microsoft Graph API — built in Rust
</p>
<p align="center">
<a href="https://github.com/tecnologicachile/mail-mcp/releases">Release</a>
<a href="LICENSE">License</a>
<a href="https://github.com/tecnologicachile/mail-mcp/stargazers">Stars</a>
</p>
</p>

---

Most email MCP servers only do IMAP reads. This one does everything: read, search, send, reply, forward, bulk operations, Microsoft Graph API, and Exchange Web Services — with real OAuth2, multi-account, and multi-provider support. Written in Rust for speed and safety.

What's New in v0.4.8

- SAVE_SENT is now per-account with a provider-aware default.
Previously, saving a copy of outgoing mail to the Sent folder via IMAP
APPEND was controlled by a single global flag, MAIL_SMTP_SAVE_SENT. The
problem: providers that already save sent mail server-side (Gmail,
Zoho) ended up with two identical copies in Sent, while a generic SMTP
server or Office 365 (which do not auto-save on SMTP submission) lost
the copy entirely when the flag was false.
- Provider-aware default (when nothing is configured):
- Gmail (smtp.gmail.com): saves server-side and deduplicates by
Message-ID → the MCP does not append (false).
- Zoho (smtp.zoho.com): saves server-side but does not
deduplicate → the MCP does not append (false), avoiding the
duplicate.
- Office 365 / generic SMTP: do not auto-save on SMTP submission →
the MCP does append (true), or the sent copy would be lost.
- Per-account override: MAIL_SMTP_<ID>_SAVE_SENT=true|false takes
priority over everything. The global MAIL_SMTP_SAVE_SENT still works as a
coarse override (wins over the provider default, loses to the per-account
override).
- Precedence: per-accountglobalprovider-aware default.

| Provider | Auto-saves server-side | MCP default |
|---|---|---|
| Gmail | Yes (with dedupe) | false |
| Zoho | Yes (no dedupe) | false |
| Office 365 (SMTP) | No | true |
| Generic SMTP / relays | No | true |

What's New in v0.4.7

- Critical fix — graph_send_message silently dropped attachments on
threaded replies.
When called with in_reply_to + attachments, the
createReply → PATCH → send flow included the attachments in the PATCH
against /me/messages/{id}. Microsoft Graph treats Message.attachments
as a navigation property and silently discards the field on PATCH
(2xx response, no error), so the message went out as single-part
text/html with no file. The MCP returned status: ok and the caller
assumed success. Invisible data loss.
- The fix: in send_via_reply(), attachments are now uploaded one by one
to POST /me/messages/{draft_id}/attachments between the PATCH and the
send. Files < 3 MB go inline (JSON with base64 contentBytes); files
≥ 3 MB use createUploadSession with 4 MB chunked PUTs. The attachments
field was removed from the PatchDraftRequest struct so the regression
cannot be reintroduced by a type-correct edit.
- No change to flows that already worked. send_via_sendmail (new
messages without in_reply_to) uses POST /me/sendMail with attachments
inline in the JSON — Graph DOES accept the field on that endpoint and never
dropped it. That path is untouched.
- Regression test added: patch_draft_request_never_serializes_attachments
fails if anyone re-adds the field to the struct.
- Reference: BUG_GRAPH_ATTACHMENTS.md at the repo root documents the
full reproduction, root cause, and the empirical evidence behind the fix.

What's New in v0.4.6

- Server-side enforcement of HARD RULE #1. Three releases of prompt-only
hardening (v0.4.3 → v0.4.4 → v0.4.5) still left LLMs occasionally leaking
literal </body_text><parameter name="body_html"> markup into the
recipient's inbox. v0.4.6 adds a real validator that rejects the tool
call before any SMTP / Graph / EWS attempt if body_text or body_html
contains tool-call wrapper syntax. The check is wired into all 5 send
paths (smtp_send_message, smtp_reply_message, smtp_forward_message,
graph_send_message, ews_send_message).
- The forbidden markers are case-insensitive and tightly scoped — only
the pseudo-tags that have no legitimate use in human correspondence:
<body_text>, </body_text>, <body_html>, </body_html>,
<function_calls>, </function_calls>, <invoke name=, </invoke>,
and <parameter name="body_*">. Generic technical content that happens
to mention <parameter> for an XML schema or <invoke> in a code
example still passes.
- HARD RULE #1 wording updated to announce the server-side rejection,
so the LLM knows it's a hard contract — not a suggestion it can ignore.
- No breaking changes for clean callers: well-behaved messages send
exactly as before.

What's New in v0.4.5

- serverInfo now reports name="mail-mcp" + the crate version (the
framework previously returned its own rmcp 0.16.0, which never changes
between releases). Useful for verifying the active version with /mcp, and
so any client-side cache keyed by (server, version) invalidates on each bump.
- MCP instructions reorganized: the 3 critical anti-concatenation rules
(which in v0.4.3 and v0.4.4 sat at the end of the block and could be lost
to truncation / diluted attention) now appear as HARD RULE #1, #2, #3 at
the TOP
, right after the title. Consolidated into 3 short paragraphs
(previously 3 long sections, ~1500 characters combined).
- No functional changes to the server. Same SMTP/IMAP/EWS/Graph, same
tool set, same behavior. Only the text exposed to the client changed.

Important for these rules to take effect

Clients that resume a session with claude --continue (or /resume) do
NOT refresh the MCP system_prompt — they keep the one from that
session's first handshake. If your session predates v0.4.5, the rules won't
reach your context even if the on-disk binary is updated. To receive them,
start a NEW session in the project (not --continue).

What's New in v0.4.4

- Preview hygiene rule in MCP instructions: when the LLM shows the
user the email preview before sending, it should render ONE clean
version of the body (markdown-style bullets, bold, links as text + URL)
and state that the message will go multipart — but it must NOT dump
the raw HTML source (<p>, <strong>, <a href>...) into the
preview. Two reasons:
1. The human reviewer wants to read the message, not audit markup —
showing the HTML is noise.
2. Exhibiting both the plain-text string AND the HTML string side by
side in the preview is exactly the context that has historically
led LLMs to concatenate them in the eventual tool call (the bug
v0.4.3 documented). Hiding the HTML source from the preview
removes the temptation.

Complements the PREVIEW DOES NOT EQUAL TOOL CALL rule introduced
in v0.4.3.

What's New in v0.4.3

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.