@openmaxai/email-mcp
This server lets an AI agent send and manage email via MCP: it sends messages over SMTP and reads/searches/manages messages over IMAP or POP3.
Send email – send to/cc/bcc recipients with plain-text or HTML bodies, optional local file attachments, from a configured address; saves a copy to the Sent folder (IMAP).
Reply to email – reply by UID or Message-ID, setting In-Reply-To/References and Re: subject; optionally reply-all while excluding your own addresses.
List emails – get newest-first summaries (uid, from, to, subject, date, flags, snippet) from a folder, with optional limit and unread filter.
Read emails – fetch full content or just headers by UID; optionally save attachments to a private temp directory.
Search emails – server-side (IMAP) or local (POP3, newest 200) search by from/to/subject/body text and date ranges.
Manage folders – list IMAP folders with message/unseen counts.
Mark read/unread – set or clear the \Seen flag on an IMAP message.
POP3 support – when configured with POP3, it supports INBOX-only operations and uses UIDL strings as UIDs, with reduced search/folder/flag capabilities.
Enables an AI agent to send, receive, search, and manage Gmail email over SMTP/IMAP/POP3 using an app password, including replying, listing messages, reading messages, and managing read/unread flags.
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., "@@openmaxai/email-mcp search my inbox for unread emails from Alice and summarize them"
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.
@openmaxai/email-mcp
A stdio MCP server that lets an AI agent send email over SMTP and read email over IMAP or POP3, using any provider that supports app passwords / authorization codes (QQ Mail, 163, Tencent Exmail, Aliyun enterprise mail, Outlook, Gmail, self-hosted servers...).
One connection per tool call, closed right after (no long-lived IDLE sessions).
Every network operation has a timeout.
All configuration comes from environment variables.
EMAIL_PASSWORDis the only secret.Logs go to stderr only (stdout carries the MCP protocol). Passwords and message bodies are never logged.
Requires Node.js 20.19 or newer.
Install (Claude Code)
claude mcp add-json email '{
"command": "npx",
"args": ["-y", "@openmaxai/email-mcp@0.1.0"],
"env": {
"EMAIL_USER": "me@example.com",
"EMAIL_PASSWORD": "<app password / authorization code>",
"RECEIVE_PROTOCOL": "imap",
"IMAP_HOST": "imap.example.com", "IMAP_PORT": "993", "IMAP_SECURE": "ssl",
"SMTP_HOST": "smtp.example.com", "SMTP_PORT": "465", "SMTP_SECURE": "ssl"
}
}'To receive over POP3 instead, set "RECEIVE_PROTOCOL": "pop3" and replace the IMAP_* keys with "POP3_HOST": "pop.example.com", "POP3_PORT": "995", "POP3_SECURE": "ssl".
Any other MCP client works the same way: run npx -y @openmaxai/email-mcp with the environment below.
Related MCP server: Mail MCP Server
Configuration
Variable | Required | Default | Notes |
| yes | Login name, usually the full email address. Also used as the From address. | |
| yes | App password / authorization code. The only secret. | |
| no | Display name for the From header. | |
| no |
|
|
| if imap | ||
| no | 993 (ssl) / 143 | |
| no | from port, else |
|
| if pop3 | ||
| no | 995 (ssl) / 110 | |
| no | from port, else |
|
| yes | ||
| no | 465 (ssl) / 587 (starttls) / 25 (none) | |
| no | from port, else |
|
| no |
| Verify server TLS certificates. Set to |
| no |
| IMAP only: after sending, save a copy (marked read, Bcc kept) to the Sent folder. |
| no | working directory + OS temp dir | Directories that attachments may be read from, separated by |
| no |
| Size limit for each attachment and for the total per message. |
| no | Other addresses of this mailbox, comma-separated. Excluded from reply-all recipients. | |
| no |
| Timeout for each tool call's network work (1000 to 600000). |
| no |
|
|
Security from the port. If *_SECURE is not set but *_PORT is, the security mode follows the port: SMTP 465 is ssl, 587 and 25 are starttls; IMAP 993 is ssl, 143 is starttls; POP3 995 is ssl. Other ports default to ssl. POP3 on port 110 is plaintext, so it needs an explicit POP3_SECURE=none. An explicit *_SECURE always wins.
starttls requires the upgrade: the connection fails if the server does not offer STARTTLS. none sends credentials in plaintext and logs a warning; use it only for local test servers.
The configuration is checked at startup. If something is missing or invalid, the server exits with code 2 and lists every problem it found. The password is never printed.
Provider presets
Before you start, most providers require you to enable IMAP/SMTP (or POP3/SMTP) in the web mail settings and to use an authorization code / app password instead of your normal login password.
Provider | IMAP | POP3 | SMTP | Notes |
QQ Mail ( |
|
|
| Settings → Account → enable IMAP/SMTP, then generate an authorization code (授权码). |
NetEase 163 ( |
|
|
| Settings → POP3/SMTP/IMAP → enable, then use the authorization code (授权码). |
Tencent Exmail ( |
|
|
| Enable IMAP/SMTP in client settings. If "secure login" is on, create a client-specific password (客户端专用密码). |
Aliyun enterprise mail |
|
|
| The admin may need to allow IMAP/POP/SMTP. Use a third-party client password if one is required. |
Outlook / Microsoft 365 |
|
|
| Needs an app password (account with 2-step verification). Many Microsoft 365 tenants turn off basic auth for IMAP/POP/SMTP, and this server does not support OAuth. |
Gmail |
|
|
| Turn on 2-Step Verification, then create an App Password. Enable IMAP/POP in Gmail settings. |
Provider settings can change. Check the provider's help pages if a connection fails.
Tools
Tool | Available | Description |
| always |
|
| always | Reply to a message by |
| always |
|
| always |
|
| always |
|
| IMAP only | Folders with message and unseen counts. |
| IMAP only |
|
Reading a message never marks it as read. Use mark_read to do that.
Sent folder. The Sent folder is found through IMAP SPECIAL-USE \Sent. If the server doesn't advertise one, the first folder named Sent, Sent Messages, Sent Items, 已发送 or 已发送邮件 is used. If none of these exists, no folder is created and the result carries a warning.
POP3 limitations
Only
INBOXexists. Any other folder returnsINVALID_INPUT.uidis the POP3 UIDL value (a string).POP3 has no read/unread flags:
seenisnull,flagsis empty, andunread_onlyreturns the newest messages with anotesaying the filter is not supported.POP3 has no server-side search.
search_emailsdownloads and filters the newest 200 messages locally. Older messages are not searched.list_foldersandmark_readare not registered.
Errors
Failed tool calls return isError: true with a JSON body {"error": {"code", "message"}}. The codes are stable:
Code | Meaning |
| Wrong user/password, IMAP/SMTP not enabled, or an authorization code is required. The message includes a hint for the provider, detected from the host name. |
| DNS failure, connection refused or reset, or a TLS/certificate problem. The message suggests port/security fixes. |
| The SMTP server rejected the recipients or the message. |
| No such message (uid / Message-ID) or folder. |
| Bad arguments, for example a missing body, an unreadable attachment or a bad date. |
| The server did not respond within |
| Anything else. Set |
Security notes
The only secret is
EMAIL_PASSWORD. It is removed from every error message and log line.TLS certificates are verified by default.
Attachments can only be read from the allowed directories: the working directory and the OS temp dir, or
EMAIL_ATTACHMENT_ROOTS. Paths are resolved withrealpath, so../traversal and symlinks that point outside those directories are rejected.Message bodies, subjects and addresses are never written to logs.
Development
npm install
npm run build
npm test # unit tests
npm run test:integration # needs Docker: starts greenmail/standalone automaticallyIntegration tests start a throwaway GreenMail container. To use an existing GreenMail instance instead, set GREENMAIL_HOST (and optionally GREENMAIL_SMTP_PORT, GREENMAIL_IMAP_PORT, ...).
Releasing
Pushing a v* tag starts the Release workflow. It needs one approval (the publish job, release environment); provenance verification, dist-tag promotion and holding-tag cleanup then run automatically. A stuck, waiting or failed release does not notify anyone: after tagging, check the Actions tab until the run is green.
Releases are serialized (concurrency with queue: max): if a run's publish approval is never given, that run holds the queue for up to 30 days and every later tag's run waits behind it. To recover, cancel the stuck run in the Actions tab (nothing was published, so nothing needs cleaning up); the next queued run then starts. When re-running an older run's cleanup job by hand, do so only if no newer release run has started since: with that run's publish outputs missing or invalid it removes the publish-staging dist-tag whatever version it points at.
License
MIT
Available Tools
7 toolsget_emailGet emailA
Read one message by uid. format=full returns text/html bodies; format=headers returns only headers. include_attachments=true saves attachments to a private temp dir and returns their paths.
Inputs: uid (required), folder, format, include_attachments.
list_emailsList emailsB
List the newest messages in a folder (via IMAP), newest first. Returns summaries: uid, from, to, subject, date, flags/seen, snippet.
Inputs: limit, folder, unread_only.
list_foldersList foldersA
List IMAP folders with message / unseen counts.
Inputs: no named parameters.
mark_readMark read / unreadA
Set or clear the \Seen flag on a message.
Inputs: uid (required), read, folder.
reply_emailReply to emailA
Reply to a received message (identified by uid or message_id). Sets In-Reply-To / References so the reply stays in the same thread, and prefixes the subject with "Re:".
Inputs: cc, bcc, uid, html, +5 more.
search_emailsSearch emailsC
Search messages (case-insensitive substring match). since/before are dates (YYYY-MM-DD); since is inclusive, before exclusive. Runs server-side via IMAP SEARCH.
Inputs: to, from, text, limit, +4 more.
send_emailSend emailB
Send an email via SMTP from user@example.com. Recipients accept "addr@example.com" or "Name addr@example.com". A copy is saved to the IMAP Sent folder.
Inputs: to (required), cc, bcc, html, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct email operation: sending, replying, listing, reading, searching, managing folders, and toggling read status. Even though list_emails and search_emails both return messages, their purposes are clearly separated by folder listing vs. substring search.
All tool names consistently follow a verb_noun pattern: send_email, reply_email, list_emails, get_email, search_emails, mark_read, list_folders. This makes the tool set highly predictable and easy for an agent to navigate.
Seven tools is well-scoped for an email MCP server. Each tool covers a meaningful operation without redundancy or bloat.
Core email workflows are well covered: send, reply, list, search, read, mark read, and folder listing. Minor gaps exist around operations like deleting/moving messages or sending attachments, but agents can typically accomplish common email tasks without dead ends.
Maintenance
Related MCP Connectors
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with email accounts via IMAP and SMTP, supporting mailbox listing, email search, retrieval, sending, and management.MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to send, read, and manage emails via SMTP and IMAP, with support for attachments, threads, and mailbox organization.1627 npm1MIT
- FlicenseBqualityCmaintenanceEnables AI models to send, receive, search, and manage emails via SMTP/IMAP, including support for attachments, contacts, and advanced search.18-
- AlicenseNot gradedqualityNot gradedmaintenanceIMAP/SMTP email for AI agents -- read, send, organize folders, and manage attachments across multiple accounts, with auto-discovery.MIT