Skip to main content
Glama
IMAP MCP

IMAP MCP

by WEYERSK

IMAP MCP

An MCP server that gives Claude read, manage and send access to any IMAP mailbox, for the mail that Google and Microsoft connectors do not cover: hosting company mailboxes (xneelo, cPanel, Plesk), self hosted Dovecot, anything that speaks plain IMAP and SMTP.

Runs locally over stdio. Your password stays in a local .env file, and mail goes directly from this machine to your mail server.

What Claude gets

Tool

What it does

list_accounts

Configured mailboxes, and whether each password is set

list_folders

Every folder, plus the detected Sent, Trash and Drafts folders

search_messages

Search by sender, recipient, subject, text, date, unread, flagged. Newest first, header only by default

get_message

One message: headers, body as text, attachment list

get_attachment

Save one attachment to disk and return the path

mark_read

Mark read or unread

set_flag

seen, flagged, answered, draft, deleted

move_messages

Move or archive to another folder

delete_messages

Move to Trash, or erase permanently after confirmation

send_message

Send new mail, after a preview and confirmation

reply_to_message

Threaded reply, sender only or reply all, after a preview

create_draft

Save a draft for you to send yourself

Related MCP server: IMAP MCP Server

Safety rules built in

  • Reading never marks mail as read. Every fetch uses BODY.PEEK and folders open read only, so Claude browsing the mailbox does not change its state. get_message(mark_seen=True) is the only exception and has to be asked for.

  • Sending and permanent deletion take two steps. The first call returns the exact message or the exact target plus a confirmation_token and does nothing. Only a second call with commit=True and that token acts. Change any argument between the two calls and the token stops matching.

  • Delete means Trash. delete_messages moves to the Trash folder unless you pass permanent=True.

  • Per account read_only. Set "read_only": true on an account and every write tool refuses, while reading keeps working.

  • Sent mail is filed. SMTP does not copy what it sends, so after a send the same bytes are appended to the Sent folder, where your normal mail client expects them.

  • Attachments go to disk, never into the conversation.

Setup

  1. Install:

    uv venv --python 3.12
    uv pip install -e ".[dev]"
  2. Copy accounts.example.json to accounts.json and fill in your mail server details. Ask your host for the IMAP and SMTP settings if you do not have them. Passwords do not go in this file.

  3. Copy .env.example to .env and add one password per account. The variable name is the account name, uppercased, with anything that is not a letter or digit turned into an underscore: account work reads IMAP_PASSWORD_WORK. Add SMTP_PASSWORD_<NAME> only if the SMTP password differs.

  4. Prove the account works before wiring it in:

    .venv\Scripts\python.exe scripts\smoke.py
  5. Register the server with Claude Code:

    claude mcp add --scope user imap -- "C:\Claude Projects\IMAP MCP\.venv\Scripts\python.exe" -m imap_mcp.server

    Restart Claude Code and check /mcp.

Account fields

Field

Default

Notes

name

required

How you refer to the account in a prompt

imap_host

required

username

required

Usually the full email address

imap_port

993

143 for starttls or none

imap_security

ssl

ssl, starttls or none

smtp_host

none

Leave blank to disable sending

smtp_port

587

465 for ssl

smtp_security

starttls

ssl, starttls or none

smtp_username

username

Only if it differs

from_address

username

The address mail is sent as

from_name

blank

Display name on outgoing mail

sent_folder, trash_folder, drafts_folder

detected

Set these only if detection picks the wrong folder

read_only

false

Blocks every write tool for this account

verify_tls

true

Set false only for a host whose certificate is broken. The connection stays encrypted, the server identity stops being checked

timeout

60

Seconds

Sent, Trash and Drafts are found from the server's SPECIAL-USE flags, falling back to the usual names including the Dovecot style INBOX.Sent.

Shared hosting and certificates

Hosts like xneelo point mail.yourdomain.co.za at a shared server whose certificate is issued for the server's own name, so strict TLS verification fails on the vanity hostname even though the connection is fine. Find the real server name and use that instead:

python -c "import socket; print(socket.gethostbyaddr(socket.gethostbyname('mail.yourdomain.co.za')))"

That returns something like www12.cpt3.host-h.net, which its certificate does cover. The tradeoff is that if the host migrates your mailbox to another server, the hostname changes and login starts failing: rerun the line above and update accounts.json. The alternative is keeping the vanity hostname with "verify_tls": false.

Not supported

OAuth2, so Gmail and Microsoft 365 are out of scope: they have first party connectors already. Password authentication over TLS only. Gmail with an app password does work if you want it here anyway.

