Better Email Mcp

io.github.n24q02m由 GitHub 账号 n24q02m 发布v1.42.0更新于 Nov 3, 2026

IMAP/SMTP email for AI agents -- read, send, organize, and manage attachments across accounts.

已验证STDIO仅桌面文件与存储沟通与协作

概览

AI 生成的概览

本地 IMAP/SMTP 邮件服务器,让助手跨多个账户搜索、读取、发送、整理邮件并下载附件。

可以做什么
  • 跨账户和文件夹搜索、读取邮件,并标记已读/未读、加旗标、移动、归档或删除
  • 撰写新邮件、回复和转发,并保留会话线程头信息
  • 列出邮箱文件夹并读取单个文件夹的邮件数与未读数等状态
  • 列出并以 base64 内容下载邮件附件
  • 查看凭据配置状态,重置或重新解析配置,清除缓存
  • 按需获取任一工具的完整文档
适用场景
适合让助手整理收件箱、查找并总结邮件、起草回复或归档邮件,无需离开对话。适用于拥有一个或多个 IMAP 邮箱的用户,包括 Gmail、Outlook、Yahoo、iCloud、Zoho、ProtonMail Bridge 或自定义主机。
运行要求
通过 npx 或 Docker 以 stdio 在本地运行,也可自托管为带 bearer 令牌的 HTTP 服务。需要邮箱凭据:EMAIL_CREDENTIALS 按 地址:应用专用密码 填写,多账户用逗号分隔,或使用 EMAIL_USER 加 EMAIL_APP_PASSWORD。多数服务商需应用专用密码,Outlook 可用设备码 OAuth 登录。需要能访问邮件服务商的网络。
安装前请注意
服务器持有完整邮箱凭据,能运行它或读取环境变量的人即可读取邮件。发送、回复、转发、移动、归档和删除会真实改变邮箱状态。Outlook OAuth 令牌以明文 JSON 保存在本地文件。HTTP 模式下由共享 bearer 令牌保护端点,运维者可读取所存数据。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Better Email Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

email

mcp-name: io.github.n24q02m/better-email-mcp

IMAP/SMTP email for AI agents -- read, send, organize, and manage attachments across accounts.

[Mode] [CI] [codecov] [npm] [Docker] [License: Apache-2.0]

[TypeScript] [Node.js] [IMAP/SMTP] [semantic-release] [Renovate]

