IMAP Mail MCP
Allows reading and searching emails from a Proton Mail account via the Proton Bridge IMAP interface.
Click on "Deploy 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 Mail MCP find unread billing emails"
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 Mail MCP
IMAP Mail MCP is an MCP (Model Context Protocol) server that lets LLM clients read email through IMAP tools.
It is designed for:
local AI workflows (Cursor, ollmcp, other MCP hosts)
mailbox exploration/search/summarization
extension by developers who want to add mail tools
Current implementation is read-only (list/search/fetch/status/thread context/attachment metadata).
What You Get
10 MCP tools for common mail workflows
consistent sorting and cursor pagination support
guardrails for result size and snippet size
deterministic tests plus CI
TypeScript codebase that is easy to extend
Related MCP server: Email MCP Server
Quick Start
1. Install
git clone https://github.com/FaisalFehad/imap-mail-mcp.git
cd imap-mail-mcp
cp .env.example .env
npm install
npm run build2. Configure .env
Set IMAP credentials in .env:
Variable | Required | Description | Typical Example |
| yes | IMAP host |
|
| yes | IMAP port |
|
| yes |
|
|
| yes | IMAP username |
|
| yes | IMAP password |
|
| no | validate TLS cert chain |
|
| no | max body chars in |
|
| no | global cap for list/search limits |
|
| no | max snippet chars when enabled |
|
Proton Bridge users usually run with IMAP_HOST=127.0.0.1, IMAP_PORT=1143, IMAP_SECURE=false.
3. Run
node dist/index.jsOr via package bin:
npx imap-mail-mcpCompatibility alias still works:
npx proton-bridge-mcpMCP Client Setup
Cursor
Add server config (Settings -> MCP):
{
"mcpServers": {
"imap-mail": {
"command": "node",
"args": ["/absolute/path/to/imap-mail-mcp/dist/index.js"],
"env": {
"IMAP_HOST": "127.0.0.1",
"IMAP_PORT": "1143",
"IMAP_SECURE": "false",
"IMAP_USER": "your@proton.me",
"IMAP_PASS": "your-bridge-password"
}
}
}
}ollmcp
Create
~/.config/ollmcp/mcp-servers/servers.json:
{
"mcpServers": {
"imap-mail": {
"command": "node",
"args": ["/absolute/path/to/imap-mail-mcp/dist/index.js"],
"env": {
"IMAP_HOST": "127.0.0.1",
"IMAP_PORT": "1143",
"IMAP_SECURE": "false",
"IMAP_USER": "your@proton.me",
"IMAP_PASS": "your-bridge-password"
},
"disabled": false
}
}
}Run:
ollmcp -j ~/.config/ollmcp/mcp-servers/servers.jsonIf ollmcp is not in PATH, use ~/.local/bin/ollmcp.
Tool Reference
Use mail_search_advanced as the default search entry point.
Tool | Use For | Notes |
| list mailboxes/folders | start here |
| list messages in one mailbox | supports |
| full message body by UID | returns envelope + body text |
| basic filter search | convenience wrapper |
| keyword/sender/receiver/subject/body/date/sent-date/read-state/message-id | primary search tool |
| counters for one mailbox | messages, unseen, recent, UID metadata |
| unread messages in a mailbox | same pagination/sort options as list/search |
| attachment metadata by UID | no binary download |
| free text query by selected fields | convenience wrapper |
| related messages around a UID | thread continuity for summarization/reply |
Common List/Search Options
Supported by list/search tools:
limit: requested size (clamped byMAIL_MAX_RESULTS)sort:ascordesc(defaultdesc)cursor: opaque cursor for next pageincludeSnippet: include snippet text in envelope resultsreturnPage: return{ items, nextCursor }instead of only array
Envelope result fields are stable:
{
"uid": 123,
"subject": "string",
"from": "comma-separated addresses",
"to": "comma-separated addresses",
"date": "ISO-8601 string",
"messageId": "optional string",
"snippet": "optional string"
}Example Workflows
Find unread billing mail in INBOX
mail_search_advancedwithmailbox=INBOX,keyword=bill,unseen=true,limit=20mail_get_messageon the most relevant UID
Summarize a conversation before drafting a reply
mail_get_thread_contextwith target UID andlimitfetch one or two full messages with
mail_get_messagesummarize using context
Scan a large folder in pages
mail_list_messageswithreturnPage=truepass returned
nextCursorto next call until absent
Developer Guide (Use This Codebase)
Project Layout
src/index.ts MCP server, tool schemas, handlers
src/imap.ts IMAP operations and query behavior
src/query.ts sorting/pagination/cursor/snippet helpers
src/config.ts environment parsing and defaults
tests/*.test.mjs deterministic testsAdd a New Tool
Add schema in
src/index.tstool list.Add handler branch in
src/index.tscall handler.Implement IMAP logic in
src/imap.ts.Add deterministic tests in
tests/.Update this README tool table.
Keep LLM Behavior Predictable
keep envelope field names stable
prefer additive changes (avoid breaking existing tool args)
keep default ordering deterministic
keep limits clamped
avoid expensive full-mailbox scans where possible
Testing
Run deterministic tests (no live mailbox required):
npm testRun live smoke test (requires real IMAP credentials):
node scripts/test-mcp.mjsCI runs:
npm cinpx tsc --noEmitnpm test
Troubleshooting
Error: Command failed no such user (NO)
Usually bad IMAP_USER/IMAP_PASS or temporary server lockout after failed attempts.
Check:
IMAP_USERis your IMAP login identity, not host/IPIMAP_PASSis correct for that IMAP accountfor Proton Bridge, use the Bridge-generated password
wait a few minutes after repeated failed login attempts
TLS errors (wrong version number, ssl3_get_record)
You are likely using TLS against a plain IMAP port.
Fix:
set
IMAP_SECURE=falsefor local plain IMAP endpoints (common with Bridge)verify port matches secure/non-secure mode
Self-signed cert errors
If your IMAP endpoint uses self-signed certs:
set
IMAP_TLS_REJECT_UNAUTHORIZED=false
ollmcp: command not found
Install via pip/pipx/uvx, or run with full path:
~/.local/bin/ollmcp -j ~/.config/ollmcp/mcp-servers/servers.jsonSecurity
never commit
.envor credential fileskeep IMAP credentials in MCP client env or local
.envthis implementation does not send or modify mail
License
MIT
Available Tools
10 toolsmail_get_mailbox_statusA
Get message counters for one folder (messages, unseen, recent, UID metadata).
Inputs: mailbox (required).
mail_get_messageA
Fetch one full message by folder and UID (envelope + body text).
Inputs: uid (required), mailbox (required).
mail_get_thread_contextA
Get related messages in the same thread context using Message-ID/References/In-Reply-To. Includes snippets by default.
Inputs: uid (required), mailbox (required), sort, limit, +2 more.
mail_list_attachmentsA
List attachment metadata for one message by folder and UID (no binary download).
Inputs: uid (required), mailbox (required).
mail_list_foldersA
List all mail folders (mailboxes). Use this to see INBOX, Sent, etc.
Inputs: no named parameters.
mail_list_messagesA
List recent messages in a folder (envelope only by default). Supports sort/cursor/snippet options.
Inputs: mailbox (required), sort, limit, cursor, +2 more.
mail_list_unreadA
List unread messages in a folder (envelope only by default). Supports sort/cursor/snippet options.
Inputs: mailbox (required), sort, limit, cursor, +2 more.
mail_query_by_folderB
Convenience free-text query in one folder. Prefer mail_search_advanced for canonical searches.
Inputs: query (required), mailbox (required), sort, limit, +4 more.
mail_searchA
Convenience folder search by basic fields. Prefer mail_search_advanced for richer filters and agent reliability.
Inputs: mailbox (required), to, body, from, +9 more.
mail_search_advancedC
Primary advanced search tool: keyword, sender/receiver, subject/body, date/date-range, sent-date-range, read state, message-id.
Inputs: mailbox (required), cc, bcc, body, +18 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Most tools have distinct purposes, but the three search tools (mail_query_by_folder, mail_search, mail_search_advanced) have overlapping functionality, which could lead to confusion despite the descriptions advising preference for mail_search_advanced.
The naming pattern is mostly 'mail_verb_noun' but uses inconsistent verbs (get vs list vs query) and mixes conventions between retrieval actions, creating slight inconsistency.
With 10 tools, the set is well-scoped for an IMAP-focused server, covering the essential operations for reading and searching emails without being excessive.
The server covers reading, searching, and thread context well, but notable gaps exist for common IMAP actions like marking messages as read/unread, deleting, or moving messages.
Maintenance
Related MCP Connectors
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Connect any IMAP/SMTP mailbox to Claude & ChatGPT: search, read, sort, draft. Sends only with OK.
Private, EU-hosted email for AI agents over JMAP: read, search, reply, draft, organize, send.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to read, search, and manage emails via IMAP with secure, read-only access to email accounts.6MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to read recent emails and fetch full email content from an IMAP inbox, allowing natural language queries about email summaries.3ISC
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with email accounts via IMAP and SMTP, supporting mailbox listing, email search, retrieval, sending, and management.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to read, send, organize, and search emails across multiple IMAP/SMTP mailboxes.756 npmMIT