email-mcp
Health Pass
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 28 GitHub stars
Code Fail
- process.env — Environment variable access in scripts/funding.mjs
- network request — Outbound network request in scripts/funding.mjs
- network request — Outbound network request in site/demo/scrollcraft.js
- os.homedir — User home directory access in src/auth/credential-store.ts
- process.env — Environment variable access in src/auth/credential-store.ts
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Unified MCP server for email access across Gmail, Outlook, iCloud, and IMAP
email-mcp
![]()
Give your AI assistant an inbox, not a screenshot. email-mcp is an open source Model Context Protocol (MCP) server that lets Claude Code, Claude Desktop, Cursor or any other MCP client search, read, draft, send and clean up mail in Gmail, Outlook, iCloud and any IMAP mailbox. It runs on your own machine and talks straight to your provider: there is no server of ours in between, and no account to create.
Who it is for: people who already work with an AI assistant and spend too much time in their inbox. Typical jobs: "find the invoice from March and save the PDF", "draft replies to the three people waiting on me", "archive every newsletter older than a week", "move this thread from my old Outlook into Gmail".
What makes it different
- Four providers, one tool set. 36 tools over the Gmail API, Microsoft Graph, iCloud and generic IMAP, so one assistant works across a work Gmail, a private iCloud and an old Outlook at once.
- Local only. Credentials stay on your machine, encrypted at rest (AES-256-GCM, Advanced Encryption Standard) in
~/.email-mcp. - Built for real inboxes. Batch tools take up to 1,000 messages per call on Gmail; search returns compact headers by default (about 20 KB instead of 1.4 MB for the same results);
email_transfermoves mail between accounts with the original sender, date and thread intact. - Guardrails against mail that talks to your assistant. A message can ask an assistant to attach a private file or forward your mail elsewhere. Files are only attached from one folder you name, and forwarding rules only reach addresses you allow-list, both set in the server's environment where no tool can change them.
- Writes like a mail client. Replies stay in their thread, Gmail adds your signature, and From carries your display name.
Try it in five minutes
Tested on 3 December 2026 with Node.js 22 from an empty home directory: the published package installs, starts, and lists its 36 tools to an MCP client.
1. Add a mailbox. The wizard asks for the provider and signs you in:
npx -y @marlinjai/email-mcp@latest setup
The quickest accounts to connect are iCloud (with an app-specific password), Outlook (browser sign-in) and any IMAP mailbox. Gmail works too, but until Google finishes verifying the shared sign-in it only admits accounts on its test list, so most people use their own Google Cloud OAuth client for now (how).
2. Connect your assistant. In Claude Code:
claude mcp add email -- npx -y @marlinjai/email-mcp@latest
Any other MCP client takes the same command in its config file (.mcp.json, claude_desktop_config.json, Cursor's mcp.json):
{
"mcpServers": {
"email": {
"command": "npx",
"args": ["-y", "@marlinjai/email-mcp@latest"]
}
}
}
3. Ask something that only reads.
List my email accounts, then show me the five newest unread messages in my inbox. Don't change anything.
The assistant calls email_list_accounts and then email_search with unreadOnly: true and limit: 5, and you get sender, subject and date for each, without the bodies.
Start read-only
email-mcp has no read-only switch of its own: what an assistant may do is decided by the client. In Claude Code, this project or user settings.json removes every tool that sends, deletes, moves, marks or changes rules, so only the 13 reading tools are left (checked with Claude Code 2.1: the denied tools are gone from the session, even in bypass permissions mode):
{
"permissions": {
"deny": [
"mcp__email__email_add_account", "mcp__email__email_remove_account",
"mcp__email__email_send", "mcp__email__email_reply", "mcp__email__email_forward",
"mcp__email__email_draft_create", "mcp__email__email_draft_update",
"mcp__email__email_move", "mcp__email__email_transfer", "mcp__email__email_delete",
"mcp__email__email_mark", "mcp__email__email_label", "mcp__email__email_folder_create",
"mcp__email__email_batch_delete", "mcp__email__email_batch_move",
"mcp__email__email_batch_mark", "mcp__email__email_batch_label",
"mcp__email__email_report_spam", "mcp__email__email_batch_report_spam",
"mcp__email__email_create_block_rule", "mcp__email__email_delete_block_rule",
"mcp__email__email_create_forward_rule", "mcp__email__email_delete_forward_rule"
]
}
}
The names assume the server is registered as email. Remove lines from the list as you start trusting the assistant with more. On Gmail, the wizard's Restricted scope additionally rules out permanent deletion at Google's end (it still allows sending).
Demo
email.lumitra.co/demo walks through a working session on an invented inbox (every address is on an example domain): finding which messages need a reply across four accounts, archiving 312 newsletters in one call, and three standing block rules for senders you never open, with each tool call shown as it happens.
A typical exchange, with invented data:
You: Archive every newsletter older than a week, and block the three senders I never open.
Assistant: (calls
email_search, thenemail_batch_movewith 312 ids, thenemail_create_block_rulethree times) Moved 312 messages to Archive in one call; your inbox is at 936. Three standing rules created for [email protected], [email protected] and [email protected], so their mail no longer reaches the inbox; each rule can be listed or deleted later.
Using npx with the setup command
npx -y @marlinjai/email-mcp@latest setup and npx -y -p @marlinjai/email-mcp@latest email-mcp-setup both start the wizard. Do not run npx email-mcp-setup without -p: the package declares two programs (email-mcp, the server, and email-mcp-setup, the wizard), and without -p npx starts the server and passes the name on as an ignored argument. The server then waits for MCP input on stdin and prints nothing, which looks exactly like a hang.
After each account the wizard asks whether to add another, so Gmail, Outlook and iCloud can be set up in one go.
Provider Setup Guides
Gmail
No configuration needed — the setup wizard handles everything using built-in OAuth credentials (PKCE):
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "Gmail" when prompted
# Choose "Full" or "Restricted" permission scope when asked
# A browser window opens for Google authorization
# Grant the requested permissions and return to the terminal
The wizard asks which Gmail permission scope to authorize:
- Full (default) — everything below, plus immediate, Trash-bypassing permanent deletion (
https://mail.google.com/, Gmail's maximum-permission scope). - Restricted — read, send, label, archive, and move-to-trash (
gmail.modify+gmail.settings.basic), but no permanent deletion. Every tool in this server works identically under Restricted except an explicitpermanent: truedelete, which fails with a Gmail API error instead of succeeding.
Pass --scope full or --scope restricted to skip the prompt, or set EMAIL_MCP_GMAIL_SCOPE=restricted in the environment the wizard runs in.
Verification status (1 October 2026): Google's review of the shared OAuth app is still running, so Google currently only lets accounts on its test-user list sign in through it; everyone else sees the "has not completed the Google verification process" screen and needs their own OAuth app (next note). The last open step for the shared app is a yearly independent security assessment (CASA, Cloud Application Security Assessment) that Google has requested. Because email-mcp has no server of its own, its applicability is being clarified with Google. Details and current status: email.lumitra.co/privacy#google-verification, tracked in issue #1.
Note: If you prefer to use your own OAuth app instead of the shared one this package ships with, create a Desktop OAuth 2.0 Client in the Google Cloud Console with the Gmail API enabled, then set
EMAIL_MCP_GMAIL_CLIENT_IDandEMAIL_MCP_GMAIL_CLIENT_SECRETin the environment before running the setup wizard (and in the MCP server's environment, since re-authentication uses the same variables). This gives you your own token lifecycle, independent of the publisher's Cloud project, and sidesteps Google's unverified-app warning and 100-test-user cap for your own account(s) once you add yourself as a test user on your own app.
Outlook
No configuration needed — the setup wizard handles everything using built-in OAuth credentials (PKCE):
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "Outlook" when prompted
# A browser window opens for Microsoft authorization
# Sign in and grant the requested permissions
Note: If you prefer to use your own OAuth app, register one in the Azure Portal with
Mail.ReadWrite,Mail.Send,MailboxSettings.ReadWrite(needed foremail_create_block_rule), andoffline_accesspermissions, then setEMAIL_MCP_OUTLOOK_CLIENT_IDin the environment before running the setup wizard.
iCloud
- Go to appleid.apple.com and sign in.
- Navigate to App-Specific Passwords and generate a new password.
- Run the setup wizard:
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "iCloud" when prompted
# Enter your iCloud email address
# Enter the app-specific password you generated
Generic IMAP
Run the setup wizard with your IMAP/SMTP server details:
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "Other IMAP" when prompted
# Enter your IMAP host, port, and credentials
# Optionally enter SMTP host and port for sending
Available Tools (36)
Account Management (4)
| Tool | Description |
|---|---|
email_list_accounts |
List all configured accounts with connection status |
email_add_account |
Add a new IMAP or iCloud account (Gmail/Outlook require setup wizard) |
email_remove_account |
Remove an account and its stored credentials; revokes the Google grant for Gmail, removes Outlook tokens from the local token cache, and reports the outcome |
email_test_account |
Test connection to an account |
Reading & Searching (6)
| Tool | Description |
|---|---|
email_list_folders |
List all folders/labels for an account |
email_search |
Search emails with filters. Returns compact results by default (returnBody=false). Set returnBody=true to include full email bodies |
email_get |
Get full email content by ID (headers, body, attachment metadata). sourceFolder names the folder on iCloud/IMAP when the message is not in INBOX |
email_get_thread |
Get an entire email thread/conversation. On iCloud/IMAP a thread is searched in one folder: INBOX, or the one named in sourceFolder |
email_get_attachment |
Download a specific attachment by ID (returns base64 data). sourceFolder names the folder on iCloud/IMAP when the message is not in INBOX |
email_save_attachment |
Download an attachment directly to disk, returning metadata only, which avoids the token cost of round-tripping large files as base64. outputPath is relative to a fixed downloads directory (~/.email-mcp/downloads, override with EMAIL_MCP_DOWNLOADS_DIR) and cannot escape it. sourceFolder as on email_get_attachment |
Sending & Drafts (6)
email_send, email_reply, email_forward, email_draft_create and email_draft_update take an optional attachments list. Each entry is either { path } (a file in the attachments folder, see below) or { content, filename } (base64), with an optional contentType (inferred from the extension otherwise). The total is capped at 25 MB; Outlook accepts up to 3 MB per message through this server. On email_draft_update a list replaces the draft's files, an empty list removes them, and no list keeps the files the draft has.
Gmail adds your signature, like Gmail's own editor. The Gmail API never appends one, so email_send, email_reply, email_forward, email_draft_create and email_draft_update read the signature of the send-as address the mail goes out from (Gmail settings, read on every call, so a changed signature applies at once) and add it in Gmail's own markup (gmail_signature), above any quoted history, plus a plain-text rendering in the text part. A text-only body gains an HTML part for it, as the signature's logo and links only exist as HTML. A body that already holds a signature (a gmail_signature block, or a -- line in text) is left alone, so passing a draft's body back to email_draft_update never stacks a second one. signature: false turns it off for one call. Each of these tools returns a signature field saying what happened: added, already_present, disabled, none_configured, unsupported, or skipped with the reason (for example a missing permission); a failed read never blocks the mail or draft.
Outlook, iCloud and IMAP add no signature. Microsoft Graph has no signature API for Outlook.com accounts (signatures live in the Outlook clients, out of reach for a server), and an IMAP or iCloud server keeps no signature at all. The tools report unsupported there instead of inventing one; put the signature in the body when the mail needs it. A signature stored in email-mcp's own account settings was considered and left out on purpose: it would be a second copy that drifts from the one in the mail client, which is exactly how old mail ends up with an outdated signature.
From names you. The From header carries a display name, not just the address: on Gmail the send-as display name from Gmail's settings, otherwise the account's name in email-mcp (unless that is only a label: a provider name such as "Gmail" or "iCloud", or the address's local part such as "founder"). Gmail often keeps no display name for an account's primary address (its web editor then uses the Google profile name, which this server cannot read); set one under Settings, Accounts, "Send mail as", edit info, and the tools use it. This also holds for a draft sent later from another mail program, which keeps the draft's From. Outlook sets From itself.
Replies stay in their thread: email_reply sends inside the original conversation on Gmail and Outlook (and sets the In-Reply-To and References headers everywhere), email_draft_create with inReplyToEmailId saves a reply draft in that thread, and email_draft_update keeps a reply draft there.
Forwarding the original message's attachments is opt-in. email_forward sends the text of the original; its files go along only with includeOriginalAttachments: true, so one call does not pass files the assistant never looked at on to another address. Forwarded files count against the 25 MB cap together with added ones.
Attaching files by path is off until you name a folder. The path comes from the assistant, and an assistant that reads mail can be asked by a mail to attach something it should not (a private key, for example). So files are only read from the one folder you set in EMAIL_MCP_ATTACHMENTS_DIR, in the environment of the server; no tool can change it. Put the file there and ask for it by name:
{
"mcpServers": {
"email": {
"command": "npx",
"args": ["-y", "@marlinjai/email-mcp@latest"],
"env": { "EMAIL_MCP_ATTACHMENTS_DIR": "~/Documents/email-outbox" }
}
}
}
A path outside that folder is refused, as is a symbolic link that leads out of it, and email-mcp's own data files are never attachable.
| Tool | Description |
|---|---|
email_send |
Compose and send a new email (to, cc, bcc, subject, body, attachments) |
email_reply |
Reply to an email in its thread. replyAll addresses the sender and all To/Cc recipients except your own address, each once. Optional to/cc/bcc overrides and additionalRecipients, e.g. when replying to your own sent message. Attachments supported. sourceFolder names the folder on iCloud/IMAP when the message is not in INBOX |
email_forward |
Forward an email to new recipients (to, cc, bcc, optional text on top, attachments). The original's attachments are left out unless includeOriginalAttachments: true. sourceFolder names the folder on iCloud/IMAP when the message is not in INBOX |
email_draft_create |
Save a draft without sending (attachments supported). inReplyToEmailId saves it as a reply inside that message's thread (inReplyToSourceFolder names that message's folder on iCloud/IMAP when it is not in INBOX) |
email_draft_update |
Update an existing draft in place. A reply draft stays in its thread. On Gmail/Outlook the draft id is unchanged; on iCloud/generic IMAP there's no in-place update (IMAP messages are immutable), so the old draft is deleted and a new one appended: the returned id is a new id, always use it going forward |
email_draft_list |
List all drafts |
Organization (8)
| Tool | Description |
|---|---|
email_move |
Move an email to a different folder. Supports sourceFolder for IMAP/iCloud |
email_transfer |
Move or copy emails between accounts, preserving the original message (sender, date, threading) via raw MIME transfer. deleteAfter=true trashes the source only after a confirmed import (safe cross-account move) |
email_delete |
Delete an email (trash or permanent). Supports sourceFolder for IMAP/iCloud |
email_mark |
Mark as read/unread, starred, or flagged. Supports sourceFolder for IMAP/iCloud |
email_label |
Add/remove labels (Gmail only) |
email_folder_create |
Create a new folder |
email_get_labels |
List all labels with counts (Gmail only) |
email_get_categories |
List all categories (Outlook only) |
Batch Operations (4)
| Tool | Description |
|---|---|
email_batch_delete |
Delete multiple emails at once (up to 1000 for Gmail, batches of 20 for Outlook, UID ranges for IMAP) |
email_batch_move |
Move multiple emails to a folder in a single call |
email_batch_mark |
Mark multiple emails read/unread, starred, or flagged at once |
email_batch_label |
Add or remove labels on multiple emails at once (native batch call on Gmail, one by one elsewhere) |
All batch tools accept a sourceFolder parameter for IMAP/iCloud and include a sequential fallback for maximum compatibility.
Spam Moderation (5)
| Tool | Description |
|---|---|
email_report_spam |
Report an email as spam/junk, training the provider's own filter — the same signal the "Report Junk" button sends in Gmail/Outlook. This is different from email_delete, which removes the message but teaches the filter nothing. Not an abuse report to the provider's security team; it only trains this account's filter |
email_batch_report_spam |
Report multiple emails as spam/junk at once |
email_create_block_rule |
Create a standing rule that intercepts future mail matching a pattern (sender domain/address, subject, or arbitrary header content) and either deletes it or moves it. Use headerContains (e.g. a Reply-To domain) to block a spam template family whose visible "From" domain rotates — matching the rotating domain directly stops working within days. Not supported on iCloud/generic IMAP (no standard server-side rule mechanism exists across IMAP servers). On Outlook, moveToJunk files straight to the Junk Email folder and requires the MailboxSettings.ReadWrite scope. On Gmail, moveToJunk skips the inbox (archives) rather than literally filing to Spam — Gmail's filter API rejects the SPAM label on standing rules (only Gmail's own classifier can apply it; email_report_spam still can, since that's a direct per-message action, not a filter) — and requires the gmail.settings.basic scope. Accounts authenticated before these scopes existed need to re-run the setup wizard once to re-consent |
email_list_block_rules |
List the standing block rules on an account, for auditing or before deleting one |
email_delete_block_rule |
Delete a standing block rule — use to undo a rule that turned out too broad |
Gmail and Outlook only for the rule tools; email_report_spam/email_batch_report_spam work on every provider (iCloud/IMAP fall back to a best-effort move into the account's Junk-typed folder, with no vendor ML training signal since generic IMAP has none to train).
Forwarding Rules (3)
| Tool | Description |
|---|---|
email_create_forward_rule |
Create a standing rule that forwards future mail matching a pattern (sender domain/address, subject, or header content) to another address, for example vendor invoices to a bookkeeping address. The original stays in the inbox unless keepInInbox is false. Creating the same rule twice returns the existing one |
email_list_forward_rules |
List every rule on an account that forwards mail elsewhere, including rules made by hand in Gmail or Outlook: an audit of where mail is being sent |
email_delete_forward_rule |
Delete a forwarding rule by id |
Gmail and Outlook only. iCloud and generic IMAP have no server-side rule mechanism; set the rule in the provider's own settings there.
Forwarding is off until you allow a target. A standing forward rule copies future mail out of your mailbox, and an assistant that reads mail can be asked to create one by the mail it reads. So email_create_forward_rule only accepts addresses you listed yourself in EMAIL_MCP_FORWARD_ALLOWLIST (comma-separated), in the environment of the server. No tool can change that list:
{
"mcpServers": {
"email": {
"command": "npx",
"args": ["-y", "@marlinjai/email-mcp@latest"],
"env": { "EMAIL_MCP_FORWARD_ALLOWLIST": "[email protected]" }
}
}
}
On Gmail the target must also be a forwarding address of the account: add it once under Gmail Settings, "Forwarding and POP/IMAP", "Add a forwarding address", and confirm the email Google sends to it. Outlook needs no such step, which is why the allowlist exists. Outlook accounts authenticated before the block-rule tools existed need to re-run the setup wizard once, as for those tools.
More things to ask
Once connected (see Try it in five minutes), ask in plain words:
- "Check my inbox for unread messages"
- "Search for emails from [email protected] in the last week"
- "Reply to the latest email from Bob and thank him"
- "Move all newsletters to the Archive folder"
- "Delete all spam emails" (uses batch operations for speed)
- "Draft a follow-up email to the team about the meeting"
Development
# Install dependencies (the repository uses npm and package-lock.json)
npm ci
# Build the project
npm run build
# Run in development mode (watch for changes)
npm run dev
# Typecheck and run the tests (what continuous integration runs)
npm run typecheck
npm test
# Run tests in watch mode
npm run test:watch
# Run integration tests (requires real email accounts)
npm run test:integration
Credential Storage
Account credentials are encrypted at rest with AES-256-GCM in ~/.email-mcp/credentials.enc.
By default the encryption key is derived from a stable, machine-specific identifier
(the hardware UUID on macOS, /etc/machine-id on Linux, or the MachineGuid on
Windows), falling back to the hostname when none is available.
Set the EMAIL_MCP_KEY environment variable to supply your own passphrase instead.
This is recommended when the machine identifier may change (for example in
containers or CI), or when you want to move credentials.enc between machines:
export EMAIL_MCP_KEY="your-strong-passphrase"
When EMAIL_MCP_KEY is set, existing credential files are transparently
re-encrypted with the passphrase the next time they are read.
The Outlook refresh token lives in the token cache of Microsoft's authentication
library (MSAL), ~/.email-mcp/msal-cache.enc, encrypted with the same scheme and key
derivation as credentials.enc, so EMAIL_MCP_KEY protects both files. Versions before 1.8.0
kept this cache as plain JSON in ~/.email-mcp/msal-cache.json; 1.8.0 encrypts it and
deletes the plain file the first time it reads it, without signing you out. Going back
to an older version afterwards means signing in to Outlook again.
On macOS and Linux, attachments saved with email_save_attachment are written
owner-only (0600), and folders email-mcp creates for them are 0700. They are not
encrypted.
The OAuth sign-in callback started by email-mcp-setup listens on the loopback
addresses only (127.0.0.1, and ::1 when available), so nothing else on your network
can reach it.
Sending to a list?
email-mcp handles your own inbox. To reach a whole list, Lumitra Mail, from the same maker, does newsletters and product mail through your own sending provider, with a visual editor, one-click unsubscribe and contacts on servers in Germany. Free for up to 6,000 messages a month.
Support
email-mcp is free and has no paid tier. Its one fixed cost is the independent security assessment Google requires every year for the shared Gmail sign-in (CASA, Cloud Application Security Assessment): 675 US dollars a year. It is the last open step before Google lets everyone use the one-command Gmail setup. The project is not funded for it yet, so the assessment starts once donations reach that amount; until then Gmail needs your own Google Cloud project (see the note in the Gmail section). Progress is shown at email.lumitra.co.
License
MIT
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found
