imail-mcp
imail-mcp is a full-featured email management server for iCloud Mail, enabling you to read, search, send, and organize emails securely.
Account & Mailbox Management: List connected iCloud accounts and their connection status; browse all mailboxes with IMAP paths and special-use roles (Inbox, Sent, Drafts, Trash, Archive, etc.).
Reading & Searching: Search messages by sender, recipient, subject, free text, date range, and read/unread status, with pagination (up to 200 results). Fetch full message content (headers, plain-text and HTML body, attachment metadata). Retrieve entire conversation threads. Bulk-fetch up to 20 full messages in a single call. Download attachments to local temp files.
Composing & Sending: Create a preview without sending, send emails after explicit user approval (with elicitation where supported), save drafts, reply or reply-all (automatic threading headers), and forward messages with an optional prepended note.
Organizing Messages: Move, archive, delete (trash/expunge), and set read/unread or flagged/unflagged flags. Perform bulk operations (move, flag, archive, delete) on up to 200 messages as a single IMAP command.
Security & Multi-Account: All operations work across multiple iCloud accounts with an optional
accountparameter. Credentials are securely stored in the macOS Keychain. The local HTTP service binds to 127.0.0.1 and requires a bearer token. Destructive actions (like sending) require explicit user approval.
Allows reading, searching, sending, and organizing iCloud Mail through IMAP and SMTP, including listing folders, searching messages, composing and sending emails, replying, forwarding, moving messages, setting flags, and managing drafts.
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., "@imail-mcp show me unread emails in my inbox"
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.
imail-mcp
π·πΊ ΠΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ Π½Π° ΡΡΡΡΠΊΠΎΠΌ: README.ru.md
An MCP server that connects Claude (Cowork / Claude Code / Claude Desktop) to your email so it can read, search, send, and organize your mail β directly from a conversation.
Runs as a resident background service (launchd) with a web admin UI, serving all your Claude clients over one Streamable HTTP endpoint β or as a classic per-client stdio server. 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
π₯οΈ Runs as a service β one long-lived process (launchd LaunchAgent, auto-start at login, auto-restart) shared by every MCP client over Streamable HTTP; stdio mode still works for per-client setups.
π Web admin UI β connect/disconnect Apple accounts, check live connection status, copy ready-made client configs, tail the service log β all at
http://127.0.0.1:4577, localhost-only.π₯ Multiple accounts β connect several iCloud accounts; every tool takes an optional
accountparameter.π₯ Read & search β folders, search with paging, full messages and whole threads, bulk fetch up to 20 full messages per call, attachments.
βοΈ Send & reply β compose, reply, reply-all, forward with correct threading headers.
ποΈ Organize, in bulk β move / archive / delete / flag up to 200 messages per call as a single IMAP command.
π Credentials stay local β account passwords and the service's access token live in the macOS Keychain, never in a plaintext file or env var.
π Never sends silently β Claude must preview an email and get your approval first; on clients that support MCP elicitation, the server additionally asks you to confirm in-app before anything is sent.
Related MCP server: macos-mail-mcp
The Mac app
The nicest way to run imail-mcp is the menu-bar app in app/:
a signed, notarizable iMail MCP.app that bundles the whole service as a
self-contained binary (no Node required), shows live status in the menu bar,
opens the control panel in its own window, and starts at login. Build it with
cd app && npm install && npm run tauri build, then drag the .app from
app/src-tauri/target/release/bundle/macos/ into /Applications. On first
launch it takes over from the CLI-installed launchd service automatically.
Everything below β the CLI service, stdio mode, tools, security model β works the same with or without the app; the app is just a shell that owns the service process.
Quick start (CLI, no app)
Requires Node.js β₯ 18 and macOS.
git clone git@github.com:nurked/icloud-mail-mcp.git
cd icloud-mail-mcp
npm install
npm run build
node dist/index.js service install # register + start the background service
node dist/index.js ui # open the admin UI in your browserIn the admin UI:
Accounts tab β connect your iCloud account (see the app-specific password note below). The login is verified live over IMAP, then stored in your Keychain.
Clients tab β copy the ready-made one-liner for Claude Code, or the JSON block for Claude Desktop. Done.
Installing globally (
npm linkornpm i -g .) gives you theimail-mcpcommand used in the examples below; otherwise usenode dist/index.js <command>.
CLI reference
imail-mcp stdio MCP server (for per-client mcpServers configs)
imail-mcp serve [--port N] run the HTTP service in the foreground
imail-mcp ui open the admin UI (authenticated) in your browser
imail-mcp service install install + start the launchd LaunchAgent
imail-mcp service status show whether the service is installed/running
imail-mcp service uninstall stop and remove the LaunchAgentDefault port: 4577. Logs: ~/Library/Logs/imail-mcp/imail-mcp.log.
Generating the app-specific password
Apple does not offer OAuth for iCloud Mail β the only supported path is IMAP/SMTP with an app-specific password (every iCloud account has 2FA):
Open appleid.apple.com β Sign-In and Security β App-Specific Passwords.
Click Generate an app-specific password, name it
imail-mcp.Paste the 16-character password into the admin UI.
Wire it into Claude
Preferred β the shared service (copy the exact command, with your token filled in, from the admin UI's Clients tab):
claude mcp add --transport http imail http://127.0.0.1:4577/mcp \
--header "Authorization: Bearer <token>"Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"imail": {
"type": "http",
"url": "http://127.0.0.1:4577/mcp",
"headers": { "Authorization": "Bearer <token>" }
}
}
}Fallback β per-client stdio (each client spawns its own process; no service needed):
{
"mcpServers": {
"imail": { "command": "node", "args": ["/absolute/path/to/dist/index.js"] }
}
}Security model
The HTTP service binds to 127.0.0.1 only and validates the
Hostheader (DNS-rebinding protection, plus the MCP SDK's own check).The
/mcpendpoint requires a bearer token, generated on first run and stored in the Keychain β without it, other local processes can't read or send your mail through the service.The admin UI uses a one-time token URL (
imail-mcp ui) exchanged for an HttpOnly, SameSite=Strict session cookie; mutating API calls additionally require a custom header (CSRF).Sending tools are gated three ways: prompt discipline (preview first), tool annotations (
destructiveHinton sends/deletes), and elicitation β on supporting clients the server asks you to confirm each send in-app, and a declined confirmation returnssent: false.
Tools
Tool | What it does |
| Connected accounts and their live connection status |
| Folders with IMAP paths and special-use roles |
| Search by from / to / subject / text / date / unread, with |
| Full headers, text + HTML body, attachment metadata |
| Bulk fetch up to 20 full messages in one call (missing UIDs reported, not fatal) |
| The whole conversation, oldest β newest |
| Save an attachment to a temp file; returns path + resource link |
| Build an email for review β does not send |
| Send now (after your approval; elicitation-confirmed where supported) |
| Put it in Drafts for you to send yourself |
| Reply / reply-all, threading headers set from the original |
| Forward to new recipients with a quoted header |
| Move one / up to 200 messages |
| Read/unread, flag/unflag β one / up to 200 |
| Move to Archive β one / up to 200 |
| Move to Trash (expunge if already there) β one / up to 200 |
Every tool takes an optional account parameter (omit when only one account
is connected). Bulk operations execute as a single IMAP command (UID
set), not N round-trips. All tools declare MCP tool annotations
(read-only / destructive / idempotent hints) and output schemas
(structured content), per the 2025-06-18+ MCP spec.
How it works
Claude Code ββ
Claude Desktop ββ€ Streamable HTTP (127.0.0.1:4577/mcp, bearer token)
Cowork ββ β
βΌ
imail-mcp service (launchd) ββIMAP (imap.mail.me.com:993)βββΆ iCloud
β admin UI at / ββSMTP (smtp.mail.me.com:587)βββΆ iCloud
ββ credentials + token βββ macOS Keychain
account registry βββ ~/Library/Application Support/imail-mcp/IMAP (imapflow) reads and organizes; SMTP (nodemailer) sends; bodies are parsed with mailparser.
A shared provider pool keeps one live IMAP connection per account, with keepalive and transparent reconnect (dead sockets retry once).
Connections are lazy β adding the server to Claude doesn't touch your mailbox until you actually use it.
Built on MCP SDK 1.x (spec line 2025-06-18 / 2025-11-25). The transport layer is isolated in
src/http/, so migrating to the stateless 2026-07-28 spec / SDK v2 is a contained change.
Project layout
src/
index.ts CLI: stdio server, serve, ui, service subcommands
mcp.ts MCP server factory: tools, schemas, annotations, elicitation
bin/setup.ts `imail-mcp-setup` β foreground service + admin UI (legacy entry)
accounts/
registry.ts non-secret account registry (accounts.json)
pool.ts provider pool: lazy connect, keepalive, add/remove accounts
auth/
keychain.ts Keychain storage: per-account credentials + HTTP token
http/
server.ts HTTP service: /mcp (session map), /auth, /api, admin UI
ui.ts admin UI page (no framework, no build step)
service/
launchd.ts LaunchAgent install/uninstall/status
providers/
types.ts provider-agnostic MailProvider contract
icloud.ts iCloud IMAP/SMTP implementation (incl. bulk ops)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/.Wire it up in
src/accounts/pool.ts.
The tools stay unchanged.
Troubleshooting
"No mail accounts are connected" β open the admin UI (
imail-mcp ui) and connect an account on the Accounts tab."Login failed" when connecting β make sure you used an app-specific password, not your normal Apple ID password.
imail-mcp uisays the service isn't answering β start it:imail-mcp service install(persistent) orimail-mcp serve(foreground).Port already in use β pass
--port Ntoserve/service install, and update your client configs accordingly.Upgrading from β€0.1 β the old single-account Keychain entry is migrated automatically on first run; existing stdio client configs keep working.
Service logs β
~/Library/Logs/imail-mcp/imail-mcp.log(also shown in the admin UI's Service tab).
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.
Available Tools
14 toolsarchive_messageArchive messageC
Move a message to the Archive mailbox.
Inputs: mailbox (required), uid (required).
compose_previewCompose preview (does NOT send)A
Build an email and return it for the user to review. Does not send or save anything. Use this first, then send_email after the user approves.
Inputs: to (required), subject (required), cc, bcc, +5 more.
delete_messageDelete messageC
Move a message to Trash (or expunge it if it is already in Trash).
Inputs: mailbox (required), uid (required).
download_attachmentDownload attachmentA
Save an attachment to a local temp file and return its path. Get the attachmentId from get_message.
Inputs: mailbox (required), uid (required), attachmentId (required).
forwardForward a messageB
Forward an existing message to new recipients. Only call after explicit user approval.
Inputs: mailbox (required), uid (required), to (required), cc, +1 more.
get_messageGet messageA
Fetch a full message: headers, text + HTML body, and attachment metadata.
Inputs: mailbox (required), uid (required).
get_threadGet threadB
Fetch the conversation a message belongs to, ordered oldest to newest.
Inputs: mailbox (required), uid (required).
list_mailboxesList mailboxesA
List all mailboxes/folders with their IMAP paths and roles.
Inputs: no named parameters.
move_messageMove messageC
Move a message to another mailbox.
Inputs: mailbox (required), uid (required), targetMailbox (required).
replyReply to a messageA
Reply to an existing message. Set replyAll for reply-all. Like send_email, only call after explicit user approval. Threading headers are set automatically from the original.
Inputs: mailbox (required), uid (required), replyAll, text, +2 more.
save_draftSave draftA
Save an email to the Drafts mailbox so the user can review and send it themselves. Does not send.
Inputs: to (required), subject (required), cc, bcc, +5 more.
search_messagesSearch messagesA
Search a mailbox. All filters are optional and combined with AND. Returns summaries, newest first.
Inputs: mailbox, from, to, subject, +5 more.
send_emailSend emailB
Send an email NOW. Only call after the user has explicitly approved sending (ideally after a compose_preview).
Inputs: to (required), subject (required), cc, bcc, +5 more.
set_flagsSet flagsB
Mark a message read/unread and/or flagged/unflagged.
Inputs: mailbox (required), uid (required), seen, flagged.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 14 tools
Each tool targets a distinct email operation (e.g., archive vs delete vs move, compose vs send vs save draft, forward vs reply). No two tools have overlapping purposes.
Most tools follow verb_noun pattern (e.g., archive_message, delete_message). 'forward' and 'reply' are just verbs, which is a minor inconsistency but still clear.
14 tools cover essential email operations (send, receive, manage folders, flags, attachments, threads) without being excessive.
Covers major email lifecycle (send, receive, delete, move, flag, search, thread). Minor gaps: no direct edit draft or empty trash, but key workflows are supported.
Maintenance
Related MCP Connectors
Connect any IMAP/SMTP mailbox to Claude & ChatGPT: search, read, sort, draft. Sends only with OK.
Read and send iCloud Mail, manage iCloud Calendar. Needs an approved account at icloud.mcp.visin.ch.
Email infrastructure for AI agents β send, receive, search, and reply to email 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
- AlicenseBqualityBmaintenanceAn MCP server that connects Claude to iCloud Mail for reading, searching, sending, and organizing emails through natural language. It supports advanced management tasks like bulk operations, mailbox organization, and automated rules for inbox maintenance.86273 npmMIT
- AlicenseAqualityBmaintenanceAn MCP server for Apple Mail that enables Claude to read, search, manage, and compose emails via AppleScript.20121 npm1MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that enables Claude Desktop to interact with iCloud email accounts. This server provides full email functionality including reading, sending, and managing emails through your iCloud account.1-
- AlicenseAqualityBmaintenanceAn MCP server that provides programmatic access to Apple Mail, enabling AI assistants like Claude to read, send, search, and manage emails on macOS.25MIT