imap-mcp
Connects to Gmail mailboxes over IMAP to read, search, flag, and move messages; manage folders; download attachments; and save drafts, using a Gmail app password.
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
An MCP server that gives Claude Code access to several IMAP mailboxes. Each mailbox has a short name in a config file, and every tool takes that name as its account argument.
The server reads, searches, flags and moves messages, manages folders, downloads attachments and writes drafts. It never sends mail.
Requirements
Python 3.10 or later
An IMAP account for each mailbox. For Gmail, create an app password.
Related MCP server: Babushka Email MCP
Installation
git clone https://github.com/emahuet/imap-mcp.git
cd imap-mcp
python3 -m venv .venv
.venv/bin/pip install -r requirements.txtOn Windows, the interpreter is .venv\Scripts\python.exe: use it in place of .venv/bin/python in the commands below.
Configuration
Copy the example files:
cp config.yaml.example config.yaml
cp .env.example .envIn config.yaml, list your accounts under accounts. The key of each entry (personal, work in the example) is the name you will use in Claude Code. Each account gives its host, port, username and the name of the environment variable that holds its password (password_env).
Put the passwords in .env:
IMAP_PERSONAL_PASSWORD=...
IMAP_WORK_PASSWORD=...Both files are read from the directory of mcp_server.py, whatever the current directory is when Claude Code starts the server. They are listed in .gitignore. A password variable already set in the shell works too.
To check the connections:
.venv/bin/python scripts/check_connection.pyRegister in Claude Code
Use absolute paths to the virtual environment and to mcp_server.py:
claude mcp add imap -s user -- /path/to/imap-mcp/.venv/bin/python /path/to/imap-mcp/mcp_server.py-s user makes the server available in every project. Run claude mcp list to see it, then start a new Claude Code session.
Tools
list_accounts(): configured accounts.list_folders(account): folders of an account.search_emails(account, folder, limit, headers_only, unseen, flagged, answered, from_, to, subject, body, since, before, mark_seen, text, query): search with filters combined by AND.textis a full-text search on the subject, body and headers (each word must be present, quotes are ignored).queryis an alias oftext. Matching depends on the server: Gmail only finds whole words.account="*"searches every account, withlimitapplied per account. Messages are not marked as read unlessmark_seen=True.get_email(account, uid, folder, include_html, max_chars): content of a message. When the message has no plain text part,textis extracted from the HTML. The raw HTML is returned only withinclude_html=True. Calendar invitations (Teams, Outlook, Google Calendar) are parsed into acalendarfield.set_flags(account, uids, flags, value, folder): set or clear flags. Aliases areflagged,seen,answeredanddraft.\Deletedis refused.move_emails(account, uids, dest_folder, source_folder): move messages, for example toTrash.permanent_delete_emails(account, uids, folder): permanent delete, allowed only in a folder flagged\Trashby the server.create_folder(account, folder)anddelete_folder(account, folder): a folder is deleted only when it is empty and has no subfolder.attachments_meta(account, uids, folder)anddownload_attachments(account, uid, save_dir, folder): attachment metadata and download.save_draft(account, to, subject, body, ...): write a draft in the Drafts folder, with HTML body, attachments and threading headers (in_reply_to,references).unread_count(account, folder): number of unread messages.
Generic folder names (Sent, Drafts, Trash, Junk, Archive) are resolved through the server's SPECIAL-USE attributes when the account uses localized names.
Scripts
Run them from the repository root:
scripts/check_connection.py [account ...]: log in to each account and print a short summary.scripts/move_once.py <account> <dest_folder> <uid> ...: move messages from INBOX.scripts/move_folder.py <account> <source_folder> <dest_folder>: move the whole content of a folder.
Tests
.venv/bin/python -m unittest discover -s testsThe tests use no network and no config file.
Security
Passwords come from environment variables only.
Connections use SSL by default (port 993).
Messages are not stored or cached on disk, except attachments you download.
License
MIT, see 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.
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.
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.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables Claude to read, search, draft, send, flag, and move email across multiple IMAP/SMTP mailboxes while keeping credentials local.-
- FlicenseNot gradedqualityDmaintenanceEnables Claude Code to manage email inboxes via IMAP, including reading, categorizing, phishing detection, archiving, junking, and sending emails with user permission.-
- 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
- AlicenseNot gradedqualityCmaintenanceEnables Claude to access an IMAP mailbox to read, search, organize, and manage messages, create drafts, and optionally send email via SMTP across providers.MIT