mail-mcp-oauth
mail-mcp-oauth
セルフホスト型で、OAuth 2.1対応のIMAP/SMTP MCPサーバー(Claude.ai向け)— maxx3250/claude-mail-mcp のフォークです。OAuth 2.1 + 動的クライアント登録(DCR) + PKCE レイヤーを内蔵し、Render上で単一のステートレスプロセスとして実行できるよう調整されています(VPS、nginx、systemd、永続ディスクは不要)。
マルチアカウント対応: 1つのデプロイで複数のメールボックス(Gmail、カスタムドメインなど)を利用でき、それぞれIMAP/SMTPでアクセスできます。各MCPツールは、操作対象のメールボックスを選ぶオプションのaccountパラメータを受け取ります。
アップストリームからの変更点
OAuth 2.1を内蔵(src/oauth.ts):
/register(DCR)、/authorize(PKCE + シングルユーザーログインフォーム)、/token。独立したOAuthシムプロセスは不要です。アップストリームでは言及されていますが公開されていないため、このフォークでは同じExpressアプリ内に直接実装しています。設計上ステートレス — アクセストークン/リフレッシュトークンは署名済みのJWT(DB不要)。登録済みOAuthクライアントと処理中の認証コードはメモリ上に保持されます(再起動するとClaude.aiが自動的に再登録するだけで、その処理はMCPクライアントがすでに行います)。
環境変数からアカウント設定: Renderのファイルシステムはephemeralなため、ディスク上のファイルではなく
ACCOUNTS_JSONを使用します。ファイルベースのACCOUNTS_FILEは、ローカル/VPS利用時には引き続き使用可能です。CalDAV/カレンダーツールを削除 — このデプロイには不要で、依存関係も削減できます(
tsdav、ical.js)。
Related MCP server: IMAP MCP Server
アーキテクチャ
Claude.ai (web)
│ HTTPS + OAuth 2.1 (DCR, PKCE, JWT)
▼
Render (TLS terminated automatically, custom domain mcp-mail.<domain>)
▼
this process (single Node service)
├── /.well-known/oauth-authorization-server, /register, /authorize, /token (src/oauth.ts)
├── /mcp (Bearer-gated MCP Streamable HTTP transport)
│ ├── ImapClient ──▶ imapflow ──▶ IMAP server (993/143) per account
│ └── SmtpClient ──▶ nodemailer ──▶ SMTP server (465/587) per account
└── /healthローカルセットアップ
npm install
cp .env.example .env
# fill in PUBLIC_URL, ACCOUNTS_JSON (see docs/ACCOUNTS.md), OAUTH_USER,
# OAUTH_PASS, and JWT_SECRET (openssl rand -hex 32)
npm run devRenderへのデプロイ
詳細な手順(GitHub push、Render Webサービス、カスタムドメイン、Netcup DNS、Claude.aiの接続)は docs/DEPLOY_RENDER.md を参照してください。
アカウント
accounts.jsonのスキーマとプロバイダー別設定(Gmailのアプリパスワード、Netcup WebhostingのIMAP/SMTP、そしてHotmail/Outlook.com が別途OAuth2フローを必要とする理由)については docs/ACCOUNTS.md を参照してください。
Claudeに公開されるツール
Tool | 用途 |
| 設定済みのメールボックスを一覧表示(id、label、default、From)— 資格情報は表示しません |
| IMAPメールボックスを列挙 |
| フォルダ内の最新N件を取得 |
| サーバーサイドのIMAP検索 |
| 本文全体 + ヘッダー + 添付ファイルのメタデータを取得 |
| SMTPで送信(必要に応じてSentにコピー) |
| RFC-822メッセージを作成しDraftsにAPPEND |
|
|
| フォルダ間で移動 |
| 削除(破壊的操作 — Trashへの移動を推奨) |
ライセンス
MIT — LICENSE を参照してください。原著作者: Markus Stöger(maxx3250/claude-mail-mcp)。
Related MCP Connectors
Connect any IMAP/SMTP mailbox to Claude & ChatGPT: search, read, sort, draft. Sends only with OK.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Your agent needs a mailbox of its own — to receive, thread, draft and send, with attachments, without borrowing your personal inbox or your company's SMTP. **What you can ask for** • "Create an inbox for this agent and tell me its address." • "Read the new messages in this thread and draft a reply." • "Send this message with the attachment and wait for the response." • "Search this inbox for everything from that domain." • "Show delivery metrics and the events on this inbox." **How to use it** Point any MCP client at https://mcp.aisa.one/mail/mcp and sign in with OAuth — there is no key to create or paste. 49 tools: create and delete inboxes, list and read messages, raw message bodies, attachments, threads, drafts and draft attachments, send and reply, message search, inbox events, metrics, and list entries — reads and writes. **Why this rather than the source** A real inbox an agent owns, rather than an SMTP credential it borrows from a human. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Find the contact elsewhere in the catalogue, then write to them from here — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/sales/mcp finds the person to write to.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables Claude to interact with email accounts via IMAP and SMTP, providing tools for searching, reading, sending, and managing emails across multiple providers.401,013 npm115MIT
- FlicenseNot gradedqualityDmaintenanceEnables Claude to read, search, send, and manage emails across multiple IMAP/SMTP accounts via a single deployment.-
- FlicenseNot gradedqualityBmaintenanceEnables Claude to read, search, draft, send, flag, and move email across multiple IMAP/SMTP mailboxes while keeping credentials local.-
- AlicenseBqualityCmaintenanceEnables email management through IMAP/SMTP, including reading, sending, replying, starring, deleting, labeling emails, handling attachments, and filtering by Gmail smart categories. Works with MCP-compatible clients like Claude Desktop and Claude Code using App Password authentication.1943 npmMIT