imap-2-mcp
Provides an optional hand-off that re-fetches an email attachment from IMAP and uploads it directly to a Paperless-ngx instance, enabling document ingestion without passing the file through the client.
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-2-mcp
MCP server that makes IMAP mailboxes searchable for AI clients such as Claude. It combines live IMAP access with a local SQLite FTS5 index that also covers attachment contents (PDF/DOCX/XLSX/text), so full-text search stays fast even for large mailboxes (50k+ messages).
Read-only against existing mail: it never sends, moves, or flags anything. The only write operations concern drafts:
create_draftAPPENDs a new draft to the drafts folder, anddelete_draftremoves a message from it — but only one that is flagged\Draft(all other mail is refused). Sending stays a manual step in your mail client (there is no SMTP in this project).
See SPEC.md for the full design and rationale.
Features (Phase 1)
Multi-account IMAP (SSL), read-only against existing mail.
Background sync worker: initial full index + periodic incremental updates.
Attachment text extraction (PDF, DOCX, XLSX, plain text).
Draft creation (
create_draft): store a draft — optionally threaded as a reply, optionally with attachments taken from indexed mails (attachment_ids) or Paperless-ngx (paperless_document_ids, max 20 MB in total) — in the account's drafts folder; never sends. Files that exist nowhere on the server can come from a drop folder (attachment_files, seelist_attachment_files; mount a synced cloud folder viaATTACHMENT_HOST_DIRto fill it from any device), from a URL (attachment_urls; Dropbox share links work; public addresses only) or as inline text/base64 (inline_attachments, for small generated files). Files that live only in a chat cannot be attached — the server never sees their bytes.Draft management:
list_draftsshows the drafts folder live,delete_draftpermanently removes one draft (byuidormessage_id; refuses anything not flagged\Draft).Optional Paperless-ngx hand-off (
send_attachment_to_paperless): re-fetch an attachment from IMAP and upload it straight to Paperless — the file never passes through the client. Enabled viaPAPERLESS_URL+PAPERLESS_API_TOKEN.MCP tools over streamable HTTP (client may run on another machine):
list_mailboxes,list_recent,get_email,get_thread,search,search_attachments,get_attachment_text,create_draft,list_drafts,delete_draft,list_attachment_files,sync_status(+send_attachment_to_paperlesswhen configured).
Related MCP server: mcp-mail-server
Quick start
cp .env.example .env # fill in your IMAP account(s) — never commit this file
docker compose up --buildThe server listens on :8000 (streamable HTTP). The first sync runs on
startup; large mailboxes take a while to index initially.
To run a one-off index pass without serving:
docker compose run --rm imap-2-mcp python -m imap2mcp --sync-onceConfiguration
All config is via environment variables (see .env.example).
Declare accounts with ACCOUNTS=name1,name2 and one ACCOUNT_<NAME>_* block
each (HOST, PORT, SSL, USER, PASSWORD). Secrets live only in your
local .env, which is git-ignored.
Authentication
Set API_TOKEN in your .env to require a bearer token on every request.
Clients then authenticate either via header or via a query parameter (useful
for connector UIs that cannot set custom headers):
Authorization: Bearer <token>
# or
https://<host>/mcp?token=<token>With API_TOKEN unset, the endpoint is unauthenticated — keep it on a trusted
network only.
Connecting Claude
Add the streamable-HTTP endpoint as an MCP server, e.g. for Claude Code:
claude mcp add --transport http imap http://<home-server-ip>:8000/mcpSecurity notes
Set
API_TOKENbefore exposing the server beyond your local network.Without a token, only expose it inside your home network (LAN/VPN such as Tailscale). Do not port-forward it to the internet.
Phase 2 (public connector) will add full OAuth and a TLS tunnel.
Status
Phase 1 implementation. Not yet hardened or load-tested against a live mailbox.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Connect Gmail, iCloud Mail, Outlook, Yahoo Mail, Fastmail and other IMAP inboxes to ChatGPT, Claude and compatible AI assistants. Find emails by meaning across languages with semantic search. Ask AI to find customer conversations, summarize deadlines and draft follow-ups. Give a sales rep access to a shared outreach inbox or bring email into a compatible CRM. Share an iCloud custom-domain inbox with teammates without their own Apple ID or iCloud+ plan. Search results may be incomplete or stale; separate permissions control mail actions.
Email inboxes for AI agents: read, search, reply, send, bulk send and read attachments.
1Private, EU-hosted email for AI agents over JMAP: read, search, reply, draft, organize, send.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables MCP-compatible AI assistants to securely search multiple mailboxes, reconstruct email threads, and inspect attachments through read-only tools without altering mailbox state.Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to read, search, and manage email via IMAP, and send emails with attachments via SMTP, using natural language commands.1,767 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to read, send, organize, and search emails across multiple IMAP/SMTP mailboxes.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to search a local email archive using hybrid keyword and semantic search, and retrieve individual emails with thread context.1MIT