IMAP MCP Server
This server enables AI assistants to manage email accounts and perform comprehensive email operations via IMAP and SMTP.
Account Management: Add, update, list, remove, connect, disconnect, and test IMAP accounts. Credentials are stored with AES-256 encryption. Supports multiple simultaneous accounts and 15+ pre-configured email providers.
Email Retrieval & Search: Search emails by sender, recipient, subject, body, date range, read/flagged status, or custom keywords — across single or all folders. Get latest emails, read full content (Markdown/HTML/plain text), find thread messages, and locate emails by Message-ID.
Sending & Drafting: Send new emails with plain text/HTML and attachments, reply (with reply-all support), forward messages, and save drafts. Upload large files as attachments without hitting context window limits.
Email Organization: Move emails between folders (with optional auto-creation), mark as read/unread, flag/unflag, add/remove custom IMAP keywords/labels, and delete individually or in bulk by UIDs or search criteria (with dry-run preview).
Folder Management: List all folders, get folder status (including message counts and custom keywords), create new folders, and get unread counts per folder or across all folders.
Spam & Domain Management: Analyze emails for spam using disposable/spam domain lists, delete spam by confidence level, view sender domain statistics, add/remove custom spam domains, whitelist trusted domains, and delete all emails from a specific domain — all with dry-run options.
Security & Access Control: AES-256 encrypted credential storage, read-only mode via environment variable to restrict to non-destructive tools, and a tool allowlist to expose only specific tools to the agent.
Allows managing 1&1 (IONOS) email accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing AOL Mail accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing Apple iCloud Mail accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing Gmail accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing GMX email accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing iCloud Mail accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing IONOS email accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing mailbox.org email accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing ProtonMail accounts via IMAP (requires ProtonMail Bridge), enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing WEB.DE email accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Allows managing Zoho Mail accounts via IMAP, enabling operations such as searching, reading, sending, moving, and deleting emails, as well as folder management.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@IMAP MCP ServerShow me my last 5 unread emails from today"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
IMAP MCP Server
A powerful Model Context Protocol (MCP) server that provides seamless IMAP email integration with secure account management and connection pooling.
Features
🔐 Secure Account Management: Encrypted credential storage with AES-256 encryption
🚀 Connection Pooling: Efficient IMAP connection management
📧 Comprehensive Email Operations: Search, read, move, mark, delete, and bulk delete emails
✉️ Email Sending: Send, reply, and forward emails via SMTP
📁 Folder Management: List folders, check status, get unread counts
🔄 Multiple Account Support: Manage multiple IMAP accounts simultaneously
🛡️ Type-Safe: Built with TypeScript for reliability
🌐 Web-Based Setup Wizard: Easy account configuration with provider presets
📱 15+ Email Providers: Pre-configured settings for Gmail, Outlook, Yahoo, and more
🔗 Auto SMTP Configuration: Automatic SMTP settings based on IMAP provider
Related MCP server: Gmail MCP Server
Installation
Run via npx (No Installation Required)
Once published to npm, you can run the server directly without cloning or building anything — npx downloads the prebuilt package and runs it:
npx -y imap-mcp-serverThis is the easiest way to use the server in an MCP client (see Configuration for ready-to-paste npx configs).
Quick Install (Recommended)
macOS/Linux:
curl -fsSL https://raw.githubusercontent.com/nikolausm/imap-mcp-server/main/install.sh | bashWindows (PowerShell as Administrator):
iwr -useb https://raw.githubusercontent.com/nikolausm/imap-mcp-server/main/install.ps1 | iexManual Installation
Clone the repository:
git clone https://github.com/nikolausm/imap-mcp-server.git
cd imap-mcp-serverInstall dependencies:
npm installBuild the project:
npm run buildAccount Setup
Accounts are stored encrypted in ~/.imap-mcp/accounts.json. This file is shared by all run modes — whether you start the server via npx, a global install, or a local clone, they all read the same accounts. So you only need to set up your accounts once.
Setting Up Accounts in npx Mode
If you run the server via npx (no clone), you have two ways to add accounts:
Option A — Run the setup wizard directly via npx (no install needed):
npx -p imap-mcp-server imap-setupThis launches the same web-based wizard described below and writes to ~/.imap-mcp/accounts.json, which your npx-configured MCP server then picks up automatically.
Option B — Add accounts straight from your AI client:
Once the MCP server is configured, just ask your assistant to add an account — it uses the imap_add_account tool. For example:
"Add my IMAP account: host imap.gmail.com, port 993, user me@gmail.com, password …"
No separate setup step required.
Web-Based Setup Wizard (Recommended)
After installation, run the setup wizard:
npm run setupOr if installed globally:
imap-setupOr directly via npx without installing:
npx -p imap-mcp-server imap-setupThis will:
Start a local web server
Open your browser to the setup wizard
Guide you through adding email accounts with pre-configured settings
Supported Email Providers
The setup wizard includes pre-configured settings for:
Gmail / Google Workspace
Microsoft Outlook / Hotmail / Live
Yahoo Mail
Apple iCloud Mail
GMX
WEB.DE
IONOS (1&1)
ProtonMail (with Bridge)
Fastmail
Zoho Mail
AOL Mail
mailbox.org
Posteo
Custom IMAP servers
Configuration
Claude Code (CLI)
Option A — via npx (no clone/build needed)
claude mcp add imap -- npx -y imap-mcp-serverThis always runs the latest published version and requires no local build.
Option B — from a local clone
If you use Claude Code in the terminal, add the MCP server with a single command:
Step 1: Make sure you have built the project first (see Manual Installation).
Step 2: Run this command in your terminal:
claude mcp add imap -- node /absolute/path/to/imap-mcp-server/dist/index.jsImportant: Replace
/absolute/path/to/imap-mcp-serverwith the actual path where you cloned the repository. For example:# macOS/Linux example: claude mcp add imap -- node /Users/yourname/imap-mcp-server/dist/index.js # Windows example: claude mcp add imap -- node C:\Users\yourname\imap-mcp-server\dist\index.js
Step 3: Verify it was added:
claude mcp listYou should see imap in the list of configured MCP servers. That's it — the IMAP tools are now available in your Claude Code sessions.
Tip: If you want to remove the server later, run:
claude mcp remove imap
Claude Desktop (GUI App)
Add the IMAP MCP server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Option A — via npx (recommended, no clone/build needed):
{
"mcpServers": {
"imap": {
"command": "npx",
"args": ["-y", "imap-mcp-server"],
"env": {}
}
}
}Option B — from a local clone:
{
"mcpServers": {
"imap": {
"command": "node",
"args": ["/path/to/imap-mcp-server/dist/index.js"],
"env": {}
}
}
}Restricting tool access (read-only mode / allowlist)
By default all tools are exposed. You can restrict which tools the agent sees
using two environment variables (set them under the env key of your MCP
config). This is useful when you want to give an assistant read-only access
to a mailbox, or expose only a hand-picked subset of tools.
Variable | Effect |
| When truthy ( |
| Comma-separated allowlist of tool names — only these are registered. Names are case-insensitive and the |
Example — read-only access:
{
"mcpServers": {
"imap": {
"command": "npx",
"args": ["-y", "imap-mcp-server"],
"env": { "IMAP_MCP_READ_ONLY": "true" }
}
}
}Example — explicit allowlist:
{
"mcpServers": {
"imap": {
"command": "npx",
"args": ["-y", "imap-mcp-server"],
"env": { "IMAP_MCP_ENABLED_TOOLS": "imap_search_emails,imap_get_email,imap_get_latest_emails" }
}
}
}The read-only subset is: imap_list_accounts, imap_connect, imap_disconnect,
imap_test_account, imap_search_emails, imap_get_email,
imap_get_latest_emails, imap_download_attachment, imap_find_thread_messages,
imap_find_email_by_message_id, imap_list_folders, imap_folder_status,
imap_get_unread_count, imap_check_spam, imap_domain_stats,
imap_list_spam_domains.
Usage
Once configured, the IMAP MCP server provides the following tools in Claude:
Choosing an account. For the email and folder tools,
accountIdis optional and backward-compatible. You may instead passaccountName, and if you only have a single account configured you can omit both — that account is used by default. With multiple accounts and no selector, the tool returns a clear error listing your options (imap_list_accounts).
Account Management
imap_add_account: Add a new IMAP account
Parameters: - name: Friendly name for the account - host: IMAP server hostname - port: Server port (default: 993) - user: Username - password: Password - tls: Use TLS/SSL (default: true) - sentFolder: Explicit Sent-folder name for sent-mail copies, e.g. "Gesendet" (optional — only needed when the server has no \Sent SPECIAL-USE folder and auto-detection fails)imap_update_account: Update an existing account (fix SMTP settings, rename, etc.)
Parameters: - accountId: ID of the account to update - name, host, port, user, password, tls, email: IMAP fields (all optional) - smtpHost, smtpPort, smtpSecure, smtpUser, smtpPassword: SMTP fields (optional) - saveToSent: Save sent emails to the Sent folder (optional) - sentFolder: Explicit Sent-folder override (optional). Pass an empty string to clear the override and re-enable auto-detectionimap_list_accounts: List all configured accounts
imap_remove_account: Remove an account
Parameters: - accountId: ID of the account to removeimap_connect: Connect to an account
Parameters: - accountId OR accountName: Account identifierimap_disconnect: Disconnect from an account
Parameters: - accountId: Account to disconnect
Email Operations
imap_search_emails: Search for emails
Parameters: - accountId: Account ID - folder: Folder name (default: INBOX; ignored when searchAllFolders is true) - searchAllFolders: Search across ALL folders at once (default: false). Skips Trash/Spam/Drafts and non-selectable folders by default. Use when a message may have been filed/moved/archived and you don't know its folder. - includeTrash, includeSpam, includeDrafts: Opt those noisy folders back into a searchAllFolders run (default: false each) - from, to, subject, body: Search criteria - since, before: Date filters - seen, flagged: Status filters - keywords: Match messages with ANY of these custom keywords (server-side OR). Read a mailbox's available custom keywords from `imap_folder_status`'s `customKeywords` field first. - unKeywords: Exclude messages with ANY of these custom keywords (result has NONE of them). Same keyword source as `keywords`. - limit: Max results (default: 50) - includeBody: Include parsed message body in the response (default: false). Fetches the RFC822 source once and parses it with mailparser, so you get uid + body in a single tool call instead of paying the N+1 cost of one `imap_get_email` per match. Body is rendered per `bodyFormat` and capped at `bodyMaxLength` per field. - bodyFormat: How to render the body when `includeBody` is true — `markdown` (default, clean Markdown via Turndown), `text`, `html`, or `auto`. - bodyMaxLength: Per-field cap when `includeBody` is true (default: 10000).With
searchAllFolders, results include afolderfield per message plusfoldersSearched, and any folder that failed to open is reported infoldersErrored(so a 0-result answer is never silently incomplete).includeBodyis honored in the single-folder path only. For a cross-folder sweep the lightweight header shape is preserved by design — pulling RFC822 source for every match across many folders would multiply bandwidth and parse cost. Follow up withimap_get_emailfor the specific uids whose bodies you need.On some servers a "flagged"/starred message carries a custom keyword (e.g. an Open-Xchange color label or Apple's
$MailFlagBit*) instead of, or in addition to, the\Flaggedsystem flag — after any flagged search, check each result'scustomKeywordsfield before concluding a message is or isn't flagged.imap_get_email: Get full email content
Parameters: - accountId: Account ID - folder: Folder name - uid: Email UID - maxContentLength: Max characters for text/html body (default: 10000) - includeAttachmentText: Include text attachment previews (default: true) - maxAttachmentTextChars: Max characters per text attachment (default: 100000)imap_get_latest_emails: Get recent emails
Parameters: - accountId: Account ID - folder: Folder name (default: INBOX) - count: Number of emails (default: 10) - includeBody: Include parsed message body (default: false). Same semantics as the `includeBody` option on `imap_search_emails` — one round-trip instead of N×`imap_get_email`. - bodyFormat: `markdown` (default), `text`, `html`, or `auto`. - bodyMaxLength: Per-field cap (default: 10000).imap_mark_as_read/unread: Change email read status
Parameters: - accountId: Account ID - folder: Folder name - uid: Email UID, OR an array of UIDs to flag in one call. Batch uses a single IMAP STORE so the operation is atomic at the server level — all UIDs are flagged, or none. Useful when triaging many messages at once.imap_flag_email/unflag_email: Star/unstar an email (sets or clears the IMAP \Flagged system flag — shows as a "star" in Gmail and Apple Mail). Some servers/clients (Open-Xchange, Apple Mail) also set a separate custom keyword (e.g.
$cl_N,$MailFlagBit*) when flagging; unflag only clears\Flagged, so if a message still shows as flagged, checkcustomKeywordsviaimap_get_emailand clear it withimap_remove_keyword.Parameters: - accountId: Account ID - folder: Folder name - uid: Email UIDimap_add_keyword/remove_keyword: Set or clear an arbitrary custom (non-system) IMAP keyword/label on an email, passed through verbatim (e.g. provider color labels like Open-Xchange's
$cl_1..$cl_10or Apple Mail's$MailFlagBit0..$MailFlagBit2, or any other custom keyword). Backslash-prefixed system flags (e.g.\Flagged,\Seen,\Deleted) are rejected — use the dedicated flag/read tools for those. Not every server permits custom-keyword changes (see the mailbox's PERMANENTFLAGS); if the server rejects or silently ignores the change, the call fails instead of reporting success.Parameters: - accountId: Account ID - folder: Folder name - uid: Email UID - keyword: IMAP keyword to set/remove (e.g. "$cl_3")imap_delete_email: Delete an email
Parameters: - accountId: Account ID - folder: Folder name - uid: Email UIDimap_move_email: Move an email from one folder to another
Parameters: - accountId: Account ID - folder: Source folder name (default: INBOX) - uid: Email UID, OR an array of UIDs to move in one call. Batch moves are attributed per-uid in the response (`results[]` with per-uid `uidMap` and any errors). Single-uid calls return the legacy response shape. - targetFolder: Destination folder name - createDestinationIfMissing: Create the destination folder if it does not exist (default: false)imap_find_thread_messages: Find inbox messages that belong to the same conversation threads as messages already sorted into another folder. Uses RFC 3501 HEADER search on In-Reply-To and References — works on any IMAP server.
Parameters: - accountId: Account ID - sourceFolder: Folder containing the already-sorted thread messages - searchFolder: Folder to search for related messages (default: INBOX) - searchReferences: Also match the References header for multi-level threads (default: true) - includeBody: Include parsed message body for each found thread message (default: false). Same semantics as the `includeBody` option on `imap_search_emails` — one round-trip instead of N×`imap_get_email`. - bodyFormat: `markdown` (default), `text`, `html`, or `auto`. - bodyMaxLength: Per-field cap (default: 10000).imap_download_attachment: Download an email attachment (returns images inline, extracts text from PDFs, or saves to downloads directory)
Parameters: - accountId: Account ID - folder: Folder name (default: INBOX) - uid: Email UID - filename: Attachment filename or contentId - savePath: Optional file path to save the attachment to - extractText: For PDFs, extract and return text content inline (default: true)imap_bulk_delete: Delete multiple emails at once with chunking and auto-reconnection
Parameters: - accountId: Account ID - folder: Folder name (default: INBOX) - uids: Array of email UIDs to delete - chunkSize: Emails to delete per batch (default: 50)imap_bulk_delete_by_search: Search for emails matching criteria and delete them all
Parameters: - accountId: Account ID - folder: Folder name (default: INBOX) - from, to, subject: Search criteria (optional) - before, since: Date filters (optional) - chunkSize: Emails to delete per batch (default: 50) - dryRun: Preview what would be deleted without deleting (default: false)At least one concrete criterion (
from,to,subject,before, orsince) is required — a call with no criteria is refused, so it can never match and delete an entire folder.imap_send_email: Send a new email
Parameters: - accountId: Account ID to send from - to: Recipient email address(es) - subject: Email subject - text: Plain text content (optional) - html: HTML content (optional) - cc: CC recipients (optional) - bcc: BCC recipients (optional) - replyTo: Reply-to address (optional) - attachments: Array of attachments (optional) - filename: Attachment filename - content: Base64 encoded content - path: File path to attach - contentType: MIME type - contentDisposition: "attachment" (default) or "inline" — use "inline" for images shown in the HTML body via cid: - cid: Content-ID for inline attachments; must match the `cid:` value used in an `<img src="cid:...">` tag in `html`After sending, a copy is saved to the account's Sent folder (unless
saveToSentis disabled on the account). The folder is resolved via the account'ssentFolderoverride → the server's\SentSPECIAL-USE flag → a list of known localized names ("Sent", "Gesendet", "Éléments envoyés", …). The response reports the outcome:savedToSent(boolean),sentFolder(the folder used), and — when the save fails —sentSaveErrorexplaining why, instead of failing silently. The same applies toimap_reply_to_emailandimap_forward_email.imap_save_draft: Save an email as a draft (no send). Takes the same fields as
imap_send_email, plusinReplyTo,references, and an optionalfolderoverride for the Drafts folder.imap_reply_to_email: Reply to an existing email
Parameters: - accountId: Account ID - folder: Folder containing the original email - uid: UID of the email to reply to - text: Plain text reply content (optional) - html: HTML reply content (optional) - replyAll: Reply to all recipients (default: false) - attachments: Array of attachments (optional, same shape as imap_send_email, including contentDisposition/cid for inline images)imap_forward_email: Forward an existing email
Parameters: - accountId: Account ID - folder: Folder containing the original email - uid: UID of the email to forward - to: Forward to email address(es) - text: Additional text to include (optional) - includeAttachments: Include original attachments (default: true)
Folder Operations
imap_list_folders: List all folders
Parameters: - accountId: Account IDEach folder includes its
attributes(raw IMAP LIST flags) and, when the server advertises it,specialUse— the RFC 6154 role (\Sent,\Drafts,\Trash,\Junk,\Archive) that identifies a folder independent of its localized display name (e.g. "Gesendet" carriesspecialUse: "\Sent").imap_folder_status: Get folder information
Parameters: - accountId: Account ID - folder: Folder nameimap_create_folder: Create a new IMAP folder/mailbox. Most servers also create any missing parent folders. Returns success even if the folder already exists.
Parameters: - accountId: Account ID - folder: Full folder path to create (e.g. "Archives/2026/2026-05" or "INBOX.Archive")imap_get_unread_count: Count unread emails
Parameters: - accountId: Account ID - folders: Specific folders (optional)
Security
Credentials are encrypted using AES-256-CBC encryption
Encryption keys are stored separately in
~/.imap-mcp/.keyAccount configurations are stored in
~/.imap-mcp/accounts.jsonThe store directory,
.key, andaccounts.jsonare written owner-only (0700/0600) so other local users cannot read the key or the credentialsThe web setup wizard's HTTP API never returns stored passwords to the browser
Downloaded attachments are confined to the downloads directory; sender-supplied filenames cannot write outside it
Never commit or share your encryption key or account configurations
Development
Running in Development Mode
npm run devBuilding
npm run buildProject Structure
src/
├── index.ts # MCP server entry point
├── services/
│ ├── imap-service.ts # IMAP connection management
│ ├── smtp-service.ts # SMTP service for sending emails
│ └── account-manager.ts # Account configuration
├── tools/
│ ├── index.ts # Tool registration
│ ├── account-tools.ts # Account management tools
│ ├── email-tools.ts # Email operation tools (including send/reply/forward)
│ └── folder-tools.ts # Folder operation tools
└── types/
└── index.ts # TypeScript type definitionsExample Usage in Claude
Add an account: "Add my Gmail account with username john@gmail.com"
Check new emails: "Show me the latest 5 emails from my Gmail account"
Search emails: "Search for emails from boss@company.com in the last week"
Send an email: "Send an email to client@example.com with subject 'Project Update'"
Reply to emails: "Reply to the latest email from my boss"
Forward emails: "Forward the email with subject 'Meeting Notes' to team@company.com"
Move an email: "Move the invoice email from INBOX to my Taxes folder"
Manage folders: "List all folders in my email account and show unread counts"
Troubleshooting
Connection Issues
Ensure your IMAP server settings are correct
Check if your email provider requires app-specific passwords
Verify that IMAP is enabled in your email account settings
For sending emails, ensure your account has SMTP access enabled
SMTP Configuration
The server automatically configures SMTP settings based on your IMAP provider. If you need custom SMTP settings, you can specify them when adding an account:
{
"smtp": {
"host": "smtp.example.com",
"port": 587,
"secure": false
}
}Common IMAP Settings
Gmail:
Host: imap.gmail.com
Port: 993
Requires app-specific password
Outlook/Hotmail:
Host: outlook.office365.com
Port: 993
Yahoo:
Host: imap.mail.yahoo.com
Port: 993
Requires app-specific password
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables seamless email management through natural language conversations with Claude. Supports searching, reading, and sending emails securely with Gmail and other email providers.Last updated4MIT
- Alicense-qualityCmaintenanceEnables Claude to read, search, send, label, and trash emails in any Gmail account via Google's Gmail API, using OAuth2 authentication with automatic token refresh.Last updated67MIT
- -license-qualityDmaintenanceEnables Claude to read, search, send, and manage emails across multiple IMAP/SMTP accounts via a single deployment.Last updated
- Alicense-qualityDmaintenanceEnables Claude to read, search, send, and manage Gmail messages and threads through natural language.Last updated636MIT
Related MCP Connectors
Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
AI email inbox and sending tools with attachments, search, live events, and webhooks.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nikolausm/imap-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server