mail-mcp
mail-mcp
セルフホスト型、プロバイダ非依存のメールサービス。任意のメールボックスのIMAP/SMTP認証情報を指定するだけで、以下の機能を提供します:
REST API:一般的なメールボックス操作をミラーリング:フォルダ一覧、メッセージの一覧/取得/検索、送信、フラグ設定、移動、削除、クォータ(ベストエフォート)。
Webhook(
message.received):永続的なIMAP IDLEウォッチャー経由で、新着メールが到着するたびにHTTP POST(WebhookごとのBearerシークレット付き)を発行。受信エンドポイントが失敗した場合、指数バックオフ(最大6回試行)でリトライします。MCPサーバー(Streamable HTTP、
POST /mcp):同じ操作をツールとして公開するため、MCP互換のエージェントが直接利用可能。
最初からマルチメールボックス対応:config/accounts.jsonに必要なだけアカウントを追加できます。
REST APIのリクエストボディはZod(lib/schemas.js)で検証され、無効なペイロードはメール層に到達する前にフィールドレベルのエラーとともに422 ERR_VALIDATION_FAILEDを返します。Webhookの購読はフラットなJSONファイルではなくSQLite(config/webhooks.sqlite、better-sqlite3経由)に永続化されます。MAIL_MCP_MAX_MESSAGE_SIZE(デフォルト25MB)より大きなメッセージは、メモリに巨大なメッセージを読み込まないよう、bodyTruncated: trueでパースされた本文/添付ファイルなしで返されます。
セットアップ
npm install
cp .env.example .env # fill in MAIL_MCP_API_TOKEN and one MAILMCP_PASS_<ID> per accountconfig/accounts.json.exampleをconfig/accounts.jsonにコピーします(gitignore対象 – このファイルにもパスワードは含まれず、パスワードは.envのみに存在します):
[
{
"id": "example",
"user": "user@example.com",
"imap": { "host": "imap.example.com", "port": 993, "secure": true },
"smtp": { "host": "smtp.example.com", "port": 465, "secure": true }
}
]アカウントid: "example"のパスワードはMAILMCP_PASS_EXAMPLEから読み取られます。
node index.jsデフォルトでは127.0.0.1:4900で動作します(MAIL_MCP_PORTを参照)。ホスト外からアクセスする必要がある場合は、TLSを使用したリバースプロキシの背後に配置してください。
Related MCP server: Agent Email
systemd
サンプルユニットがdeploy/mail-mcp.serviceにあります。これを/etc/systemd/system/にコピーし、パスを調整すると、EnvironmentFile経由で/root/mail-mcp/.envからシークレットを読み込みます。
認証
すべてのRESTおよびMCPリクエストには、Authorization: Bearer <MAIL_MCP_API_TOKEN>が必要です。
テスト
npm test # run once
npm run test:coverage # run with coverage reportカバレッジは純粋な/ロジックモジュール(lib/schemas.js、lib/accounts.js、lib/webhooks-store.js)を対象としています。lib/mailclient.jsとlib/idle-watcher.jsは実際のIMAP/SMTPサーバーと通信するため、ユニットテストではなく手動のエンドツーエンドテストで検証されています。これらはカバレッジバッジから除外されているため、誤解を招くことはありません。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA generic IMAP and SMTP MCP server that enables AI agents to interact with email accounts for reading, searching, and sending messages. It provides high-level tools for managing email workflows like daily digests and folder organization across any standard email provider.1MIT
- Alicense-qualityAmaintenanceAn open-source MCP server that provides AI agents with secure access to read, search, and manage emails via Microsoft 365 and Gmail. It features security-first defaults like recipient allowlists and markdown content conversion to facilitate safe agent interaction with mailboxes.4Apache 2.0
- AlicenseAqualityDmaintenanceProvider-agnostic email MCP server that connects any IMAP mailbox to AI assistants, enabling email management through natural language.8AGPL 3.0
- Alicense-qualityCmaintenanceAn MCP server that exposes IMAP operations as tools for AI assistants, enabling email management including listing mailboxes, reading, searching, moving, flagging emails, and creating drafts.47MIT
Related MCP Connectors
Hosted email MCP for AI agents with inboxes, send/receive, memory, recovery, and credits.
Shipmail MCP server for AI agent custom-domain email inboxes with REST API and webhooks.
Self-hosted multi-domain email as MCP tools - register domains, real mailboxes, send/read mail.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MauricioPerera/mail-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server