imap-mail-mcp
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., "@imap-mail-mcp 搜一下我 163 邮箱这周的未读邮件,并把第一封的正文读给我"
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.
imap-mail-mcp
一个 stdio MCP 服务器,把网易 / 新浪 / 完美邮箱接进 Agent。7 个工具,走 IMAP + SMTP,不需要任何厂商 API。
An MCP server that bridges 网易 (163/126/yeah/188), 新浪 and 完美邮箱 into your agent over IMAP + SMTP. Seven tools, zero vendor APIs — plus the three TLS/IMAP quirks that break every generic mail MCP on Chinese providers.
为什么需要它
这三家都没有任何 agent 接口:
邮箱 | 官方 API | Agent / MCP |
网易 163 / 126 / yeah / 188 | 仅企业邮有「接口集成平台」(部门、SSO),不含邮件正文 | 无 |
新浪 sina.com / sina.cn | 无对外开放平台 | 无 |
完美邮箱 88.com / email.cn | 无 | 无 |
所以只有 IMAP/SMTP + 授权码这一条路。通用的 Gmail MCP 拿到这儿会连不上——原因见下面「三个真实的坑」。
Related MCP server: Universal Email MCP Server
工具(7 个)
工具 | 说明 |
| 已配置账号、IMAP/SMTP 端点、已识别的域名 |
| 文件夹列表(中文名用返回的 |
| 按发件人 / 主题 / 全文 / 日期 / 未读搜索,返回 uid + 信封 |
| 读正文(MIME 已解码)+ 附件清单 |
| 附件落盘到 |
| 已读 / 未读 |
| 发信,必须 |
安装
git clone https://github.com/EastMG/imap-mail-mcp.git
cd imap-mail-mcp
npm install要求 Node ≥ 20(想用 --use-system-ca 建议 Node ≥ 24)。
配置账号
授权码在各自网页版的「设置 → 客户端 / POP3/IMAP/SMTP」里生成。不是网页登录密码。
node server.mjs add --email you@163.com --password <客户端授权密码> --id 163
node server.mjs add --email you@sina.com --password <16 位授权码> --id sina
node server.mjs add --email you@88.com --password <专用密码> --id 88
node server.mjs test # 逐个验证 IMAP + SMTP 登录
node server.mjs list # 看配置自定义域名直接给服务器地址:
node server.mjs add --email you@your-domain.com --password <专用密码> \
--imap imap.example.com --smtp smtp.example.com也可以手写 accounts.json(参考 accounts.example.json):
[
{ "id": "163", "email": "you@163.com", "password": "…" },
{ "id": "custom", "email": "you@your-domain.com", "password": "…",
"imapHost": "imap.example.com", "smtpHost": "smtp.example.com", "tlsSecLevel": 1 }
]域名在预设表里的(163 / 126 / yeah / vip.163 / 188 / sina.com / sina.cn / vip.sina.* / 88.com / email.cn)只需邮箱和授权码;子域名会按最长后缀匹配,比如 you@morning.email.cn 自动落到 imap.email.cn。
接到 MCP 客户端
Claude Desktop / Claude Code / 任意 MCP 客户端:
{
"mcpServers": {
"mail": {
"command": "node",
"args": ["/absolute/path/to/imap-mail-mcp/server.mjs"]
}
}
}Windows 上装了卡巴斯基之类的杀软,要在命令前加一个参数(原因见下):
{
"mcpServers": {
"mail": {
"command": "node",
"args": ["--use-system-ca", "/absolute/path/to/imap-mail-mcp/server.mjs"]
}
}
}工具名会以 mcp__mail__* 的形式出现。
三个真实的坑
这三条都是实测出来的,也是这个项目存在的主要理由。
1. 网易:LOGIN 之后必须发 RFC 2971 ID
不发的话连接看着正常,一 SELECT 就报:
SELECT Unsafe Login. Please contact kefu@188.com for help格式不对也会被拒(BAD Parse command)。本项目用 imapflow,它在 startSession() 里检测 ID 能力并在认证后再发一次——这正是 163 要求的。
2. 杀软 TLS 中间人:Node 不读 Windows 证书库
卡巴斯基这类软件会解密 IMAP/SMTP 流量,你拿到的是它自签的根签发的证书:
*.163.com ← Kaspersky Anti-Virus Personal Root Certificate(自签根)浏览器、Thunderbird 都正常(它们读系统证书库),Node 只读内置 CA,于是:
SELF_SIGNED_CERT_IN_CHAIN self-signed certificate in certificate chain两种解法:
# A. 让 node 读系统证书库(推荐,Node ≥ 24)
node --use-system-ca server.mjs test
# B. 只信任那一张根证书
export NODE_EXTRA_CA_CERTS=/path/to/kaspersky-root.pem3. 新浪:1024 位 DH,OpenSSL 3 直接拒
ERR_SSL_DH_KEY_TOO_SMALL预设表给新浪 4 个域名标了 tlsSecLevel: 1,落到 ciphers: "DEFAULT@SECLEVEL=1",只作用于新浪,其它账号仍是默认(最严)级别。自建服务器想降级,在 accounts.json 里写 "tlsSecLevel": 1。
中文文件夹名
IMAP 协议层是 modified UTF-7。list_folders 返回两个字段:
{ "path": "&f1F62ZAad+U-/已发送", "name": "已发送", "specialUse": "\\Sent" }调 search_messages / read_message 时把 path 原样传,不要手写中文。INBOX 不受影响。
安全模型
accounts.json权限0600、原子写入,密码只存本机;.gitignore已排除,不会进版本库。send_message不带confirmed=true直接抛错,要求先把「发件账号 / 收件人 / 主题 / 正文」展示给用户;每次真实发送追加一行到sends.log。这不是强保证——模型仍可能自己填
confirmed=true。工具层无法验证「用户真的同意了」,要硬管控请在客户端侧做审批。每调用一条连接、用完 logout;
disableAutoIdle,不维持常驻连接。logger: false:stdout 是 MCP 协议通道,任何日志都会破坏分帧,诊断信息走 stderr。
已知边界
网易对第三方 IMAP 有频率限制,密集拉取可能被临时限制(返回
Unsafe Login或连接被拒),隔几分钟再试。不做 IDLE / 推送:agent 只能主动查询,不会自动收到新邮件。
附件在内存里解析,超大附件(> 50 MB)可能吃内存。
草稿保存(APPEND 到 Drafts)未实现,发信是直接发。
私密笔记、思维导图之类与邮件无关的能力一概没有。
开发
npm test # node:test,覆盖域名解析 / TLS 级别 / 凭证提示
npm start # 本地起 MCP(stdio)License
Available Tools
7 toolsdownload_attachmentB
Save one attachment of a message to ./downloads and return the local path.
Inputs: uid (required), index, account, mailbox.
list_accountsA
List configured mailboxes (网易/新浪/完美邮箱) with their IMAP/SMTP endpoints.
Inputs: no named parameters.
list_foldersB
List IMAP folders for one account.
Inputs: account.
mark_readC
Mark a message read or unread.
Inputs: uid (required), read, account, mailbox.
read_messageA
Read one message by uid: headers, decoded plain-text body, attachment list.
Inputs: uid (required), account, mailbox, maxChars.
search_messagesA
Search messages in a mailbox. Returns uid + envelope; use read_message for the body. Chinese folder names must match list_folders output exactly.
Inputs: from, text, limit, since, +5 more.
send_messageA
SEND a real email. IRREVERSIBLE. Show the user account/recipients/subject/body first, get explicit approval, then call with confirmed=true. Every send is logged to sends.log.
Inputs: to (required), confirmed (required), cc, bcc, +6 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 maps to a distinct resource+action pair: accounts vs. folders vs. message search vs. message read, plus attachment download, read-state toggle, and send. The search/read split is explicitly clarified in the descriptions ('returns uid + envelope; use read_message for the body'), leaving no realistic overlap. Only mark_read and read_message share the 'read' word, but their actions are clearly different.
All seven tools follow a strict snake_case verb_noun pattern (list_accounts, list_folders, search_messages, read_message, download_attachment, mark_read, send_message). Resource nouns are used consistently across list/search/read operations.
Seven tools is a well-scoped surface for an IMAP/SMTP client: discovery (accounts, folders), retrieval (search, read, download), state change (mark_read), and the irreversible action (send_message). Nothing appears redundant or padded.
Core read/send workflows are covered, but the mailbox lifecycle has notable gaps: there is no delete_message, no move/copy-to-folder, and no folder creation, so an agent cannot archive, file, or clean up mail. Reply/forward also require the agent to reconstruct headers manually via send_message.
Maintenance
Related MCP Connectors
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Gmail, Outlook, iCloud, Fastmail and any IMAP mailbox for your agent. Scoped OAuth, approved sends.
Email inboxes for AI agents: read, search, reply, send, bulk send and read attachments.
- MyAgentMailDeprecatedcom.myagentmail
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI to send, read, search, delete and reply to emails through SMTP or Gmail API, supporting common email services like QQ, 163, Gmail and Outlook with HTML/text formats and attachments.1ISC
- AlicenseBqualityDmaintenanceEnables AI to send and receive emails via SMTP/IMAP, supporting auto-configuration for major email providers like QQ, 163, Gmail, Outlook, and enterprise mail.72MIT
- AlicenseBqualityBmaintenanceEnables AI agents to securely interact with Gmail and QQ Mail, including IMAP search/read/organization, attachments, and preview-confirmed sending.412MIT
- AlicenseBqualityCmaintenanceEnables sending, listing, and reading email messages via IMAP/POP3 with support for multiple providers, including NetEase, QQ, Gmail, and Outlook.72,218 npmMIT