Local, read-only MCP server with keyword search over one IMAP mailbox
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.
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.
Create ~/.config/imap-mcp/config.toml. For iCloud, username is 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. security prompts for it twice. When macOS asks for Keychain access later, choose Always Allow for /usr/bin/security:
uvx imap-mcp set-password Check the connection. This prints the server capabilities and folders, and no message content:
uvx imap-mcp probe Run 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 download_dir ~/Downloads Where download_attachment saves files sync_interval_minutes 15 How old the data can be before a tool call syncs sync_budget_seconds 20 The time limit of a sync that a tool call starts db_path ~/Library/Application Support/imap-mcp/imap-mcp.db The index. It must be on a local disk, not in iCloud Drive. drafts_folder empty The Drafts folder name. Empty means find it by role or name. exclude_folders [] Folders never to sync auth_servers ["icloud.com"] Domains of your IMAP server's Authentication-Results headers. Only those headers give the spf, dkim and dmarc verdicts. IMAP_MCP_CONFIG overrides the config file path. IMAP_MCP_DEBUG=1 makes the CLI show where an unexpected error failed.
Find the absolute path of uvx. The desktop app starts servers with a minimal PATH, so a bare uvx fails. Do not use a version-manager shim:
which -a uvx Open Claude, then Settings, Developer, Edit Config. This opens ~/Library/Application Support/Claude/claude_desktop_config.json.
{ "mcpServers": { "imap": { "command": "/opt/homebrew/bin/uvx", "args": ["imap-mcp@latest", "serve"] } } } imap-mcp@latest checks for a new release at each start. Use a fixed version such as imap-mcp@0.1.0 to upgrade only when you choose.
Quit and restart Claude. The tools appear under the imap server in the tools menu.
Keep create_draft on "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.
Any client that runs a stdio server can use the same command:
claude mcp add imap -- uvx imap-mcp@latest serve Usage Ask the agent in plain language. It picks the tools. For example:
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.
git clone https://github.com/bcrisp4/imap-mcp cd imap-mcp && uv sync uv run ruff check && uv run ruff format --check && uv run pyright && uv run mypy && uv run pytest To 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.
All 2 files in this release have provenance metadata.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
All 2 files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




