Secure IMAP/SMTP/EWS/Graph API MCP server in Rust — Microsoft 365, Hotmail, Gmail, Zoho, OAuth2, multi-account
# Add to your Claude Code skills
git clone https://github.com/tecnologicachile/mail-mcpmail-mcp is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by tecnologicachile. Secure IMAP/SMTP/EWS/Graph API MCP server in Rust — Microsoft 365, Hotmail, Gmail, Zoho, OAuth2, multi-account. It has 124 GitHub stars.
mail-mcp's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/tecnologicachile/mail-mcp" and add it to your Claude Code skills directory (see the Installation section above).
mail-mcp is primarily written in Rust. It is open-source under tecnologicachile on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh mail-mcp against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
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.
For hosts that own the OAuth2 sign-in and launch mail-mcp once per request.
Existing configurations behave as before.
MAIL_OAUTH2_<ID>_ACCESS_TOKEN takes a host-managed access token. It is
used as is for IMAP and SMTP XOAUTH2 and never refreshed, so the host keeps
the refresh token (which Microsoft rotates on every refresh) and passes a
fresh access token on each launch. With it, CLIENT_ID and REFRESH_TOKEN
are optional. An expired or rejected token is an auth_failed error that
names the variable; the token never appears in logs or errors. Environment
or .env only, not a TOML field.CLIENT_SECRET is optional. Missing or empty means a public client: the
refresh request sends no client_secret, as none already did.auth_failed, with the server
text kept, for example Gmail's [ALERT] Application-specific password required. These used to be reported as internal errors.imap_verify_account now says "Account verification failed" in its summary
when the check fails, instead of always reporting success.RUST_LOG=trace no longer writes IMAP passwords or tokens to the log.
async-imap traces every command on the wire, so it is now capped at debug
unless RUST_LOG names async_imap explicitly.Two opt-out settings for hosts that launch mail-mcp as an embedded
component with a fixed environment. Without them, behavior is unchanged.
MAIL_UPDATE_CHECK=false skips the startup release check. By default
the server asks the GitHub releases API for the latest version (waiting at
most 2 seconds) and adds an update notice to its instructions. Hosts that
pin the version can now turn that request off.MAIL_DOTENV=false turns off legacy .env discovery. The .env file
is searched in the working directory and every parent. With this set in the
process environment, no .env is read and none of its variables are
exported, so a stray file cannot add accounts or settings.Both accept false, 0 or off; a value that is not a boolean is a startup
error.
ProtectHome=true (and
similar sandboxes) stopped with could not read config file ~/.mail-mcp/config.toml: Permission denied. Startup now treats an
inaccessible default location like a missing file, prints a warning, and
runs from the environment as earlier releases did. Set
MAIL_CONFIG_FILE=none to skip the check. An explicit --config or
MAIL_CONFIG_FILE path that cannot be read is still an error.graph_send_message now honors MAIL_SMTP_WRITE_ENABLED. It was the
only send tool that skipped the check, so an account with a Microsoft
token carrying Mail.Send could send mail with sending turned off. If you
rely on that setting to keep an agent read-only or drafts-only, upgrade.
A test now checks that every send tool refuses when it is off.
(#45, reported by jtron9k)mail-mcp config init and mail-mcp accounts add
store accounts in ~/.mail-mcp/config.toml, outside the MCP client's JSON.
List, edit, remove, and run read-only connection tests from the CLI.
Start with guided setup.
Environment variables and .env keep working as before, and extra
arguments in an MCP client entry are ignored with a warning, as they were.
(#40, by felipefdl)cargo audit advisory that
has a fix. Tools, their names and their annotations are unchanged.
(#42, by tordable)imap_search_messages and imap_search_all_mailboxes
now fetch the headers of a whole result page with one UID FETCH instead
of one per message. On high-latency servers a 50-message page went from
20-40 s to 3-9 s, and searching every mailbox is about twice as fast.
Results are unchanged.
(#44, by tdabasinskas)readOnlyHint,
destructiveHint, idempotentHint and openWorldHint. Clients that use
them can run the 14 read-only tools without asking each time. Sends,
moves and other changes are marked as writes, and deletes, flag changes,
draft_update and draft_send as destructive.
(#43, by tdabasinskas)RUST_LOG=info. At that
level the rmcp library logged every JSON-RPC response in full, which with
the HTTP transport put message subjects and bodies in the server log (the
journal, for a systemd service). When RUST_LOG sets a global level of
info or more verbose, rmcp is now capped at warn unless RUST_LOG
names it (for example RUST_LOG=info,rmcp=info while debugging). The
stdio transport did not log responses, and with RUST_LOG unset nothing
changes. If you run v0.6.0 or earlier over HTTP, set
RUST_LOG=info,rmcp=warn.https://outlook.office365.com/EWS.AccessAsUser.All with AADSTS70011
(invalid_scope). The Quickstart uses
https://outlook.office.com/EWS.AccessAsUser.All. Existing EWS tokens keep
working; this only matters when getting a new one.Nothing changes for an existing install unless you opt in.
mail-mcp-update; run it to move to the latest release in place.
Homebrew installs keep updating with brew upgrade.MAIL_OAUTH2_TOKEN_STORE to a file
path to also keep it across restarts (written 0600, never fatal if it
cannot be written). Changing the refresh token in your config always wins
over a stored one.body_text and body_html are separate fields" rule now also
appear on the send tools and body fields, for MCP gateways that do not
forward the server instructions. See
Running behind an MCP gateway
for what else changes when mail-mcp sits behind a gateway.draft_create, draft_update, draft_send,
draft_delete, draft_list) closing
#3 and
#17. An agent can
save a message in the account's own Drafts folder, revise it, and send it
later, so a person can review it in their mail client first. The same five
tools work on every backend: IMAP + SMTP, Exchange Web Services and
Microsoft Graph, picked per account (EWS config, else Graph config, else
IMAP). list_all_accounts reports the backend as drafts_with.MAIL_DRAFTS_ENABLED (default false). It is
independent of MAIL_IMAP_WRITE_ENABLED: every operation on an existing
draft_id first checks that the target really is a draft (IMAP Drafts
folder, EWS IsDraft, Graph isDraft), so enabling drafts never grants
move or delete on other mail. draft_send also requires
MAIL_SMTP_WRITE_ENABLED.Mail.ReadWrite scope for drafts; see
account setup. The EWS attachment flow
(CreateItem with SaveOnly, then CreateAttachment) follows the approach
proposed by @verdelyi in
#14.imap_search_all_mailboxes by
@tdabasinskas in
#35. Runs one search
in every selectable mailbox of an account and returns the newest matches,