
Email (IMAP/SMTP)
io.github.boutquin由 GitHub 账号 boutquin 发布v1.0.1更新于 Oct 25, 2026
Multi-account IMAP/SMTP email server with 22 tools for reading, sending, searching, and organizing.
概览
本地 MCP 服务器,让助手通过 IMAP/SMTP 访问多个邮箱账户,进行读取、搜索、发送和整理邮件。
- 可以做什么
- 列出账户、文件夹和邮件,读取未读邮件或分页读取完整正文,并查看会话线程。按主题和正文搜索,可按发件人、收件人和日期筛选。发送、回复、转发邮件,创建并发送草稿,可附带主机上的文件。移动、复制、删除邮件,标记已读或未读、加旗标,并支持批量操作。列出并下载附件。
- 适用场景
- 当你希望助手通过标准 IMAP/SMTP 处理真实邮箱时使用,支持 Gmail、Outlook、Yahoo、iCloud、Fastmail、Zoho 等常见服务商或自定义邮件服务器,并可同时管理多个账户。
- 运行要求
- 作为本地进程运行(Go 安装、Homebrew、预编译二进制、Docker 镜像或 Claude Desktop 包)。需要 EMAIL_CONFIG_FILE(JSON 账户文件路径)或 EMAIL_ACCOUNTS(内联 JSON)之一,每个账户需 id、email、username 以及密码或 OAuth2 凭据。需要访问邮件服务器的网络;Gmail 和 Outlook 可选 OAuth2 客户端 ID 与密钥。
安装
在 SourceWeft 中
- 打开 控制台中的 Email (IMAP/SMTP),将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
mcp-server-email
[CI] [codecov] [Go] [License: MIT] [MCP]
Multi-account email server for the Model Context Protocol. Gives LLMs full email access — read, send, search, organize — over IMAP/SMTP with connection pooling, rate limiting, and retry. Designed as the remote-email counterpart to apple-bridge (local Mail.app access).
Quick Start
-
Install
-
Create a config file (
~/.config/mcp-email/accounts.json)For well-known providers (Gmail, Outlook, Yahoo, iCloud, Fastmail, Zoho), host and port are auto-detected from the email domain — just provide credentials:
For custom mail servers, specify host and port explicitly:
-
Add to Claude Code (
~/.claude.json) -
Restart Claude Code — the
email_*tools are now available.
Installation
Go Install (recommended for Go developers)
Homebrew (macOS/Linux)
Binary Download
Download pre-built binaries for your platform from GitHub Releases.
Available for: Linux (amd64, arm64), macOS (amd64, arm64), Windows (amd64, arm64).
Docker
MCP Bundle (Claude Desktop)
Download the .mcpb file from Releases and open in Claude Desktop.
Build from source
Configuration
Accounts are loaded once at startup. Changes require a server restart.
Config file vs environment variable
If both are set, EMAIL_ACCOUNTS takes precedence.
Account JSON schema
*Host and port are auto-detected for well-known providers (see below). Required for custom servers. **Not required when using OAuth2 authentication.
Provider auto-detection
When imap_host/smtp_host are omitted, the server detects settings from the email domain:
Explicit host/port in the config always takes precedence over auto-detection.
TLS modes
TLS mode is auto-detected from port:
Override with "use_starttls": true or "use_starttls": false in the account object. Omit for auto-detection (recommended).
OAuth2 authentication
For providers that support it (Gmail, Outlook), you can use OAuth2 instead of app passwords. This uses the device code flow (RFC 8628) — no browser redirect needed.
-
Create OAuth2 credentials in the provider's developer console (Google Cloud Console or Azure AD)
-
Configure the account with
auth_method: "oauth2": -
On first connection, the server initiates the device code flow — printing a verification URL and code to stderr. Visit the URL and enter the code to authorize.
-
Tokens are persisted in
~/.config/mcp-email/tokens/and automatically refreshed. Subsequent connections reuse the stored token without re-authorization.
Supported OAuth2 providers: Gmail (gmail.com, googlemail.com) and Outlook (outlook.com, hotmail.com, live.com).
Environment variables
*One of EMAIL_CONFIG_FILE or EMAIL_ACCOUNTS is required.
Config file permissions
The config file contains account passwords. Always restrict access:
Tools (22)
Account & folder tools
Message listing
Message operations
Attachments & threads
Send & drafts
All optional account params default to the configured default account.
Search
email_search searches both subject and body using IMAP SEARCH OR (SUBJECT "q") (BODY "q").
Optional filters narrow the candidate set server-side before body scanning:
The existing operation timeout (default 30s) prevents hung body searches on large mailboxes.
Attachments
email_send and email_draft_create accept an attachments parameter — an array of file references on the server host:
Limits (defaults): 18 MB per file, 18 MB total (pre-base64 encoding; stays under 25 MB SMTP cap after encoding). Configurable via MAX_ATTACHMENT_SIZE_MB and MAX_TOTAL_ATTACHMENT_SIZE_MB environment variables.
Download limit: Attachment downloads (email_attachment_get) are capped at 25 MB by default, configurable via MAX_DOWNLOAD_SIZE_MB.
Validation failures (missing file, non-absolute path, size exceeded) return INVALID_ARGUMENT.
Message IDs
Message IDs are composite strings encoding account, mailbox, and UID:
Example: hello:INBOX:12345
All CRUD tools (email_get, email_move, email_copy, email_delete, email_mark_read, email_flag, email_draft_send) extract the account and folder from the ID — no separate params needed.
Error Codes
All errors are returned as MCP tool errors with a structured code prefix:
Resources
Comparison with apple-bridge
This server and apple-bridge share an Email model and parameter semantics (limit, includeBody, folder, query) so LLMs can work with both interchangeably. Key differences:
Development
Prerequisites
- Go 1.24+
- golangci-lint
- Docker (for integration tests only)
Build
Unit tests
Unit tests use mock implementations of the imap.Operations and smtp.Operations interfaces — no live mail server needed.
Benchmarks
Fuzz testing
Fuzz targets ship with seed corpora in testdata/fuzz/ directories. Run a specific target:
Lint
Integration tests
Integration tests exercise the full IMAP/SMTP stack against a real mail server. They are isolated behind the integration build tag and never run during go test ./....
Mail server: Greenmail
Tests use Greenmail, a lightweight Java mail server packaged as a Docker image. Key details that affect how you run it:
Quick start (one command)
This starts a Greenmail container, runs all integration tests, then tears down the container — regardless of pass/fail.
Manual step-by-step
If you need to iterate on tests without restarting the container each time:
-
Start Greenmail
Wait ~3 seconds for the JVM to start.
-
Run integration tests
-
Tear down when done
Test environment variables
*If the corresponding HOST variable is unset, that test file's tests are skipped with a message (not failed).
What the tests cover
IMAP (internal/imap/integration_test.go — 7 tests):
SMTP (internal/smtp/integration_test.go — 4 tests):
Troubleshooting
CI
Integration tests run automatically in GitHub Actions via the integration job in .github/workflows/ci.yml. The job uses a Greenmail service container — no manual Docker setup needed. See the workflow file for the exact configuration.
Coverage
To generate a combined unit + integration coverage report:
Architecture
Tool handlers are decoupled from IMAP/SMTP clients via the imap.Operations and smtp.Operations interfaces, enabling comprehensive unit testing with mocks.
Dependencies
This project uses go-imap v2 (currently v2.0.0-beta.8).
The v2 API is not yet stable — breaking changes may occur before the v2.0.0 release.
We pin the exact version in go.mod and will upgrade promptly when stable is released.
License
来源:README.md,提交 0ba695c
工具
0版本历史
1- v1.0.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分