MCP Hub
Back to servers

IMAP Mini MCP

A lightweight MCP server for interacting with IMAP email accounts to read messages, manage folders, and compose draft replies. It supports standard providers and local bridges, providing tools for searching, fetching attachments, and organizing mailboxes without the ability to send or delete emails.

Stars
3
Updated
Feb 13, 2026
Validated
Feb 14, 2026

IMAP Mini MCP

A lightweight MCP (Model Context Protocol) server for reading IMAP email and creating draft replies. Works with any standard IMAP server (Gmail, Outlook, Fastmail, etc.) and local bridges like ProtonMail Bridge.

All tools are read-only, except for draft creation — agents can compose and update drafts but cannot send or delete emails.

Workflow Recommendation

I highly recommend using a speech-to-text tool (e.g. SuperWhisper on Mac or Whisperflow on Windows) and connecting your AI desktop application (Claude, Codex, etc.) to this MCP server. That way you can converse with your email inbox using speech, which will dramatically speed up your workflow.

How to Use

Agent configuration

Add to your MCP client config (e.g. claude_desktop_config.json):

{
  "mcpServers": {
    "imap-mini-mcp": {
      "command": "node",
      "args": ["/path/to/imap-mini-mcp/dist/index.js"],
      "env": {
        "IMAP_HOST": "imap.example.com",
        "IMAP_USER": "you@example.com",
        "IMAP_PASS": "your-password"
      }
    }
  }
}

The args path must point to the built dist/index.js. Add any optional variables to the env block as needed.

Environment variables

VariableRequiredDefaultDescription
IMAP_HOSTyesIMAP server hostname (e.g. imap.gmail.com)
IMAP_USERyesEmail address or username
IMAP_PASSyesPassword or app-specific password
IMAP_PORTno993IMAP server port
IMAP_SECUREnotrueUse TLS for the connection
IMAP_STARTTLSnotrueUpgrade to TLS via STARTTLS (when IMAP_SECURE=false)
IMAP_TLS_REJECT_UNAUTHORIZEDnotrueReject self-signed TLS certificates

For most providers (Gmail, Outlook, Fastmail), the defaults work — just set host, user, and password.

For ProtonMail Bridge — all five settings below are required (the bridge listens on localhost without TLS, uses a self-signed certificate, and does not support STARTTLS):

IMAP_HOST=127.0.0.1
IMAP_PORT=1143
IMAP_SECURE=false
IMAP_STARTTLS=false
IMAP_TLS_REJECT_UNAUTHORIZED=false

Or as MCP client config:

{
  "mcpServers": {
    "imap-mini-mcp": {
      "command": "node",
      "args": ["/path/to/imap-mini-mcp/dist/index.js"],
      "env": {
        "IMAP_HOST": "127.0.0.1",
        "IMAP_PORT": "1143",
        "IMAP_SECURE": "false",
        "IMAP_STARTTLS": "false",
        "IMAP_TLS_REJECT_UNAUTHORIZED": "false",
        "IMAP_USER": "you@proton.me",
        "IMAP_PASS": "your-bridge-password"
      }
    }
  }
}

Tools

Listing emails

All list tools return {count, emails} where each email is {id, subject, from, date}, sorted newest-first. Optional mailbox parameter (default: "INBOX").

Addressing emails — Every email is identified by a composite id in the format YYYY-MM-DDTHH:mm:ss.<Message-ID> (e.g. 2026-02-12T14:30:25.<abc123@mail.example.com>). This identifier is globally unique and stable across folder moves — unlike IMAP UIDs which are folder-scoped. Use the id returned by any list_emails_* tool to fetch content, download attachments, move emails, or create reply drafts. Action tools accept an optional mailbox hint for faster lookup; if omitted, all folders are searched.

ToolTime range
list_emails_24hLast 24 hours
list_emails_7daysLast 7 days
list_emails_monthLast 30 days
list_emails_quarterLast 90 days
list_emails_yearLast 365 days
list_emails_allAll time

list_emails_from_domain

List all emails from a specific domain.

ParameterTypeRequiredDescription
domainstringyesDomain to search for (e.g. "example.com")
mailboxstringnoDefault: "INBOX"

Returns {count, emails}.

list_emails_from_sender

List all emails from a specific sender email address.

