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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.