Prerequisites
Before you begin, ensure you have:MCP-compatible client
Install Claude Desktop or another MCP client that supports stdio servers.
IMAP credentials
Obtain your IMAP server credentials:
- Host: IMAP server hostname (e.g.,
imap.gmail.com) - User: Your email address
- Password: App-specific password (not your account password)
Node.js (for npm method)
Install Node.js 18 or later if using the npm installation method.
Configure Claude Desktop
Add the Mail IMAP MCP Server to your Claude Desktop configuration. The configuration file location varies by platform:- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Replace
[email protected] and your-app-password with your actual credentials. The DEFAULT account is used when no specific account is requested.Environment Variables
The server supports several configuration options via environment variables. Here are the most common ones:| Variable | Type | Default | Description |
|---|---|---|---|
MAIL_IMAP_DEFAULT_HOST | string | required | IMAP server hostname |
MAIL_IMAP_DEFAULT_USER | string | required | Username for authentication |
MAIL_IMAP_DEFAULT_PASS | string | required | Password (use app-specific password) |
MAIL_IMAP_DEFAULT_PORT | number | 993 | IMAP server port |
MAIL_IMAP_DEFAULT_SECURE | boolean | true | Use TLS (currently enforced) |
MAIL_IMAP_WRITE_ENABLED | boolean | false | Enable write operations |
MAIL_IMAP_CONNECT_TIMEOUT_MS | number | 30000 | TCP connection timeout |
MAIL_IMAP_GREETING_TIMEOUT_MS | number | 15000 | IMAP greeting timeout |
MAIL_IMAP_SOCKET_TIMEOUT_MS | number | 300000 | Socket I/O timeout |
MAIL_IMAP_CURSOR_TTL_SECONDS | number | 600 | Cursor time-to-live |
MAIL_IMAP_CURSOR_MAX_ENTRIES | number | 512 | Maximum cursors to retain |
Enable Write Operations
By default, write operations (copy, move, delete, flag updates) are disabled for safety. To enable them, add:Test the Connection
After configuring Claude Desktop, restart the application and test the connection:Verify connectivity
Ask Claude: “Verify my default IMAP account”This tests TCP/TLS connection, authentication, and retrieves server capabilities. Expected response includes
"ok": true and a list of IMAP capabilities.List mailboxes
Ask Claude: “List mailboxes in my default account”This returns all visible folders/mailboxes like INBOX, Sent, Drafts, etc.
Multiple Accounts
Configure multiple IMAP accounts by adding account-specific environment variables:MAIL_IMAP_*_HOST patterns. Account IDs are normalized to lowercase (e.g., WORK becomes work).
When calling MCP tools, specify the account using the normalized account ID:
"account_id": "work" or "account_id": "personal".Troubleshooting
Authentication failed
- Verify username and password are correct
- Use app-specific password (not your main account password)
- Check that IMAP is enabled on your account
- Ensure 2FA is configured if required by your provider
Connection timeout
- Check your internet connection
- Verify the IMAP host and port are correct
- Increase timeout:
"MAIL_IMAP_CONNECT_TIMEOUT_MS": "60000" - Check if firewall is blocking port 993
Write operations disabled
"MAIL_IMAP_WRITE_ENABLED": "true" to the env section in your configuration.
Account not configured
MAIL_IMAP_<ID>_HOST, _USER, and _PASS variables defined.
Available Tools
The server provides 10 MCP tools for email operations:Read operations (always enabled)
imap_list_accounts: List configured accountsimap_verify_account: Test connectivity and capabilitiesimap_list_mailboxes: List mailboxes/foldersimap_search_messages: Search with cursor paginationimap_get_message: Get parsed message detailsimap_get_message_raw: Get RFC822 source
Write operations (require MAIL_IMAP_WRITE_ENABLED=true)
imap_update_message_flags: Add/remove flagsimap_copy_message: Copy to mailboximap_move_message: Move to mailboximap_delete_message: Delete message (requires confirmation)
Next Steps
Search messages
Learn cursor-based pagination and search filters
Configure accounts
Deep dive into account configuration options
API reference
Explore all 10 MCP tools and their parameters
Security
Learn about security features and best practices