IMAP/SMTP MCP server to search, read, organize, send, reply & forward email for AI assistants
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
A powerful Model Context Protocol (MCP) server that provides seamless IMAP email integration with secure account management and connection pooling.
Requires Node.js 22.12 or newer. Node 18 and 20 have both reached end-of-life, and several of this package's dependencies no longer support them. Check yours with
node --version.
Once published to npm, you can run the server directly without cloning or building anything β npx downloads the prebuilt package and runs it:
This is the easiest way to use the server in an MCP client (see Configuration for ready-to-paste npx configs).
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.
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):
This 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.
After installation, run the setup wizard:
Or if installed globally:
Or directly via npx without installing:
This will:
You can override the username and password of an already-configured account at
runtime with environment variables β useful when you inject secrets from a
password manager or CI system instead of storing them in accounts.json.
The variables are keyed by the account name, uppercased with every
non-alphanumeric character replaced by _. For an account named Work Gmail
(key WORK_GMAIL):
| Variable | Overrides |
|---|---|
IMAP_MCP_ACCOUNT_WORK_GMAIL_IMAP_USERNAME | IMAP username (user) |
IMAP_MCP_ACCOUNT_WORK_GMAIL_IMAP_PASSWORD | IMAP password |
IMAP_MCP_ACCOUNT_WORK_GMAIL_SMTP_USERNAME | SMTP username (smtp.user) |
IMAP_MCP_ACCOUNT_WORK_GMAIL_SMTP_PASSWORD | SMTP password |
Notes:
accounts.json, and the values are used as-is (not re-encrypted).process.env, so the
plaintext secret does not linger in the environment (where it could leak to
child processes or diagnostics). Set them before launching the server.The setup wizard integrates with this: each credential field (IMAP password,
IMAP username, SMTP username, SMTP password) has a "Do not save to config; set
later using an environment variable" checkbox. When ticked, the value you enter
is still used to test the connection, but it is not written to accounts.json β
the wizard shows the exact variable name to export, and the account picks the
credential up from that variable at runtime.
If the variable is missing, the account still holds the empty placeholder the wizard wrote. Rather than dialing out with a blank credential β which providers answer with a generic authentication failure that looks exactly like a wrong password β the server refuses the connection and names what to set:
Because the variables are read once at startup, setting one in an already-running shell has no effect until the server is restarted.
The setup wizard includes pre-configured settings for:
This always runs the latest published version and requires no local build.
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:
Important: Replace
/absolute/path/to/imap-mcp-serverwith the actual path where you cloned the repository. For example:
Step 3: Verify it was added:
You 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:
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):
Option B β from a local clone:
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 |
|---|---|
IMAP_MCP_READ_ONLY | When truthy (1, true, yes, on), only the safe, read-only tools are registered β searching, reading, listing folders, unread counts, spam analysis. No tool that sends mail, deletes/moves messages, changes flags, or edits accounts is exposed. |
IMAP_MCP_ENABLED_TOOLS | Comma-separated allowlist of tool names β only these are registered. Names are case-insensitive and the imap_ prefix is optional (search_emails β‘ imap_search_emails). When set, it takes precedence over IMAP_MCP_READ_ONLY. |
Example β read-only access:
Example β explicit allowlist:
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/imap-mcp-server)<a href="https://allmcps.com/mcp/imap-mcp-server"><img src="https://allmcps.com/api/badge/imap-mcp-server?style=directory" alt="Imap MCP Server on AllMCPs" /></a>