Tests

.venv\Scripts\python.exe -m pytest          # 35 unit tests, no network

End to end against a throwaway mail server in Docker, which exercises all 12 tools including sending, moving and permanent deletion without touching a real mailbox:

docker run -d --rm --name imapmcp-greenmail -p 3143:3143 -p 3025:3025 ^
  -e GREENMAIL_OPTS="-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled" ^
  greenmail/standalone:2.1.0
.venv\Scripts\python.exe scripts\e2e_greenmail.py
docker stop imapmcp-greenmail

Available Tools

12 tools
create_draftA

Save a draft in the Drafts folder for the user to review and send from their own mail client. Nothing is sent, so no confirmation is needed.

Inputs: cc, to, bcc, body, +4 more.

delete_messagesA

Delete messages. By default they move to Trash and can be recovered. permanent=True erases them, and that path previews first: call once to get a confirmation_token, then again with commit=True and that token.

Inputs: uid, uids, commit, folder, +3 more.

get_attachmentA

Save one attachment to disk and return the path. Identify it by index or filename from get_message. Defaults to the downloads folder in the project.

Inputs: uid, index, folder, account, +2 more.

get_messageA

Fetch one message by uid: headers, body as text, and the list of attachments (names and sizes, not their content). Long bodies are truncated at max_chars and flagged as such. The message stays unread unless mark_seen=True.

Inputs: uid, folder, account, mark_seen, +2 more.

list_accountsA

List the configured mailboxes and whether each has its password set.

Inputs: no named parameters.

list_foldersA

List every folder in a mailbox, with the detected Sent, Trash and Drafts folders. Folder names are case sensitive and may be nested, so always take names from here rather than guessing.

Inputs: account.

mark_readC

Mark one or more messages read (read_state=True) or unread.

Inputs: uid, uids, folder, account, +1 more.

move_messagesA

Move messages to another folder, for example to archive them. Use an exact folder name from list_folders. UIDs change on move.

Inputs: uid, uids, folder, account, +1 more.

reply_to_messageA

Reply to a message, keeping the thread intact. Goes to the sender only unless reply_all=True. Previews first and sends on the second call with commit=True and the confirmation_token, exactly like send_message.

Inputs: uid, body, commit, folder, +6 more.

search_messagesA

Search a folder and return message headers, newest first.

Dates are YYYY-MM-DD and IMAP compares by day only. 'text' is a server side substring search across the whole message and its behaviour varies by server. include_snippet=True adds the first 200 characters of each body, which means downloading every match, so keep the limit small when using it. raw_criteria takes a raw IMAP search string and overrides the other filters. Reading never marks anything as seen.

Inputs: text, limit, since, before, +10 more.

send_messageA

Send a new mail. The first call returns a preview of the exact message plus a confirmation_token and sends nothing. Call again with identical arguments, commit=True and that token to actually send. A copy is filed in the Sent folder. attachments are local file paths.

Inputs: cc, to, bcc, body, +6 more.

set_flagC

Add or remove an IMAP flag: seen, flagged, answered, draft or deleted.

Inputs: uid, flag, uids, value, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools have distinct purposes, but mark_read and set_flag overlap on the 'seen' flag, and delete_messages vs set_flag's 'deleted' could confuse agents. However, descriptions clarify the differences, so ambiguity is limited.

    Naming Consistency5/5

    All 12 tools follow a consistent verb_noun pattern in snake_case (e.g., delete_messages, get_attachment, list_folders). No stylistic deviations or mixed conventions.

    Tool Count5/5

    12 tools is within the ideal 3-15 range. Each tool covers a core email operation (send, read, search, manage), with no redundancies or missing essentials.

    Completeness4/5

    The surface covers key IMAP workflows: send, reply, draft, search, get message, attachment download, move, delete, flags, and folder/account listing. Minor gaps exist (e.g., folder creation, expunge, raw message fetch), but agents can accomplish typical tasks without failures.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      Enables Claude to interact with email accounts via IMAP and SMTP, providing tools for searching, reading, sending, and managing emails across multiple providers.
      40
      1,044 npm
      127
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to read, search, send, and manage emails across multiple IMAP/SMTP accounts via a single deployment.
      -
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to read, search, draft, send, flag, and move email across multiple IMAP/SMTP mailboxes while keeping credentials local.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Lets Claude Desktop read any IMAP mailbox and send emails via SMTP, with support for multiple mailboxes and locally stored credentials.
      13
      21 npm
      MIT