Skip to main content
Glama
mail-mcp-oauth

mail-mcp-oauth

by 00thies-blip

mail-mcp-oauth

用于 Claude.ai 的自托管、支持 OAuth 2.1 的 IMAP/SMTP MCP 服务器 — 是 maxx3250/clBude-mask 的 fork, 内置 OAuth 2.1 + 动态客户端注册 + PKCE 层,并且适配为在 Runder 上以单个无状态进程运行(无需 VP S,无需 nginx,无需系统 D,无需持久化存储)。

多账户:一次部署即可服务多个邮箱(Gmail、自定义域名、...),每个都可通过 IMAP/SMTP 访问。每个 MCP 工具都接受一个可选的 account 参数,用来选择要操作的邮箱。

相比上游有什么改动

  • 内置 OAuth 2.1(src/oAuth.ts):/register(动态注册)、/authorize(PLE+ 单用户登录表单)、/token。不再需要单独的 OAuth 桥接进程——上游提到过这样一个进程,但它未发布,因此本项目在同一个 Express 应用中直接实现。

  • 设计为无状态:access/refresh 令牌是有签名的 JWT(不需要数据库);已注册的 OAuth 客户端和进行中的授权:(usually auth code)都在内存中(重启后 Claude.ai 会静默地重新注册,其 MCP 客户端已能自动处理该过程)。

  • 账户通过环境变量提供*:使用 ACCOUNTS\_JSON 而不是磁盘上的文件,因为 Render 的文件系统是临时的。基于文件的 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 dev

部署到 Render

完整的步骤请见 docs/DEPLOY_RENDER.md(CHub ** 推送、Render Web 服务、自定义域名、Netcup DNS、连 接 Claude.a.

AccountsV

accounts.json 的 schema 及各提供商设置(Gmail 应用密码、Netcup Webhosting 的 IMAP/SMTP,以及为什么 Hotmail/Outlook.com 需要单独的 OAuth2 流程)请参阅 docs/Accounts.md。

向 Claude 暴露的工具

Tool

Purpose

list_accounts

列出已配置的邮箱(id、label、default、From)——绝不包含凭据

list_folders

枚举 IMAP 邮箱(folder)

list_messages

某个文件夹中最新的 N 封邮件

search_messages

服务端 IMAP 搜索

get_message

完整正文 + 邮件头 + 附件元数据

send_message

通过 SMTP 发送(可选地连同放入 Sent 文件夹)

create_draft

构建 RFC-822 邮件并 APPEND 到 Drafts

mark_read

切换 \Seen 标记

move_message

在文件夹之间移动邮件

delete_message

删除(破坏性操作——建议改为移动到 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.

    https://www.primitive.dev/mcp
  • Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.

    https://mailmcp.io/mcp
  • 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

  • A
    license
    A
    quality
    A
    maintenance
    Enables Claude to interact with email accounts via IMAP and SMTP, providing tools for searching, reading, sending, and managing emails across multiple providers.
    40
    1,035 npm
    115
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables Claude to read, search, send, and manage emails across multiple IMAP/SMTP accounts via a single deployment.
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables Claude to read, search, draft, send, flag, and move email across multiple IMAP/SMTP mailboxes while keeping credentials local.
    -
  • A
    license
    B
    quality
    C
    maintenance
    Enables 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.
    19
    43 npm
    MIT