Sister projects from n24q02m (click to expand)
ProjectTaglineTag
agent-chat-pluginPeer AI agents chat in a shared folder — no human relay, no orchestrator, wor...Tooling
better-code-review-graphKnowledge graph for token-efficient code reviews -- semantic search and call-...MCP
better-drive2-way Google Drive sync with .driveignore filter — rclone engine, Windows trayTooling
better-email-mcpIMAP/SMTP email for AI agents -- read, send, organize folders, and manage att...MCP
better-godot-mcpComposite MCP server for Godot Engine -- 17 composite tools for AI-assisted g...MCP
better-notion-mcpMarkdown-first Notion for AI agents -- pages, databases, blocks, and comments...MCP
better-semantic-releaseDrop-in python-semantic-release fork with built-in release-safety guards (orp...Tooling
better-telegram-mcpTelegram for AI agents -- messages, chats, media, and contacts across both bo...MCP
better-workspace-mcpGoogle Workspace MCP server (Docs/Drive/Calendar/Gmail/Sheets/Slides/Tasks/Ch...MCP
claude-pluginsClaude Code plugin marketplace for the n24q02m MCP servers -- install web sea...Marketplace
imagine-mcpImage and video understanding + generation for AI agents -- across Gemini, Op...MCP
jules-task-archiverChrome Extension for bulk operations on Jules tasks via batchexecute API -- a...Tooling
mcp-coreShared foundation for building MCP servers -- Streamable HTTP transport, OAut...MCP
mnemo-mcpPersistent AI memory with hybrid search and embedded sync. Open, free, unlimi...MCP
qwen3-embedLightweight Qwen3 text embedding and reranking via ONNX Runtime and GGUFLibrary
skretSecrets without the server.CLI
tacetA self-distilling neuro-symbolic cascade that amortises LLM cost across knowl...Tooling
web-coreShared web infrastructure package for search, scraping, HTTP security, and st...Library
wet-mcpOpen-source MCP server for AI agents: web search, content extraction, and lib...MCP

Table of contents

[Better Email MCP server]

Features

  • Multi-account support -- manage 6+ email accounts (Gmail, Outlook, Yahoo, iCloud, Zoho, ProtonMail, custom IMAP)
  • App Passwords -- no OAuth2 setup required for most providers; clone and run in 1 minute
  • 4 composite tools (plus help) -- search, read, send, reply, forward, organize, and credential status in single calls
  • Auto-discovery -- provider settings detected from email address, custom IMAP host supported
  • Thread-aware -- reply/forward maintains In-Reply-To and References headers
  • Tiered token optimization -- compressed descriptions + on-demand help tool + MCP Resources

Install

The server runs in two modes: stdio (default, single-user, credentials from env vars) and HTTP (opt-in, single-user with a bearer token). For stdio, add it to your MCP client config:

jsonc
{  "mcpServers": {    "email": {      "command": "npx",      "args": ["--yes", "@n24q02m/email@latest"],      "env": {        "EMAIL_CREDENTIALS": "[email protected]:app-password"      }    }  }}

The package is @n24q02m/email (formerly @n24q02m/better-email-mcp; old package receives one final release then freezes). The MCP Registry id stays io.github.n24q02m/better-email-mcp, and the legacy better-email-mcp command is kept as an alias of email.

Multiple accounts are comma-separated: [email protected]:pass1,[email protected]:pass2. See Configuration for all env vars, and Remote (HTTP Mode) to run a hosted multi-user server.

Most providers use an App Password (no OAuth setup); Outlook/Hotmail/Live use a bundled OAuth device-code flow in HTTP mode. Settings (IMAP/SMTP host, port) are auto-discovered from the email domain.

Install matrix

ClientInstall
Claude Code/plugin marketplace add n24q02m/claude-plugins + /plugin install better-email-mcp@n24q02m-plugins (stdio; prompts for EMAIL_CREDENTIALS), or an mcpServers entry in .mcp.json / client settings
Codex CLI[mcp_servers.email] block in ~/.codex/config.toml (stdio command/args or HTTP type/url)
OpenCodemcpServers block in opencode.json
Cursor / Windsurf / Gemini CLI / any MCP clientmcpServers JSON in the client's config — same shape as the example above

Full per-client walkthroughs: docs.n24q02m.com/servers/email/setup/.

CLI

The package ships one binary, email (run via npx @n24q02m/email), also installed under its legacy name better-email-mcp. With no arguments it starts the MCP server over stdio; it also accepts one flag and one subcommand:

InvocationDescription
emailStart the MCP server over stdio (default). Reads credentials from EMAIL_CREDENTIALS, or from EMAIL_USER + EMAIL_APP_PASSWORD
email --httpStart the server in HTTP (single-user, bearer token) mode. Equivalent to MCP_TRANSPORT=http or TRANSPORT_MODE=http
email auth [outlook] <email> [--client-id=<id>]Authenticate an Outlook/Hotmail/Live account via OAuth2 Device Code flow. Tokens are saved to ~/.better-email-mcp/tokens.json. The outlook provider positional is optional (email has a single OAuth2 provider); --client-id overrides OUTLOOK_CLIENT_ID for a self-hosted Azure AD app
email logout [<email>]Clear the locally stored Outlook token(s). Omit <email> to clear every stored token
bash
# stdio server (normally launched by your MCP client, not by hand)EMAIL_CREDENTIALS="[email protected]:app-password" npx @n24q02m/email
# HTTP multi-user servernpx @n24q02m/email --http
# One-off Outlook OAuth device-code sign-innpx @n24q02m/email auth [email protected]
# Sign out of a single account (or omit the email to clear all)npx @n24q02m/email logout [email protected]

auth/logout are only for Outlook/Hotmail/Live addresses -- other providers use an App Password in EMAIL_CREDENTIALS. See Remote (HTTP Mode) for the HTTP config.

Smithery

Published with a Smithery config (smithery.yaml). Smithery runs the server over stdio with no build config required; credentials come from the environment (see Configuration). The start command is:

yaml
startCommand:  type: stdio  commandFunction: |-    (config) => ({ command: 'npx', args: ['-y', '@n24q02m/email'] })

Documentation

Full docs at docs.n24q02m.com/servers/email/:

  • Setup -- install methods for Claude Code, Codex, Gemini CLI, Cursor, Windsurf, mcp.json

Install with AI agent -- paste this to your AI coding agent:

Install MCP server email following the steps at https://raw.githubusercontent.com/n24q02m/claude-plugins/main/plugins/better-email-mcp/setup-with-agent.md

Tools

Public tool rename

The public send tool is replaced by messages with action: new, reply, or forward. This follows the MCP N+2 standard: sending is an action in the messages domain, so keeping a separate send entry would duplicate that domain and add redundant tool-list and help-topic surface. The old name is removed directly; there is no compatibility alias.

Old public nameNew public nameReasonAlias removal
sendmessages (action: new | reply | forward)N+2 domain-tool rule: outbound mail is part of the messages mega-tool, not a second action-level tool.Removed directly in the Unreleased release; no alias
ToolActionsDescription
messagessearch, read, mark_read, mark_unread, flag, unflag, move, archive, trash, new, reply, forwardSearch, read, organize, compose, reply to, and forward emails
folderslist, statusList mailbox folders or read targeted IMAP STATUS metadata
attachmentslist, downloadList and download email attachments
configstatus, setup_status, setup_start, setup_reset, setup_complete, set, cache_clearCredential status and setup guidance, reset, re-resolve, cache clear
help-Get full documentation for any tool

MCP Resources

URIDescription
email://docs/messagesMessage operations reference
email://docs/foldersFolder operations reference
email://docs/attachmentsAttachment operations reference
email://docs/helpFull documentation
email://docs/configCredential setup and runtime configuration reference

Comparison

How email stacks up against direct competitors in each pillar:

Capabilityemailemail-mcpGmail-MCP-Servermcp-mail-server
IMAP/SMTP (provider-agnostic)YesYesNo (Gmail API only)Yes
Multi-accountYes (comma-separated creds)YesNo (single global credential)No (single account per instance)
App PasswordsYes (no OAuth setup)YesNo (OAuth2 only)Yes
Auto-discovery from email addressYesYes (8 providers)n/a (Gmail only)No (manual host/port)
Bundled Outlook OAuth (no user Azure app)Yes (device-code, Thunderbird-pattern client)partial (OAuth2 XOAUTH2, experimental)No (user-supplied Google OAuth)No
Attachments (list + download)YesYesYesYes
HTTP mode (single-user, bearer token; self-hostable)YesNo (stdio only)No (stdio only)No (stdio only)

Remote (HTTP Mode)

Run as a single-user HTTP server, authenticated with a shared bearer token:

jsonc
{  "mcpServers": {    "email": {      "type": "http",      "headers": { "Authorization": "Bearer <your-token>" },      "url": "https://<your-host>/mcp"    }  }}

Self-Hosting (HTTP Mode)

Single-user mode: one shared bearer token; accounts come from env vars or email auth outlook <address>:

bash
export EMAIL_MCP_TOKEN_HASH='scrypt$...'  # required: the container binds 0.0.0.0 and refuses to start without itexport EMAIL_CREDENTIALS='[email protected]:app-password'docker run -p 8080:8080 \  -e PORT=8080 \  -e EMAIL_MCP_TOKEN_HASH \  -e EMAIL_CREDENTIALS \  -e HOME=/data \  -v email-data:/data \  n24q02m/email:latest

Mint the hash with printf '%s' "$TOKEN" | email token hash; the token is read from stdin, never argv. Clients send the raw token as Authorization: Bearer <token>. Saved Outlook tokens live under /data/.better-email-mcp/ and persist when the /data volume is kept.

Self-Hosting with Docker Compose

The repository ships docker-compose.http.yml, which builds the http image target and publishes it on host loopback only (127.0.0.1:8082):

bash
export EMAIL_MCP_TOKEN_HASH='scrypt$...'   # required; see the note aboveexport EMAIL_CREDENTIALS='[email protected]:app-password'docker compose -f docker-compose.http.yml up

The server is then reachable at http://localhost:8082. To serve other machines, put your own TLS reverse proxy on the same host in front of the loopback port. Prebuilt multi-arch images are published to Docker Hub (n24q02m/email) and GHCR (ghcr.io/n24q02m/email).

Outlook OAuth Device Code

Outlook/Hotmail/Live accounts use OAuth2 device-code. Run email auth outlook <address> once. On first use:

  1. The CLI prints a device code and a Microsoft login URL
  2. Open the URL in a browser and enter the code
  3. Sign in and authorize the app
  4. Tokens are saved to ~/.better-email-mcp/tokens.json (created with mode 0600 on POSIX). In Docker that path is /data/.better-email-mcp/tokens.json.

OAuth uses the bundled public Azure client (d56f8c71-9f7c-43f4-9934-be29cb6e77b0, Thunderbird-pattern) -- no user-side Azure registration needed.

In stdio mode, Outlook accounts use an App Password instead (Outlook Account Settings → Security → Advanced security options → App passwords).

Configuration

To trust mise configuration automatically, set trusted_config_paths in the user-level config at ~/.config/mise/config.toml; do not add it to this project's .mise.toml.

VariableRequiredDefaultDescription
EMAIL_CREDENTIALSYes (stdio)-Email credentials, email:app-password per account, comma-separated for multi-account. Optional custom IMAP host/port: email:password:imap_host:imap_port
EMAIL_USERAlternative (stdio, single-account)-Email address. Used with EMAIL_APP_PASSWORD as a per-field alternative to EMAIL_CREDENTIALS; merged into EMAIL_CREDENTIALS at boot
EMAIL_APP_PASSWORDAlternative (stdio, single-account)-App password (Gmail/Yahoo/iCloud) or Outlook App Password; used with EMAIL_USER
PORTNo0 (OS-assigned)Server port (http mode); set explicitly (e.g. 8080) to bind a fixed port
HOSTNo-Bind address (http mode)
EMAIL_MCP_TOKEN_HASHNo (http; required when not bound to loopback)-scrypt hash of the shared bearer token, minted with email token hash. Without it, HTTP runs unauthenticated only on loopback
OUTLOOK_CLIENT_IDNod56f8c71-9f7c-43f4-9934-be29cb6e77b0 (bundled public client)Override the bundled Azure AD public client for self-hosted Outlook OAuth2 (or --client-id=<id> on auth, which overrides this env var)
OUTLOOK_EMAILNo-Workaround when Microsoft device-code response omits the email field
OUTLOOK_TENANTNoconsumers (stdio/CLI), common (http device-code)Microsoft directory to sign in against, used for both the device-code and the token-refresh endpoint. Set common for a work/school (Entra ID) mailbox, or a tenant GUID / verified domain to pin one directory
OUTLOOK_SCOPESNohttps://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send offline_accessSpace-separated scope list. Narrow it (e.g. drop SMTP.Send) for a read-only deployment — a grant consented with fewer scopes cannot be refreshed against the full list
OUTLOOK_EXTRA_DOMAINSNo-Comma-separated domains routed to OAuth in addition to outlook.com/hotmail.com/live.com. Needed for a Microsoft 365 mailbox on your own domain, which otherwise looks like a password account

Multiple Accounts

Custom IMAP Host

bash
# Custom hostname (default port 993, implicit TLS)[email protected]:password:imap.custom.com
# Custom hostname with a custom port[email protected]:password:imap.custom.com:1993
# Local IMAP proxy -- "localhost" is accepted as a host, even without a dot[email protected]:password:localhost:1993

Each account can use its own host and port. A non-993 port is treated as plaintext/STARTTLS -- the usual shape for a local IMAP proxy (for example email-oauth2-proxy).

Microsoft 365 work/school accounts

A mailbox in a Microsoft 365 organisation -- including one on your own domain -- signs in through Entra ID rather than the consumer directory, and Microsoft disabled basic auth for Exchange Online in 2024, so an App Password is not an option. Two settings make it work:

bash
# Sign in against the directory that owns the mailboxOUTLOOK_TENANT=common                      # or a tenant GUID / verified domain
# Route your own domain to OAuth instead of asking for a passwordOUTLOOK_EXTRA_DOMAINS=company.com

OUTLOOK_TENANT applies to the token refresh as well as the initial sign-in -- refreshing a work/school token against the consumer directory fails with AADSTS7000012: The grant was obtained for a different tenant.

If the mailbox was consented with a narrower grant (say IMAP but no SMTP), match it with OUTLOOK_SCOPES so the refresh does not ask for more than was granted.

Search Query Language

QueryDescription
UNREADUnread emails
FLAGGEDStarred emails
SINCE 2024-01-01Emails after date
FROM [email protected]Emails from sender
SUBJECT meetingEmails matching subject
UNREAD SINCE 2024-06-01Compound filter

Supported Providers

ProviderAuthSave-to-Sent
GmailApp PasswordAuto (skipped)
YahooApp PasswordAuto (skipped)
iCloud/Me.comApp-Specific PasswordAuto (skipped)
Outlook/Hotmail/LiveOAuth2 (Device Code)IMAP APPEND
ZohoApp PasswordIMAP APPEND
ProtonMailProtonMail BridgeIMAP APPEND
CustomVia email:pass:imap.hostIMAP APPEND

Security

  • Credential sanitization -- Passwords never leaked in error messages
  • App Passwords -- Uses app-specific passwords, not regular passwords
  • Token storage -- Outlook OAuth tokens are written with mode 0600 on POSIX (not enforced on Windows)
  • IMAP validation -- Search queries validated before execution

Build from Source

bash
git clone https://github.com/n24q02m/email.gitcd emailbun installbun run dev

Trust Model

Credentials are single-user: whoever runs the server (or your OS user for stdio) can read them. Storage depends on the deployment mode:

ModeStorageEncryptionWho can read your data?
HTTP (Docker)Env vars (EMAIL_CREDENTIALS) and saved Outlook tokens in $HOME/.better-email-mcp/tokens.json (the /data volume)Tokens: plain JSON, POSIX file mode 0600Server operator
stdioEnv vars; saved Outlook tokens in ~/.better-email-mcp/tokens.json; legacy config.enc from earlier releases is still readTokens: plain JSON, POSIX file mode 0600Only your OS user

License

Apache-2.0 -- See LICENSE.

来源:README.md,提交 4fca8ab

工具

5

messages

Messages

Search, read, manage, compose, and send email messages. Actions (required params -> optional): - search (-> account, query="UNSEEN", folder="INBOX", limit=20) - read (account, uid -> folder, preview, max_chars) - mark_read / mark_unread / flag / unflag (account, uid|uids -> folder) - move (account, uid|uids, destination -> folder) - archive / trash (account, uid|uids -> folder) - new (account, to, subject, body -> cc, bcc, attachments) - reply (account, uid, body -> to, folder, attachments) - forward (account, uid, to, body -> folder, attachments) Read preview mode returns at most max_chars (default 4000) and includes truncation metadata; omit preview for the full body. Query examples: "UNREAD", "FROM [email protected]", "SINCE 2026-01-01", "UNREAD FROM [email protected]". Date format MUST be YYYY-MM-DD. Outbound bodies support plain text or HTML. Attachments use base64 content, max 10 files and 25MB decoded total.

输入参数cctobccuidbodyuidslimitqueryaction必填folderaccountpreview另有 4 个

folders

Folders

List mailbox folders or read targeted mailbox status metadata. Actions (required params -> optional): - list (-> account): folder names, paths, and flags for one or all accounts - status (account, folder): IMAP STATUS messages, unseen, and uid_next for exactly one mailbox

输入参数action必填folderaccount

attachments

Attachments

List and download email attachments. Actions (required params -> optional): - list (account, uid -> folder): show attachments with filename, content_type, size - download (account, uid, filename -> folder): get base64-encoded content Use list first to get exact filenames. Case-sensitive. Max 25MB per provider.

输入参数uid必填action必填folderaccount必填filename

config

Config

Manage email credential setup and runtime configuration. Setup actions (credential lifecycle): - status: Show current credential state and configured accounts - setup_status: Show credential state only (no accounts list; cross-server parity action) - setup_start: Show how to supply credentials (EMAIL_CREDENTIALS env var or `email auth` CLI) - setup_reset: Clear stored credentials and reset to awaiting_setup state - setup_complete: Re-check credential state after credentials were supplied Runtime actions: - set: Update runtime settings (email has no runtime settings; returns ok=false) - cache_clear: Clear IMAP folder caches and the OAuth token cache

输入参数action必填

help

Help

Get full documentation for a tool. Use when compressed descriptions are insufficient.

输入参数tool_name必填

版本历史

2
  1. v1.42.0最新Oct 29, 2026
  2. v1.41.5Sep 16, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分