imap-mcp
Provides read-only, searchable access to an iCloud IMAP mailbox, including ranked keyword search, message retrieval, folder listing, attachment downloads, and Markdown draft creation. It never sends, deletes, moves, or flags mail.
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.
imap-mcp
imap-mcp is a local MCP server that gives an AI agent read-only, searchable access to one IMAP mailbox. It can write drafts and can never send mail.
It syncs the mailbox into a local SQLite index with ranked keyword search. It syncs again on a tool call when the data is more than 15 minutes old, and every result tells the agent how old the data is. iCloud is the main target. Any IMAP server that accepts an app password also works.
Status: alpha. Tool names and parameters can change before 1.0.0. See the changelog.
What it never does
It never sends mail. The package contains no SMTP code.
It never deletes, moves or flags mail. A read never marks a message as read. A command allowlist checks every IMAP command before it goes on the wire.
It never listens on the network. It runs on stdio, started by your agent.
Email is untrusted input. Results keep sender text apart from server data, remove hidden HTML and invisible Unicode, and show sender authentication results. See Security in the design doc.
Related MCP server: IMAP Mail MCP
Requirements
macOS. The password lives in the macOS Keychain.
uv. It installs Python 3.14 if you do not have it.
An IMAP account with an app password. For iCloud, create one at account.apple.com under Sign-In and Security, App-Specific Passwords.
Set up
Create
~/.config/imap-mcp/config.toml. For iCloud,usernameis your Apple Account email or a custom-domain address on the account:host = "imap.mail.me.com" port = 993 username = "you@icloud.com" from_address = "you@icloud.com"Store the app password in the Keychain.
securityprompts for it twice. When macOS asks for Keychain access later, choose Always Allow for/usr/bin/security:uvx imap-mcp set-passwordCheck the connection. This prints the server capabilities and folders, and no message content:
uvx imap-mcp probeRun the first full sync. A large mailbox takes a long time, because iCloud limits download speed. You can stop it and run it again later. It continues where it stopped:
uvx imap-mcp sync
Optional settings
Key | Default | Effect |
|
| Where |
|
| How old the data can be before a tool call syncs |
|
| The time limit of a sync that a tool call starts |
|
| The index. It must be on a local disk, not in iCloud Drive. |
| empty | The Drafts folder name. Empty means find it by role or name. |
|
| Folders never to sync |
|
| Domains of your IMAP server's |
IMAP_MCP_CONFIG overrides the config file path.
Connect the Claude desktop app
Find the absolute path of
uvx. The desktop app starts servers with a minimalPATH, so a bareuvxfails. Do not use a version-manager shim:which -a uvxOpen Claude, then Settings, Developer, Edit Config. This opens
~/Library/Application Support/Claude/claude_desktop_config.json.Add the server, with your
uvxpath:{ "mcpServers": { "imap": { "command": "/opt/homebrew/bin/uvx", "args": ["imap-mcp@latest", "serve"] } } }imap-mcp@latestchecks for a new release at each start. Use a fixed version such asimap-mcp@0.1.0to upgrade only when you choose.Quit and restart Claude. The tools appear under the imap server in the tools menu.
Keep
create_drafton "Ask" when Claude asks for permission. Do not choose "Always allow".
Server logs go to ~/Library/Logs/Claude/mcp-server-imap.log. Logs never contain message content or addresses.
Connect Claude Code or another MCP client
Any client that runs a stdio server can use the same command:
claude mcp add imap -- uvx imap-mcp@latest serveUsage
Ask the agent in plain language. It picks the tools. For example:
"When does my car insurance renew?" The agent searches, reads the best match and answers with the date and the sender.
"What did the plumber say about Thursday? Draft a reply that accepts 9am." The agent finds the thread and writes a draft. You open Drafts in Mail, edit it and send it yourself.
"Save the PDF invoice from Acme." The agent saves it to
~/Downloadsand tells you the path."Check for new mail first." The agent calls
sync_now.
Tools
Tool | Effect |
| Ranked keyword search with filters (folder, sender, recipient, dates, unread, flagged, attachments). Skips Junk and Trash unless named. |
| One message: headers, plain-text body, attachment list |
| Folders with message and unread counts |
| Sync now, within the time limit |
| Save one attachment to |
| Write a Markdown draft to the Drafts folder. Never sends. |
Commands
Command | Effect |
| Run the MCP server on stdio. Your agent runs this. |
| Store the app password in the Keychain |
| Log in and print capabilities and folders |
| Run a full sync with no time limit |
| Show sync state, folder counts and database size |
| Rebuild the database file |
| Delete the index. The next sync rebuilds it. |
Prompt injection
An email can contain text written to steer the agent. imap-mcp cannot send mail, so the worst it can do on its own is write a draft. But if the same agent also has a tool that can reach the network (web fetch, HTTP, another mail tool), a hostile email can tell the agent to leak data through that tool. In a session that reads mail, give the agent as few network tools as possible.
Development
git clone https://github.com/bcrisp4/imap-mcpcd imap-mcp && uv syncuv run ruff check && uv run ruff format --check && uv run pyright && uv run mypy && uv run pytestTo run your checkout instead of the release, use uv run --directory /path/to/imap-mcp imap-mcp serve as the server command.
Tests never connect to a real mailbox. They use a TLS fake IMAP server that records every command and reproduces the iCloud quirks. Read AGENTS.md before you change code, and docs/releasing.md to make a release.
Docs
Design: goals, security model, sync design and decisions
API reference: built from the docstrings on each merge to
main. To browse it offline, runuv run pdoc imap_mcpin a clone.
Licence
MIT. See LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
- Lettio MCPOAutheu.lettio
Private, EU-hosted email for AI agents over JMAP: read, search, reply, draft, organize, send.
- MailowsOAuthcom.mailows
Give AI agents their own email inboxes: list, read and send mail via scoped, revocable OAuth grants.
Email inboxes for AI agents: send, receive, search, drafts with owner approval, and webhooks.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to read, search, and manage emails via IMAP with secure, read-only access to email accounts.6MIT
- AlicenseAqualityDmaintenanceEnables LLM clients to read and search email via IMAP with tools for listing folders, searching messages, and fetching message content. It supports pagination, snippets, and thread context, and is designed for local AI workflows.1017 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to search and read a local, provider-independent email archive, reconstruct contacts and interactions, and prepare draft responses without sending anything.1MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to securely access IMAP mailboxes with read-focused tools for searching, reading, listing messages, and creating drafts, while deliberately preventing sending or deleting emails.MIT