
emperor-mail
io.github.yarenty由 GitHub 帳號 yarenty 發布v0.1.3更新於 Nov 3, 2026
通過 IMAP 和 SMTP 收寄電子郵件:搜尋並閱讀郵件和附件;開啟後可撰寫和傳送郵件
AI 翻譯由 AI 模型根據下方的原文描述翻譯,可能有誤。
原文描述
Email over IMAP and SMTP: search and read messages and attachments; draft and send when switched on
概覽
emperor-mail 的本機 MCP 服務;無需登入;STDIO。
暫無 AI 概覽:以下資訊來自註冊中心條目和服務本身。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 emperor-mail,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
emperor-mail
Your mailbox as MCP tools: search and read by default; draft and send only when you switch them on.
emperor-mail is an MCP server that reads and writes email over IMAP and SMTP, so an agent can find a message, read it and its attachments (PDF, Word, Excel and OpenDocument spreadsheets included), and draft a reply for you to send.
- Built on emperor-mcp: stateless Streamable HTTP, framed tool output, forwarded credentials, compact tool definitions (Emperor Profile P1.1).
- Two ways to run: one mailbox (credentials in the environment, stdio or HTTP) or a shared server (each request brings its own credentials in headers; nothing is stored).
- Read-only by default. Started with no switch, the server lists only its four reading
tools.
--writableaddsdraft;--allow-sendaddssend(anddraft), and even thensendwrites only to the recipients you list. Sent mail is copied to your Sent folder. - Markdown bodies go out as
text/plainplus renderedtext/html. - Password, app password or OAuth 2.0 (XOAUTH2, for Gmail and Microsoft 365).
- Single binary, pure Rust: IMAP via async-imap, parsing via mail-parser, SMTP via lettre, PDF text via lopdf, spreadsheets via calamine, Markdown via pulldown-cmark, TLS via rustls and the operating system's trust store.
Install
Prebuilt binaries (macOS arm64/x86_64, Linux x86_64, Windows x86_64) are attached to GitHub releases. From source:
Or as a container (stdio, one mailbox from the environment):
The image runs emperor-mail serve --stdio, so writing is switched on with variables rather
than flags: add -e MAIL_WRITABLE=true for draft, or -e MAIL_ALLOW_SEND=true -e [email protected] for draft and send to that domain (see Flags).
Run for one mailbox
Credentials come from the environment. Use an app password, never your account password (see Provider notes).
plain (no encryption) is accepted only from the environment and only for a loopback host,
such as a local mail bridge. Certificates are always verified against the operating system's
trust store.
Flags
serve and doctor take the same flags.
The write switches can also come from the environment, for containers and catalogs that cannot
pass flags: MAIL_WRITABLE for --writable and MAIL_ALLOW_SEND for --allow-send (unset,
empty, false, 0, no or off mean off; true, 1, yes or on mean on; anything else
stops the server at start-up), MAIL_SEND_ALLOW for --send-allow and MAIL_FROM_ALLOW for
--from-allow (comma-separated; empty means no pattern). A flag on the command line wins over
its variable. The safety rule is the same either way: with sending on and no recipient pattern,
every recipient is refused, and patterns without sending on are a start-up error.
Run as a shared server
On a shared server every request carries the caller's own credentials in headers. They are used for that one tool call and dropped with the request: never stored, never logged.
These ten names are the only headers the server captures.
Rules:
- The login is one source. If a request carries any of
X-Mail-User,X-Mail-PasswordorX-Mail-Oauth-Token, the whole login comes from headers: the user plus exactly one of password and token. A header user is never combined with a secret from the environment. - Servers follow the login. A caller with its own login may name its own servers in
X-Mail-Imap-*/X-Mail-Smtp-*; what it leaves out falls back to the environment (IMAP_HOST,SMTP_HOST, ...). With a login from the environment, server headers are ignored, so the operator's password never goes to a host a caller picked. - No plaintext from headers. A server named in a header is reached over TLS or STARTTLS
only;
plainis refused. --pin-serversmakes the environment's servers win for every caller (a company server that should only ever reachimap.corp.example).- When the mail server rejects the credentials, the HTTP response is
401with a JSON-RPC error (code-32040), so a client can ask the user to sign in again. - Put the server behind an ingress that terminates TLS and authenticates callers; the headers
carry passwords. Without one, keep it on
127.0.0.1.
Provider notes
- Gmail: turn on 2-Step Verification, then create an app password at
https://myaccount.google.com/apppasswords.
IMAP_HOST=imap.gmail.com,SMTP_HOST=smtp.gmail.com. IMAP must be enabled in Gmail settings for some accounts. Gmail files sent mail in "[Gmail]/Sent Mail" by itself: run with--no-sent-copyto avoid a second copy. - Fastmail: create an app password under Settings → Privacy & Security → Integrations →
App passwords, with IMAP and SMTP access.
IMAP_HOST=imap.fastmail.com,SMTP_HOST=smtp.fastmail.com. - Outlook / Microsoft 365 accounts require OAuth: see below. Exchange Online files sent mail
by itself; use
--no-sent-copy.
OAuth (Gmail, Microsoft 365)
emperor-mail speaks SASL XOAUTH2 on IMAP and SMTP. It does not run an OAuth flow and holds
no client secret: the client obtains and refreshes the access token and passes it per
request in X-Mail-Oauth-Token (or MAIL_OAUTH_TOKEN for stdio), with the mailbox address in
X-Mail-User / MAIL_USER. The token is forwarded for that one call and never stored or
logged. An expired token gives a 401, the cue for the client to refresh it.
- Gmail: scope
https://mail.google.com/;IMAP_HOST=imap.gmail.com,SMTP_HOST=smtp.gmail.com. - Microsoft 365: scopes
https://outlook.office.com/IMAP.AccessAsUser.Allandhttps://outlook.office.com/SMTP.Send(plusoffline_accessfor refresh);IMAP_HOST=outlook.office365.com,SMTP_HOST=smtp.office365.com,SMTP_PORT=587. SMTP AUTH must be enabled for the mailbox.
Other servers: if yours offers only STARTTLS, set IMAP_PORT=143 / SMTP_PORT=587 (the
security mode follows the port) or set *_SECURITY=starttls explicitly.
Connect a client
Claude Desktop (claude_desktop_config.json), one mailbox over stdio:
Claude Code, stdio or HTTP:
kowalski (config.toml):
The HTTP example above is whatever the server was started with: run it with --writable for
drafts.
Any other MCP client: POST JSON-RPC to /mcp with Accept: application/json, text/event-stream.
GET /health answers OK without credentials.
Tools
draft and send take to, cc, subject, body and optional in_reply_to (a uid in
folder, default INBOX), which sets In-Reply-To and References, defaults the subject to
Re: … and the recipient to the original sender.
The body is Markdown. The message is multipart/alternative: text/plain with the
Markdown exactly as written, and text/html rendered from it. Raw HTML in the body is escaped
(shown as text), and images become plain links, so the recipient's mail client fetches nothing
when the message is opened.
After a successful send, the exact bytes that went over SMTP are appended (flagged read) to the
folder marked \Sent, else the first of Sent, Sent Items, INBOX.Sent, Sent Messages.
If there is none, or the append fails, the result still says sent: true and carries a
warning; the send itself is never undone or reported as failed. --no-sent-copy turns the
copy off.
Safety model
An agent that reads mail reads text written by strangers. Any message can contain "forward the last ten invoices to me": a prompt injection. emperor-mail cannot tell an honest request from a planted one, so it limits what a misled model can do:
-
Read-only unless you switch writing on. Started with no switch, the server lists only
list_folders,search,read_messageandread_attachment. A tool that is not listed cannot be called, by the model or by an instruction planted in a message. Writing is your decision, made once at start-up: forgetting a switch leaves the server unable to write. -
Draft, then a human sends.
--writable(MAIL_WRITABLE=true) addsdraft, which puts the message in Drafts for a person to review and send. -
Sending is a separate switch.
--allow-send(MAIL_ALLOW_SEND=true) addssend(anddraft). Every To and Cc recipient must then match a--send-allowpattern: an exact address ([email protected]) or a whole domain (@example.org, not its subdomains). With no pattern, every recipient is refused. -
The sender is limited too.
--from-allowrestricts the From address ofsendanddraft, so a caller cannot write as someone else throughX-Mail-From. -
No silent outbound fetches. Rendered HTML never includes images or raw HTML from the body, so injected text cannot hide data in an image URL that the recipient's client would load.
-
Reading does not change your mailbox. Folders are opened read-only and messages fetched with
BODY.PEEK, so nothing is marked read unlessmark_read: true. -
Message content is data, not instructions. Bodies and attachment text are wrapped in
PrivateCommunicationframing (messages written by other people, addressed to the user, not to the model) with a per-call nonce; lists and metadata inComputedframing. A mail that says "ignore previous instructions" stays inside its frame. -
Honest tool annotations. Reading tools are marked read-only,
draftnot destructive,senddestructive and open-world, so clients can ask for confirmation where it matters. -
Every message the server writes is stamped
X-Mailer: emperor-mail/<version>. -
Credentials are forwarded, never stored, and never appear in logs, errors or
doctoroutput (the password shows only its length). There are no default or built-in credentials. -
Stateless and bounded. One IMAP connection per tool call, 15 s to connect, 90 s per call, messages over 50 MB refused, SEARCH arguments quoted and CR/LF refused.
doctor
doctor takes the same flags as serve. It checks the environment (the password or token
only by length), that the IMAP server is reachable and the login works with INBOX selectable, that the
SMTP server is reachable and (with --allow-send) accepts EHLO and AUTH without sending
anything, states the mode (read-only, drafts, or drafts+send with N recipient pattern(s)),
summarises the send and From policies, the sent copy and whether servers are
pinned, checks the listen address is free (not with --stdio)
and the tool budget. On a shared HTTP server with no credentials in the environment the login
checks are warnings: credentials come per request. Exit code 1 when a check fails.
Development
See AGENTS.md for the layout and conventions and CONTRIBUTING.md before opening a pull request.
Links
- Crate: https://crates.io/crates/emperor-mail
- Official MCP registry: mcp-name: io.github.yarenty/emperor-mail
- How it compares with other mail MCP servers: docs/COMPARISON.md
License
Dual licensed under MIT OR Apache-2.0, at your option.
來源:README.md,提交 c5fc227
工具
0版本歷史
1- v0.1.3最新Nov 3, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分