email-mcp
Reads, searches, sends and organizes Gmail / Google Workspace mailboxes over IMAP and SMTP using an app password, including Gmail's native search syntax for filtering messages.
Connects to an iCloud Mail mailbox over IMAP/SMTP with an app-specific password to read, search, send and organize mail, and supports sending from a custom-domain address via EMAIL_FROM.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@email-mcp Summarize the unread emails in my work inbox from this week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🚀 Quick start
Let your AI set it up
Paste this one line into Claude Code, Codex or any assistant that can run shell commands:
Read https://raw.githubusercontent.com/a1exsun/email-mcp/main/skills/setup-email-mcp/SKILL.md and follow it to set up email-mcp for me.The setup skill clones and builds the project, works out your provider's servers from your address, writes .env, verifies the login and registers the server with your client. It never asks for a password in chat: you paste the app password into .env yourself.
Or do it by hand
Clone and build (requires Node.js ≥ 22.18):
git clone https://github.com/a1exsun/email-mcp.git && cd email-mcp && npm installCreate your configuration and fill it in (see Configuration):
cp .env.example .envCheck that every mailbox can log in to IMAP and SMTP:
node --env-file=.env dist/index.js checkConnect your client and restart it.
Related MCP server: IMAP MCP Server
🧰 Tools
Then just ask in plain language:
"Summarize the unread mail in my work inbox from this week." "Find the invoice Alice sent in October and save the PDF to ~/Downloads." "Draft a reply to the latest message from my landlord, but don't send it."
⚙️ Configuration
The server is configured through environment variables. The simplest way is a .env file loaded with Node's built-in --env-file flag; .env.example documents every variable.
1 Not needed when OUTLOOK_CLIENT_ID is set.
Several mailboxes
List a short name for each mailbox in EMAIL_ACCOUNTS, then prefix every variable with the upper-cased name:
EMAIL_ACCOUNTS=work,home
WORK_EMAIL_ADDRESS=me@company.com
WORK_EMAIL_PASSWORD=...
WORK_IMAP_HOST=imap.company.com
WORK_SMTP_HOST=smtp.company.com
HOME_EMAIL_ADDRESS=me@icloud.com
HOME_EMAIL_PASSWORD=...
HOME_IMAP_HOST=imap.mail.me.com
HOME_SMTP_HOST=smtp.mail.me.com
HOME_SMTP_PORT=587Every tool then accepts account (work or home here) and defaults to the first name in the list. Names may contain letters, digits and underscores.
📮 Providers
EMAIL_ADDRESS must be your @icloud.com address, because that is the login. Put the custom-domain sender in EMAIL_FROM:
EMAIL_ADDRESS=me@icloud.com
EMAIL_FROM="Alex <me@mydomain.com>"Microsoft disabled password login for IMAP and SMTP, so Outlook mailboxes sign in with OAuth2.
In the Azure portal → App registrations, create an app:
Supported account types: any organizational directory + personal Microsoft accounts.
Under Authentication, turn on Allow public client flows.
Under API permissions, add the delegated permissions
IMAP.AccessAsUser.AllandSMTP.Send.Copy the Application (client) ID into
OUTLOOK_CLIENT_ID.
Log in once from a terminal (device-code flow: open the link it prints and enter the code):
node --env-file=.env dist/index.js loginWith several mailboxes, add the account name:
node --env-file=.env dist/index.js login work.The token is cached in
~/.email-mcp/with permissions600and refreshes automatically.
On Microsoft 365 business accounts an administrator may need to enable SMTP AUTH for the mailbox.
🔌 Connect your client
Point your MCP client at dist/index.js and let Node load the .env file. Use absolute paths.
claude mcp add email -s user -- node --env-file=/absolute/path/to/email-mcp/.env /absolute/path/to/email-mcp/dist/index.js[mcp_servers.email]
command = "node"
args = ["--env-file=/absolute/path/to/email-mcp/.env", "/absolute/path/to/email-mcp/dist/index.js"]{
"mcpServers": {
"email": {
"command": "node",
"args": ["--env-file=/absolute/path/to/email-mcp/.env", "/absolute/path/to/email-mcp/dist/index.js"]
}
}
}You can also pass the variables through the client's own env setting instead of a .env file.
Command line
Command | Purpose |
| Start the MCP server on stdio (what your client runs) |
| Log in to IMAP and SMTP for each mailbox and report |
| One-time Outlook OAuth2 device-code login |
🔒 Safety
send_email and forward_email really send mail. Keep your client's confirmation prompt on for them, and prefer save_draft for unattended runs.
Use an app password or authorization code, never your main account password. It is stored in plain text in
.env, so keep that file private (chmod 600 .env). It is git-ignored.Nothing is deleted permanently.
delete_emailsmoves mail to Trash, anddelete_folderrefuses folders that still contain mail.Your mail stays between you and your provider. The server talks only to the IMAP/SMTP hosts you configure (and Microsoft's login endpoint for Outlook); there is no telemetry.
Email is untrusted input. A message can contain text written to manipulate an AI assistant. Review what the assistant intends to do before approving actions triggered by mail content.
🛠️ Development
npm install # install and build
npm test # run the tests (node --test, runs the .ts sources directly)
npm run build # compile to dist/Built on the official @modelcontextprotocol/sdk, imapflow, nodemailer, mailparser and @azure/msal-node.
Issues and pull requests are welcome. Please run npm test before opening a PR.
📄 License
MIT © Alex Sun
Available Tools
13 toolscreate_folderD
Create a folder.
Inputs: path (required), account.
delete_emailsA
Delete emails by moving them to Trash (recoverable; never permanent).
Inputs: uids (required), folder, account.
delete_folderA
Delete an EMPTY folder. Move or delete its emails first.
Inputs: path (required), account.
download_attachmentB
Save an email attachment to a local directory. Returns the saved path.
Inputs: uid (required), filename (required), save_dir (required), folder, +1 more.
forward_emailB
Forward an email (with its attachments) to new recipients, with an optional note on top.
Inputs: to (required), uid (required), cc, note, +2 more.
list_foldersB
List all folders. specialUse marks Inbox/Sent/Drafts/Trash/Junk/Archive.
Inputs: account.
move_emailsB
Move emails to another folder (archive, categorize).
Inputs: uids (required), dest_folder (required), folder, account.
read_emailB
Read one email: headers, text body (HTML converted to text) and attachment list.
Inputs: uid (required), folder, account, mark_read, +1 more.
rename_folderC
Rename or move a folder.
Inputs: path (required), new_path (required), account.
save_draftA
Save an email to the Drafts folder without sending it, so a human can review and send it.
Inputs: to (required), body (required), cc, bcc, +6 more.
search_emailsB
Search a folder, newest first. All filters are optional and combined with AND.
Inputs: to, body, from, seen, +9 more.
send_emailB
Send an email, optionally as a reply (pass reply_to_uid) and with attachments.
Inputs: to (required), body (required), cc, bcc, +6 more.
set_flagsA
Mark emails read/unread (seen) and starred/unstarred (flagged). Omitted values stay unchanged.
Inputs: uids (required), seen, folder, account, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool has a clearly distinct operation: folder listing/creation/renaming/deletion, email search/read/send/save/forward/move/delete, flag updates, and attachment download. There is minimal overlap because reply is handled as an option on send_email, while save_draft and forward_email remain clearly separate workflows.
All tool names use a consistent snake_case verb_noun pattern such as list_folders, read_email, move_emails, and delete_folder. This makes the set predictable and easy to scan.
The server exposes 13 tools, which is well-scoped for email management. Folders, messages, drafts, attachments, and flags each get focused operations without an excessive number of tools.
The tool set covers the main email lifecycle: folder CRUD, search/read, send/reply, save draft, forward, move, delete, flags, and attachment download. Minor gaps exist, such as explicit draft editing or reply-all, but core workflows are well supported.
Maintenance
Related MCP Connectors
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Email and optional phone for AI agents: send, receive, search, draft and call over MCP.
Hosted email MCP for your own Gmail, Outlook.com, Microsoft 365, iCloud or IMAP inbox: read, search, draft, reply in thread, forward and file mail. It moves or flags up to 500 messages in one call, and a send leaves exactly one copy in Sent. A calendar is a separate connection, and connecting one adds diary and scheduling tools.
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables external AI agents to read, send, and manage email over IMAP/SMTP via MCP, including inbox listing, search, drafts, scheduled/batch sending, and operations like reply, archive, and labels.303-
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants and MCP clients to manage multiple email accounts, including searching, reading, sending, replying to, forwarding, organizing, and bulk-deleting messages across IMAP/SMTP, with encrypted credential storage and connection pooling.1,009 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to read, search, send, manage, schedule, and analyze email across multiple IMAP/SMTP accounts through MCP, including drafts and templates, provider-aware labels, bulk operations, real-time IMAP IDLE watching with AI triage, verification-code capture, calendar extraction, and analytics.31 npmISC
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to search, read, send, reply to, forward, organize, and bulk-delete email across multiple IMAP/SMTP mailboxes, with AES-256-encrypted credential storage, connection pooling, and folder management. Supports 15+ pre-configured providers and simultaneous multi-account access from any MCP client.1,009 npmMIT