Skip to main content
Glama
00thies-blip

mail-mcp-oauth

by 00thies-blip

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

list_accounts

Список настроенных почтовых ящиков (id, label, default, From) — никогда не учётные данные

list_folders

Перечисление IMAP-папок

list_messages

Последние N писем в папке

search_messages

Поиск на стороне IMAP-сервера

get_message

Полное тело письма + заголовки + метаданные вложений

send_message

Отправка через SMTP (при желании копия отправляется в Sent)

create_draft

Сформировать письмо в формате RFC-822 и добавить его в Drafts (APPEND)

mark_read

Переключить флаг \Seen

move_message

Переместить сообщение между папками

delete_message

Удалить (необратимо — лучше переместить в Trash)

Лицензия

MIT — см. LICENSE. Оригинальная работа — Markus Stöger (maxx32535/claude-mail-mcp).

Related MCP Connectors

  • 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.

  • Your mailboxes in ChatGPT and Claude: Gmail, iCloud, Fastmail, any IMAP. Passwords stay yours.

    https://mailmcp.ai/mcp

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,152 npm
    112
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables 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 npm
    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.
    -