mail-mcp-oauth
Enables Claude to read, search, send, and manage email across multiple IMAP/SMTP accounts through OAuth 2.1-secured MCP tools.
README
mail-mcp-oauth
Self-hosted, OAuth 2.1-enabled IMAP/SMTP MCP server for Claude.ai — a fork of maxx3250/claude-mail-mcp with a built-in OAuth 2.1 + Dynamic Client Registration + PKCE layer, and adapted to run as a single stateless process on Render (no VPS, no nginx, no systemd, no persistent disk).
Multi-account: one deployment serves several mailboxes (Gmail, custom
domains, ...), each accessible via IMAP/SMTP. Every MCP tool takes an
optional account parameter to pick which mailbox to act on.
What changed vs. upstream
- OAuth 2.1 built in (src/oauth.ts):
/register(DCR),/authorize(PKCE + single-user login form),/token. No separate OAuth shim process — upstream references one but it isn't published, so this fork implements it directly in the same Express app. - Stateless by design: access/refresh tokens are signed JWTs (no DB); registered OAuth clients and in-flight auth codes are in-memory (a restart just makes Claude.ai silently re-register, which its MCP client already handles).
- Accounts from an env var:
ACCOUNTS_JSONinstead of a file on disk, since Render's filesystem is ephemeral. File-basedACCOUNTS_FILEstill works for local/VPS use. - CalDAV/calendar tools removed — not needed for this deployment, cuts
the dependency surface (
tsdav,ical.js). - Sending via HTTP APIs, not direct SMTP: Render's free tier blocks
all outbound traffic to SMTP ports (25/465/587) — confirmed against
four different mailboxes across three providers, not fixable from our
side.
send_messagepicks, per account: the Gmail API (src/gmail-client.ts) for any Google-hosted address (the only way to authenticate as a domain you don't control DNS for), else Brevo's HTTP API (src/brevo-client.ts) ifBREVO_API_KEYis set, else direct SMTP. IMAP is unaffected regardless. See docs/ACCOUNTS.md. - Google OAuth2 (src/google-oauth.ts): XOAUTH2 for IMAP + Gmail API for sending, for Gmail personal and Google Workspace mailboxes (the latter needs it for IMAP too — app passwords disabled by admin policy, no password path exists at all).
Architecture
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) per account, XOAUTH2 or password
│ └── send_message ──▶ Gmail API (Google accounts) or Brevo HTTPS API (SMTP ports blocked on Render free tier)
└── /health
Local setup
npm install
cp .env.example .env
# fill in PUBLIC_URL, ACCOUNTS_JSON (see docs/ACCOUNTS.md), OAUTH_USER,
# OAUTH_PASS, JWT_SECRET (openssl rand -hex 32), and BREVO_API_KEY
# (only needed if raw SMTP egress is blocked where you're deploying)
npm run dev
Deploying to Render
See docs/DEPLOY_RENDER.md for the full step-by-step (GitHub push, Render web service, custom domain, Netcup DNS, connecting Claude.ai).
Accounts
See docs/ACCOUNTS.md for the accounts.json schema,
per-provider setup (Gmail app passwords, Netcup Webhosting IMAP/SMTP,
Google OAuth2 for Gmail + Workspace), the Brevo sender-domain-
authentication steps for non-Google domains, and why Hotmail is currently
blocked on a Microsoft-side issue rather than anything in this repo.
Tools exposed to Claude
| Tool | Purpose |
|---|---|
list_accounts |
List configured mailboxes (id, label, default, From) — never credentials |
list_folders |
Enumerate IMAP mailboxes |
list_messages |
Newest N messages in a folder |
search_messages |
Server-side IMAP search |
get_message |
Full body + headers + attachment metadata |
send_message |
Send (Gmail API / Brevo / SMTP depending on account, optionally copies to Sent) |
create_draft |
Build RFC-822 and APPEND to Drafts |
mark_read |
Toggle \Seen |
move_message |
Move between folders |
delete_message |
Delete (destructive — prefer move to Trash) |
License
MIT — see LICENSE. Original work by Markus Stöger (maxx3250/claude-mail-mcp).
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。