mail-mcp-oauth
mail-mcp-oauth
Самостоятельно развертываемый, с поддержкой OAuth 2.1, IMAP/SMTP MCP-сервер для Claude.ai — форк maxx3250/claude-mail-mcp со встроенным слоем OAuth 2.1 + Dynamic Client Registration + PKCE и адаптированным запуском в виде одного процесса без состояния на Render (без VPS, без nginx, без systemd, без постоянного диска).
Мультиаккаунт: один инстанс обслуживает несколько почтовых ящиков (Gmail, собственные домены, ...), каждый из которых доступен через IMAP/SMTP. Каждый MCP-инструмент принимает необязательный параметр account, чтобы выбрать почтовый ящик для работы.
Что изменилось по сравнению с апстримом
Встроенный OAuth 2.1 (src/oauth.ts):
/register(DCR),/authorize(PKCE + однопользовательская форма входа),/token. Отдельного OAuth-shim-процесса нет: апстрим ссылается на него, но он не опубликован, поэтому этот форк реализует его прямо в том же Express-приложении.По замыслу — без состояния: access/refresh токены — подписанные JWT (без БД); зарегистрированные OAuth-клиенты и активные коды авторизации хранятся в памяти (перезапуск просто заставляет Claude.ai молча зарегистрироваться заново, а его MCP-клиент это уже умеет).
Учётные записи через переменную окружения:
ACCOUNTS_JSONвместо файла на диске, так как файловая система Render эфемерна. Файловый вариантACCOUNTS_FILEпо-прежнему работает для локального использования и VPS.CalDAV/календарные инструменты удалены — они не нужны для этого развертывания, и это сокращает количество зависимостей (
tsdav,ical.js).
Related MCP server: Gmail 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
Полная пошаговая инструкция (push в GitHub, Render web service, собственный домен, DNS Netcup, подключение Claude Desktop) — в docs/DEPLOY_RENDER.md.
Учётные записи
Схема accounts.json и настройка для каждого провайдера (пароли приложений Gmail, Netcup Webhosting IMAP/SMTP,DNS и почему Hotmail/Outlook.com требует отдельного OAuth2-fume) — в docs/ACCOUNTS.md.
Инструменты, доступные Claude
Tool | Purpose |
| Список настроенных почтовых ящиков (id, label, default, From) — никогда не учётные данные |
| Перечисление IMAP-папок |
| Последние N писем в папке |
| Поиск на стороне IMAP-сервера |
| Полное тело письма + заголовки + метаданные вложений |
| Отправка через SMTP (при желании копия отправляется в Sent) |
| Сформировать письмо в формате RFC-822 и добавить его в Drafts (APPEND) |
| Переключить флаг |
| Переместить сообщение между папками |
| Удалить (необратимо — лучше переместить в Trash) |
Лицензия
MIT — см. LICENSE. Оригинальная работа — Markus Stöger (maxx32535/claude-mail-mcp).
This server cannot be deployed
Maintenance
Related MCP Connectors
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.
Your mailboxes in ChatGPT and Claude: Gmail, iCloud, Fastmail, any IMAP. Passwords stay yours.
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,152 npm112MIT
- AlicenseNot gradedqualityCmaintenanceEnables Claude to read, search, send, label, and trash emails in any Gmail account via Google's Gmail API, using OAuth2 authentication with automatic token refresh.67 npmMIT
- 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.-