ParameterTypeRequiredDescription
senderstringyesSender email address (e.g. "alice@example.com")
mailboxstringnoDefault: "INBOX"

Returns {count, emails}.

fetch_email_content

Fetch the full content of a single email by id.

ParameterTypeRequiredDescription
idstringyesEmail identifier from list results
mailboxstringnoFolder hint for faster lookup

Returns {id, subject, from, to, date, body, attachments}. The attachments array contains metadata only: {id, filename, contentType, size}.

fetch_email_attachment

Download a specific attachment from an email.

ParameterTypeRequiredDescription
idstringyesEmail identifier from list results
attachment_idstringyesAttachment id from fetch_email_content
mailboxstringnoFolder hint for faster lookup

Returns {id, filename, contentType, size, contentBase64}.

list_folders

List all folders in the email account. Takes no parameters.

Returns {count, folders} where each folder is {path, name, delimiter}. Use the path value when specifying folders in other tools.

create_folder

Create a new folder.

ParameterTypeRequiredDescription
pathstringyesFull path of the folder (e.g. "INBOX/Receipts")

Returns {created} with the path of the created folder.

move_email

Move an email from one folder to another. The email is not deleted — it is atomically relocated.

ParameterTypeRequiredDescription
idstringyesEmail identifier
source_folderstringnoFolder hint for faster lookup
destination_folderstringyesFolder to move the email to

Returns {id, destination}.

create_draft

Create a new email draft in the Drafts folder.

ParameterTypeRequiredDescription
tostringyesRecipient email address
subjectstringyesEmail subject line
bodystringyesPlain text email body
ccstringnoCC recipient(s)
bccstringnoBCC recipient(s)
in_reply_tostringnoID of email being replied to (for threading)

Returns {id, subject, to, date}. The Drafts folder is auto-detected via the \Drafts special-use attribute.

draft_reply

Create a reply draft to an existing email. Automatically derives recipient, subject, and threading headers from the original email.

ParameterTypeRequiredDescription
idstringyesID of the email to reply to
bodystringyesPlain text reply body
reply_allbooleannoInclude original To/CC as CC (default: false)
mailboxstringnoFolder hint for faster lookup

Returns {id, subject, to, date}.

update_draft

Replace an existing draft with new content. The id must refer to an email in the Drafts folder — this tool cannot modify emails in other folders.

ParameterTypeRequiredDescription
idstringyesID of the existing draft to replace
tostringyesRecipient email address
subjectstringyesEmail subject line
bodystringyesPlain text email body
ccstringnoCC recipient(s)
bccstringnoBCC recipient(s)
in_reply_tostringnoID of email being replied to (for threading)

Returns {id, subject, to, date}.

Troubleshooting

"IMAP connection closed unexpectedly" or "Server disconnected"

This almost always means the server rejected the connection due to a TLS/STARTTLS mismatch. Verify these environment variables are set correctly in your MCP client config:

VariableCheck
IMAP_HOSTCorrect hostname or IP
IMAP_PORTMatches your server (993 for TLS, 143/1143 for plain)
IMAP_SECUREtrue for port 993, false for plain connections
IMAP_STARTTLSfalse if your server does not support STARTTLS
IMAP_TLS_REJECT_UNAUTHORIZEDfalse if your server uses a self-signed certificate

Local IMAP bridges (e.g. ProtonMail Bridge) typically require IMAP_SECURE=false, IMAP_STARTTLS=false, and IMAP_TLS_REJECT_UNAUTHORIZED=false. See the ProtonMail Bridge config example in the Environment variables section above.

"IMAP authentication failed"

Check that IMAP_USER and IMAP_PASS are correct. Some providers (e.g. Gmail) require an app-specific password rather than your account password.

"Cannot reach IMAP server — connection refused"

The IMAP server is not running or not listening on the configured host and port. For local bridges, make sure the bridge application is running.

Development

Build and run

npm install
npm run build

Local development with .env

For running the server directly (outside of an MCP client), copy .env.example to .env and fill in your credentials, then:

npm start

When used through an MCP client, credentials are provided via the client config's env block instead.

Testing

Tests use vitest and mock the IMAP layer — no real server connection is needed:

npm test             # run once
npm run test:watch   # watch mode
npm run lint         # type-check only

License

MIT

Reviews

No reviews yet

Sign in to write a review