imail-mcp
MCP server that connects Claude to iCloud Mail, enabling reading, searching, sending, and organizing emails via IMAP/SMTP.
README
imail-mcp
🇷🇺 Документация на русском: README.ru.md
An MCP server that connects Claude (Cowork / Claude Code / Claude Desktop) to your email account so it can read, search, send, and organize your mail — directly from a conversation.
iCloud Mail is the first supported provider. The internals are written against a provider-agnostic interface, so Gmail / Microsoft 365 adapters can be added later without touching a single tool.
Highlights
- 📥 Read & search — list folders, search by sender/subject/text/date, read full messages and whole threads, download attachments.
- ✉️ Send & reply — compose, reply, reply-all, and forward with correct threading headers set automatically.
- 🗂️ Organize — move, archive, delete, and mark messages read/unread or flagged.
- 🔒 Credentials stay local — stored in the macOS Keychain, never in a plaintext file or env var.
- 🛑 Never sends silently — Claude is instructed to always preview an email and get your explicit approval before anything leaves your outbox.
Why a one-time setup (and no "Sign in with Apple" button)
Apple does not offer an OAuth / consent flow for third-party access to iCloud Mail. The only supported path is standard IMAP + SMTP with an app-specific password (required because every iCloud account uses 2FA).
So setup is a one-time step: generate that password once, hand it to the server, done. It is verified with a live IMAP login and then stored in your macOS Keychain — not on disk, not in your shell profile.
Platform note: credential storage uses the built-in macOS
securityCLI, so the server currently targets macOS. (A different keystore backend is all that's needed to support Linux/Windows.)
Install & connect
Requires Node.js ≥ 18.
git clone git@github.com:nurked/icloud-mail-mcp.git
cd icloud-mail-mcp
npm install
npm run build
npm run setup # or: node dist/bin/setup.js
setup opens a local page at http://127.0.0.1:4577 (bound to localhost
only — never exposed off your machine). The page:
- Links you to Apple's app-specific password page.
- Takes your iCloud address + the 16-character password you generate.
- Does a live IMAP test login to verify it works.
- Saves the credentials to your Keychain.
Generating the app-specific password
- Open appleid.apple.com → Sign-In and Security → App-Specific Passwords.
- Click Generate an app-specific password, name it
imail-mcp. - Copy the 16-character password and paste it into the setup page.
Wire it into Claude
Add the server to your MCP config (Claude Desktop / Cowork / Claude Code
mcpServers):
{
"mcpServers": {
"imail": {
"command": "node",
"args": ["/absolute/path/to/icloud-mail-mcp/dist/index.js"]
}
}
}
If you install the package globally (
npm linkornpm i -g), you can use"command": "imail-mcp"with noargsinstead.
Restart Claude and the imail tools become available.
Tools
| Tool | What it does |
|---|---|
list_mailboxes |
List folders with their IMAP paths and special-use roles |
search_messages |
Search by from / to / subject / text / date / unread (filters AND together) |
get_message |
Full headers, text + HTML body, attachment metadata |
get_thread |
The whole conversation, oldest → newest |
download_attachment |
Save an attachment to a temp file, return its path |
compose_preview |
Build an email for review — does not send |
send_email |
Send now (only after your approval) |
save_draft |
Put it in Drafts for you to send yourself |
reply |
Reply / reply-all, threading headers set from the original |
forward |
Forward to new recipients with a quoted header |
move_message |
Move a message to another mailbox |
set_flags |
Mark read/unread, flag/unflag |
archive_message |
Move to Archive |
delete_message |
Move to Trash (expunge if already there) |
Sending is never silent
The server ships an instruction telling Claude to always show you a
compose_preview and get your explicit go-ahead before calling send_email
(or reply / forward). If you'd rather send it yourself, ask Claude to
save_draft instead and the message lands in your Drafts folder.
How it works
Claude ──stdio──▶ imail-mcp ──IMAP (imap.mail.me.com:993)──▶ iCloud
│ └─SMTP (smtp.mail.me.com:587)──▶ iCloud
└─ credentials ◀── macOS Keychain
- IMAP (imapflow) handles reading and organizing; SMTP (nodemailer) handles sending; bodies are parsed with mailparser.
- The provider connects lazily on the first tool call, so adding the server to Claude doesn't touch your mailbox until you actually use it.
- The MCP
stdiotransport owns stdout, so all logging goes to stderr to keep the protocol stream clean.
Project layout
src/
index.ts MCP server + tool definitions
bin/setup.ts `imail-mcp-setup` entry point
auth/
setup-server.ts local connect page + live IMAP verification
keychain.ts macOS Keychain storage (via `security` CLI)
providers/
types.ts provider-agnostic MailProvider contract
icloud.ts iCloud IMAP/SMTP implementation
Adding another provider
The tools only ever talk to the MailProvider interface, so a new backend is
one new file:
- Implement
MailProvider(seesrc/providers/types.ts) in a new file undersrc/providers/. - Select it in
src/index.ts.
The tools stay unchanged.
Troubleshooting
- "No iCloud credentials found" — run
npm run setupfirst; the server reads from the Keychain on first tool use. - "Login failed" during setup — make sure you used an app-specific password, not your normal Apple ID password.
- Re-connecting / changing accounts — just run
npm run setupagain; it overwrites the stored credentials (-Uupdate) after a fresh verification.
License
PolyForm Noncommercial License 1.0.0 — this is source-available, not OSI open source.
- ✅ Free for any noncommercial purpose — personal use, study, research, hobby projects, and use by nonprofits, schools, and government bodies.
- ✅ You may read, modify, and redistribute it; the copyright notice must stay intact, so your work is always credited.
- 💼 Commercial use requires a separate license. If you want to use imail-mcp to make money — in a product, a paid service, or inside a for-profit company — contact Investment Fidelity Company at ceo@investmentfidelity.company to arrange a commercial license.
See LICENSE.md for the full terms.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。