
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 分