
mcp4mail
online.mcp4mail由 mcp4mail.online 发布官方发布者v1.0.0更新于 Nov 9, 2026
Your IMAP mailbox as an MCP server: read, search and (if you allow it) organize mail. Open source.
概览
通过 OAuth 将 IMAP 邮箱接入 AI 助手,可列出账户与文件夹、搜索和阅读邮件,并可选地整理邮件。
- 可以做什么
- 列出已连接的邮箱账户及其文件夹,查看账户连接信息但不显示密码
- 按主题、发件人、收件人、附件名和日期搜索邮件,并读取单封邮件
- 下载附件(短时链接或内联返回),并查找曾通信过的地址
- 仅在邮箱主人开启后修改邮箱:加旗标或标记已读、移动、移入垃圾箱、新建文件夹、保存草稿
- 准备待发邮件,并在人工批准后查询是否已发出
- 适用场景
- 适合让助手搜索和总结自己的 IMAP 邮件,或起草与整理邮件,而不必依赖 Gmail 或 Microsoft 的专用接口。也适合希望把邮箱凭据留在自己基础设施上的自托管用户。
- 运行要求
- 远程 MCP 端点 mcp4mail.online 并通过 OAuth 登录,或用 Docker Compose 自托管实例。需要一个 IMAP 账户的用户名和密码,最好使用应用专用密码。自托管需要 PostgreSQL,并通过 ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY、ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY 和 ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT 等环境变量提供加密密钥。
安装
在 SourceWeft 中
- 打开 控制台中的 mcp4mail,将其添加到工作区。
- 连接 所需的 凭据。它们会被私密存储,绝不会在公开页面上展示。
- 为需要使用其工具的对话启用该服务。
Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。
交给智能体安装
把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。
阅读 https://sourceweft.com/mcp/online.mcp4mail%2Fmcp4mail/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。其他 MCP 客户端
把它添加到你客户端的 mcpServers 配置中。 客户端会在首次连接时完成 OAuth 登录。
{
"mcpServers": {
"mcp4mail": {
"type": "http",
"url": "https://mcp4mail.online/mcp"
}
}
}README
mcp4mail
Your mailbox as an MCP server. Connect an IMAP account and let your AI assistant read and search your mail, authorized over OAuth 2.1. Hosted at mcp4mail.online, open source and self-hostable.
Run it yourself and your credentials never leave your machine. A hosted mail connector necessarily keeps
your IMAP password on someone else's server; with mcp4mail you can keep it in your own database instead. One
docker compose up gets you there: see the self-hosting guide.
mcp4mail is young, and we use it ourselves. Today it exposes the 14 tools listed below: list
your accounts and folders, search headers, read messages, download attachments and look up contacts. It can
also change a mailbox (flag, move, trash, create folders, save drafts, send), but only where the mailbox
owner switched on "Allow the AI to make changes" and ticked that permission; every mailbox is read-only by
default, and send_message only prepares an email that leaves after a human presses Send.
Try it
- Hosted: go to mcp4mail.online, sign up, connect an IMAP account, and add
https://mcp4mail.online/mcpto your MCP client. - Self-host:
cp .env.example .env, fill it in, thendocker compose up -d. See the self-hosting guide.
This project is primarily developed by AI developers orchestrated through mcptask.online. Watch the development happen live: https://mcptask.online/live
How this project is built
This is a real open-source product and, at the same time, a public demonstration. Tasks are written by
people in mcptask.online, picked up by runners (Claude Code driven by the
mcptask runner, on our own machines), and every change follows the same path: task → branch → pull request
→ tests & CI → merge → deploy to mcp4mail.online. Nobody, person or runner,
pushes to main directly: the branch is protected by a repository ruleset that requires an open pull
request, a linear history, and green status checks (security scans, lint, unit tests, system tests) before
a squash merge is allowed.
Watch it live: https://mcptask.online/live
The full story with the numbers: An open-source MCP server built by autonomous AI developers: the numbers (Dev.to, 30 October 2026).
Where to look if you want to verify any of this yourself: the Pull requests tab, where each
PR links its task and shows its CI runs, including the failed ones; CLAUDE.md and
.claude/, the instructions the runners work from; and the
CI configuration.
People still write the task briefs, review the pull requests, and decide what ships and what doesn't; a runner executes a task end to end, but it is not deciding what to build. A runner is a user with a seat here, not something free or unlimited.
MCP tools
Point your AI client at https://mcp4mail.online/mcp (or your own instance's /mcp URL) and sign in. Steps for
Claude, Claude Code, ChatGPT, Cursor and VS Code: docs/mcp-clients.md.
Write tools work only on a mailbox whose owner switched on "Allow the AI to make changes to this mailbox"
and ticked what the tool does; everywhere else they are refused, see
below. send_message never sends on its own: you get an email with a
link and the message leaves only when you press Send.
Self-hosting
Read docs/self-hosting.md first: which environment variables matter, why
HITCH_RESOURCE_URI must match your public URL exactly, TLS, and how mailbox passwords are stored.
Stack
Ruby 3.4, Rails 8.1, PostgreSQL, Hotwire (Turbo + Stimulus), Tailwind CSS, Solid Queue / Cache / Cable.
Development
PostgreSQL must be running locally; the default config connects over the local socket as your OS user.
Secrets
This repository is public. Nothing secret is ever committed: config/master.key, .env* and
credentials.yml are git-ignored, production secrets come from the environment.
Mailbox passwords are encrypted at rest with Active Record Encryption. In production, generate keys with
bin/rails db:encryption:init and provide them through the encrypted credentials
(active_record_encryption.*) or the ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY,
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY and ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT environment
variables. Development and test derive throwaway keys from the per-machine tmp/local_secret.txt.
Mail accounts
mcp4mail connects to your mailbox over plain IMAP with a username and password. Use an app-specific password wherever your provider offers one (Gmail, iCloud, Fastmail, Outlook.com, Yahoo and others do), so that what is stored in the database can be revoked on its own and is not the key to your whole account. Gmail is supported the same way: turn on two-step verification and sign in with an app password. On a Google Workspace account the administrator can switch off IMAP or app passwords, and only they can turn them back on. How the password is stored and who can decrypt it is described in the security notes of the self-hosting guide.
MCP endpoint: read-only by design
Every mailbox is read-only until you say otherwise. Each mailbox on the Mail accounts page has one switch, "Allow the AI to make changes to this mailbox", and it is off by default.
- Off (the default): the AI can only read and search. Any tool that would change the mailbox is refused
with a message telling the model the mailbox is read-only, and the refusal is written to the audit log as
denied. - On: checkboxes unfold under the switch and you tick what the AI may do in that mailbox: mark as read
and flag (
set_flags), move messages and create folders (move_message,create_folder), write drafts (create_draft), send and reply, always after your approval (send_message), delete to trash (trash_message). All are ticked when you switch it on. A tool whose box is unticked is refused the same way as on a read-only mailbox.list_mail_accountsandget_mail_accounttell the model what it may do.
The tool registry refuses to boot with a tool that is neither read-only and non-destructive nor explicitly
declared as a write tool (write_tool destructive: ..., permission: ... on McpTools::ApplicationTool,
where permission is one of the checkboxes above), so nothing can slip in as a write tool by accident.
Write tools announce readOnlyHint: false and declare their own destructiveHint.
What read-only does and does not mean, plainly:
-
Nothing can change a mailbox without its switch and the matching checkbox. Folders are opened with IMAP
EXAMINE, so even reading does not mark messages as seen. -
It does read your mail, whenever an AI client you connected asks. Connect only clients you trust with that.
-
It keeps a copy of message headers (sender, recipients, subject, date, flags, size) in its own database, refreshed every 15 minutes, so searches do not hit your mail server each time.
-
Scoping. Every tool resolves data through the signed-in user's own mail accounts; an account id that is not theirs is refused before any tool code runs.
-
Rate limits. Hitch limits each user + client pair (120 requests a minute); on top of that each user has one quota for tool calls across all their clients (240 a minute).
-
Audit log. Every call is written to
mcp_audit_events: user, client, tool, account, outcome, rows returned, duration. Arguments are not stored. -
Search guard. Pages are capped at 50 results, and each account has a budget of searches (60 per 10 minutes) and returned rows (1,000 an hour), so a runaway loop cannot walk a whole mailbox.
FAQ
Why IMAP and not the Gmail or Microsoft Graph API? The target user is on their own IMAP host, where there is no vendor API to call. Plain IMAP with a username and an app password works everywhere, so there is no Gmail or Microsoft OAuth. See Mail accounts.
Where is my mail password stored, and who can decrypt it? In PostgreSQL, encrypted with Active Record Encryption (AES-256-GCM). It is decrypted only in memory to open the IMAP connection, and never shown, returned by a tool or logged. Whoever holds the encryption keys can decrypt it; if you self-host, that is you.
Can the AI send or delete mail on its own?
No. Every mailbox is read-only until its owner switches on "Allow the AI to make changes" and ticks what is
allowed. Even then send_message only prepares an email that leaves after you press Send, and deleting
means trash_message, which moves to Trash. See
read-only by design.
Does it store my mail? Only message headers (sender, recipients, subject, date, flags, size), refreshed every 15 minutes so searches do not hit your mail server each time. Message bodies are read from your mail server when the AI asks for one.
Does it work with Outlook, Exchange or Gmail? Where the provider offers IMAP with an app password, yes: Gmail, iCloud, Fastmail, Outlook.com and Yahoo do. Whether an Exchange server allows IMAP is up to its administrator. See Mail accounts.
Is it free? Yes. It is MIT-licensed and self-hostable, and the hosted service at mcp4mail.online is run from the same code.
Contributing
See CONTRIBUTING.md. bin/ci must pass.
License
来源:README.md,提交 0758088
工具
0版本历史
1- v1.0.0最新Sep 28, 2026
评分
已满足适用检查项的 85%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通必需25 分
- 已声明认证方式必需10 分
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分