imap-mcp

imap-mcp

Connects any IMAP mailbox and turns email into markdown notes for search and RawItem records for the Mycelium runtime.

Category
访问服务器

README

imap-mcp

Connect any mailbox to your second brain.

An MCP server that reads mail over IMAP — iCloud, Gmail, Outlook, Fastmail, university or company mail, anything that speaks the protocol — and turns it into markdown notes you can search, plus RawItem records the Mycelium runtime ingests directly.

MIT licensed. Runs on macOS, Linux, and Windows.

Why IMAP

Every mail provider speaks IMAP. One connector covers all of them, which matters when a room full of people each bring a different mailbox.

Where a provider already has a proper OAuth connector, prefer it — google-workspace-mcp for Gmail, microsoft-365-mcp for Outlook. OAuth gives scoped, revocable access; an IMAP app password does not. This server is for the mailboxes those two cannot reach: iCloud, which publishes no OAuth grant for Mail at all, and every smaller or self-hosted provider.

Supported providers

Provider Host Notes
icloud imap.mail.me.com Needs 2FA on the Apple ID
gmail imap.gmail.com Prefer the OAuth connector; needs 2-Step Verification
outlook outlook.office365.com Prefer the OAuth connector; many tenants disable IMAP
fastmail imap.fastmail.com App passwords can be scoped to IMAP only
generic you set IMAP_HOST University, company, self-hosted

Ask the server itself with imap_list_providers — it returns each provider's host and the exact page where you mint a password.

Setup

See SETUP.md. Three steps, and you mint the password yourself.

Tools

Tool Access Purpose
imap_list_providers read providers + where to get a password
imap_health read is it reachable, does the credential work
imap_list_mailboxes read exact folder names
imap_search_messages read compact summaries, no bodies
imap_read_message read one full message
imap_sync_to_vault write notes into your vault
imap_export_for_runtime read RawItem records
imap_explain_filter read why a message was or wasn't ingested

Eight actions, under the ~15 threshold where a search+execute surface starts paying for itself, so it's one tool per action.

Safety

Your mailbox is never modified. Sessions open with EXAMINE (read-only) and every fetch uses BODY.PEEK[]. A plain FETCH BODY[] sets the \Seen flag as a side effect, so a "read-only" sync would quietly mark your unread mail as read. The only tool that writes anything writes notes into your vault.

Your password never leaves your machine. It lives in the OS keychain, is never written to a config file, never logged, and never returned by a tool. IMAP LOGIN failures echo the failed command back — which contains the password — so auth errors are replaced wholesale rather than passed through.

Email is treated as untrusted input. Every message body is wrapped in an UNTRUSTED_EMAIL_BODY fence, and a body that forges the closing marker to break out of its own fence is neutralised. Mail is data to summarise, never instructions to follow. This matters more than it sounds: anyone can send you an email, so an unfenced body is a stranger writing directly into your assistant's context.

Nothing is skipped silently. If the server renumbers a mailbox (UIDVALIDITY changed), the sync cursor is discarded and the response says uidvalidity_reset: true — a stale cursor would otherwise point at unrelated messages and skip real mail forever. Filtered messages carry the rule that dropped them, and imap_explain_filter explains any single one.

Every write says where it went. Results carry vault_root and root_source, so mail landing in the wrong folder is visible in the first response rather than discovered months later.

Filter

Smart defaults keep what matters and drop the noise. Folder names differ by provider and by language, so they come from the provider profile rather than being hardcoded — Gmail nests under [Gmail]/, Outlook says Junk Email, a Spanish-locale account says Enviados.

Keep Drop
mail you sent spam / junk / trash folders
threads you replied to (\Answered) newsletters (List-Unsubscribe)
flagged mail (\Flagged) noreply@-style automated senders

Explicit block beats explicit allow; both beat smart defaults. Turn defaults off entirely with apply_smart_filter=False.

Two consumers, one core

imap_client.py is the only module that speaks IMAP.

  • Second brainimap_sync_to_vault writes External Inputs/<Provider>/<mailbox>/YYYY-MM-DD-<slug>.md
  • Mycelium runtimeimap_export_for_runtime emits records matching the runtime's RawItem field-for-field, so the server-side adapter wraps this rather than reimplementing it

Tests

uv run pytest -q

65 tests, no network required. The security guards (fence escaping, path containment, credential non-leakage) have each been mutation-tested: the guard removed, the matching test confirmed failing, the guard restored.

Not yet verified: no live smoke test has run against a real mailbox on any provider. Every test uses synthetic fixtures, which proves the parsing and filtering logic but not that a live server accepts these exact commands.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选