mail-mcp
Full read and send integration for Gmail accounts over IMAP/SMTP with app passwords: folder listing, message search (including Gmail search syntax such as has:attachment, label:, newer_than:7d, category:primary), reading messages and attachments, flagging, moving/archiving (via All Mail), saving drafts, and sending mail. Gmail labels are exposed as folders, and Sent copies are not duplicated because Gmail stores them automatically.
Read and send integration for iCloud Mail over IMAP/SMTP using app-specific passwords: lists folders with unread counts, searches messages, reads bodies and attachments, sets flags, moves messages, saves drafts and sends email with attachments and threaded replies. The server appends a copy of sent messages to Sent Messages over IMAP because iCloud does not keep one for SMTP, and resolves folder aliases through IMAP special-use folders.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mail-mcp
English · Italiano
A local MCP server that connects Claude (Desktop or Code) to your mailboxes. It reads mail over IMAP and sends over SMTP. It handles several accounts at once, with ready-made settings for iCloud and Gmail. Any other IMAP/SMTP provider can be configured by hand.
It runs on your Mac. Passwords stay in the macOS Keychain and no port is exposed.
Tools
Every tool takes an account parameter ("icloud", "gmail", ...). Searches and
folder listings cover all accounts when no account is given. Actions on a message
and sending always require an account when more than one is configured.
Tool | What it does |
| Lists the configured accounts |
| Lists folders with total and unread counts |
| Searches by sender, recipient, subject, text, dates, unread or flagged, newest first. On Gmail it also accepts |
| Returns headers, plain-text body and the list of attachments. It does not mark the message as read unless |
| Saves an attachment to |
| Marks messages read/unread and flagged/unflagged |
| Moves messages to another folder in the same account |
| Sends over SMTP (STARTTLS required), with attachments and threaded replies ( |
| Saves a draft without sending it, so you can review it in Mail or Gmail |
Common folder names
iCloud and Gmail name their folders differently (Sent Messages versus
[Gmail]/Sent Mail). Wherever a folder is expected you can use these aliases. They are
resolved through IMAP special-use folders (RFC 6154), so they also work with localized
Gmail folder names.
Alias | iCloud | Gmail |
| Sent Messages | [Gmail]/Sent Mail |
| Drafts | [Gmail]/Drafts |
| Deleted Messages | [Gmail]/Trash |
| Junk | [Gmail]/Spam |
| Archive | [Gmail]/All Mail (Gmail's "archive") |
Provider differences handled for you
Copy in Sent: iCloud does not keep one for mail sent over SMTP, so the server appends it over IMAP. Gmail keeps one automatically, so the server does not append another and you get no duplicates.
Archiving in Gmail means moving the message to All Mail, which removes the Inbox label. The
archivealias does exactly that.Gmail labels appear as folders over IMAP. To search by label, use
gmailQuery: "label:name".
Related MCP server: mail-macos-mcp
Quick setup (recommended)
Run this in Terminal on your Mac:
bash <(curl -fsSL https://raw.githubusercontent.com/fz4q8ggzrh-ux/MCP_IMAP_Connector/main/setup.sh)The script guides you step by step. It:
checks for Node.js 20+ and offers to install it with Homebrew;
downloads and builds the server in
~/mail-mcp;asks for your iCloud and Gmail addresses, opens the page where you create the app password, and tests the login before saving anything. If the password is wrong it tells you why and lets you try again. For iCloud it also tries the short IMAP username automatically;
stores the passwords in the macOS Keychain;
asks whether Claude may send email or only read it, and optionally which recipients are allowed;
writes
~/.config/mail-mcp/config.jsonand adds the connector to Claude Desktop and Claude Code.
Run it again at any time to change accounts or passwords. It reuses the passwords already in the Keychain. To test the saved configuration at any time:
node ~/mail-mcp/dist/index.js --checkManual setup
You need Node.js 20 or later (brew install node).
git clone https://github.com/fz4q8ggzrh-ux/MCP_IMAP_Connector.git ~/mail-mcp
cd ~/mail-mcp
npm install
npm run build1. Create app passwords
Neither iCloud nor Gmail accepts your normal password over IMAP/SMTP.
iCloud: go to https://account.apple.com → Sign-In and Security → App-Specific Passwords, and create one named "mail-mcp".
Gmail: 2-Step Verification must be on. Then go to https://myaccount.google.com/apppasswords, create one named "mail-mcp" and copy the 16 letters without spaces. Google Workspace admins can disable app passwords.
2. Store them in the Keychain
Add one entry per account, with service mail-mcp and your email address as the
account:
security add-generic-password -s mail-mcp -a name@icloud.com -w
security add-generic-password -s mail-mcp -a name@gmail.com -wEach command prompts for the password. Paste the app password.
3. Configuration file
Create ~/.config/mail-mcp/config.json:
{
"accounts": [
{ "name": "icloud", "user": "name@icloud.com", "from": "First Last <name@icloud.com>" },
{ "name": "gmail", "user": "name@gmail.com", "from": "First Last <name@gmail.com>" }
]
}The provider is detected from the domain (icloud.com, me.com, mac.com,
gmail.com). For a custom domain hosted by iCloud or Google Workspace, add
"provider": "icloud" or "provider": "gmail".
4. Connect it to Claude
Claude Desktop: edit ~/Library/Application Support/Claude/claude_desktop_config.json
(Settings → Developer → Edit Config):
{
"mcpServers": {
"mail": {
"command": "/opt/homebrew/bin/node",
"args": ["/Users/YOUR_USER/mail-mcp/dist/index.js"]
}
}
}Use the full path to node (see which node), because Claude Desktop does not read
your shell's PATH. Then restart Claude Desktop.
Claude Code:
claude mcp add mail --scope user -- node ~/mail-mcp/dist/index.jsTry asking: "What unread email do I have in iCloud and Gmail?"
Full configuration
Fields for each account in config.json:
Field | Default | Notes |
| required | Full address. Used for SMTP login and the Keychain lookup |
| the provider ( | Account name used by the tools. Required if you have two accounts with the same provider |
| from the domain |
|
|
| Sender shown to recipients, e.g. |
|
| iCloud: if it rejects the full address, try only the part before the |
| provider preset |
|
|
| Appends a copy to Sent after sending |
| detected | Only needed if automatic detection fails |
|
| Read-only for this account |
| everyone | Allowed addresses or domains, e.g. |
|
| Keychain service to read the password from |
At the top level of the file you can also set downloadDir, readOnly and
allowedRecipients, which apply to every account.
Environment variables, useful for tests or if you prefer not to use the file:
Variable | Use |
| Alternative path to the configuration file |
| The account list as JSON, instead of the file |
| Password for account |
| Single-account configuration |
| Makes every account read-only |
| Global allow-list, comma-separated |
| Folder for saved attachments |
Security
Claude asks for confirmation before each tool call unless you allowed it permanently. Keep that confirmation on for
send_email.send_emailis marked as destructive. Its description tells Claude to show you the sending account, recipients, subject and body before sending. For maximum caution, usesave_draftand send the message yourself.Sending always requires an explicit account, so Claude cannot pick the sending address on its own.
Email content is external text, and a message can contain instructions aimed at the assistant. Consider
readOnlyorallowedRecipientsfor mailboxes that receive a lot of mail from unknown senders.Each operation opens one IMAP connection and closes it. No session stays open.
Tests
npm test # unit testsThe end-to-end test uses two local Dovecot IMAP servers over TLS (port 1993 with iCloud's folder layout, port 1994 with Gmail's) and two SMTP test servers with STARTTLS, which the test starts itself:
MAIL_E2E=1 npm testThe expected credentials and folders are described at the top of test/e2e.test.mjs.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect any IMAP/SMTP mailbox to Claude & ChatGPT: search, read, sort, draft. Sends only with OK.
Connect Rackspace Email and other IMAP mailboxes to Claude or ChatGPT: search, read, draft, send.
Your mailboxes in ChatGPT and Claude: Gmail, iCloud, Fastmail, any IMAP. Passwords stay yours.
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables Claude to interact with email accounts via IMAP and SMTP, providing tools for searching, reading, sending, and managing emails across multiple providers.40819 npm140MIT
- AlicenseAqualityCmaintenanceEnables Claude to control the macOS Mail app for reading, searching, drafting, sending, and managing emails directly from Claude Desktop.12MIT
- FlicenseNot gradedqualityBmaintenanceEnables Claude to read, search, draft, send, flag, and move email across multiple IMAP/SMTP mailboxes while keeping credentials local.-
- AlicenseAqualityDmaintenanceEnables Claude to read, manage, and send email from any IMAP mailbox over plain IMAP and SMTP, including hosting-company and self-hosted mail servers. It provides tools for searching, reading, moving, deleting, and composing messages while built-in safety rules prevent unintended changes.12MIT