Skip to main content
Glama
mail-mcp-oauth

mail-mcp-oauth

by 00thies-blip

mail-mcp-oauth

Selbstgehosteter, OAuth-2.1-fähiger IMAP/SMTP-MCP-Server für Claude.ai – ein Fork von maxx3250/claude-mail-mcp mit einer eingebauten Schicht für OAuth 2.1, Dynamic Client Registration und PKCE, angepasst für den Betrieb als einzelner zustandsloser Prozess auf Render (ohne VPS, ohne nginx, ohne systemd, ohne dauerhaften Datenträger).

Multi-Konto: Eine einzige Bereitstellung kann mehrere Postfächer bedienen (Gmail, eigene Domains, ...), jeweils erreichbar über IMAP/SMTP. Jedes MCP-Tool akzeptiert einen optionalen Parameter account, um festzulegen, auf welches Postfach zugegriffen wird.

Änderungen gegenüber dem Upstream

  • OAuth 2.1 eingebaut (src/oauth.ts): /register (DCR), /authorize (PKCE + Login-Formular für Einzelnutzer), /token. Kein separater OAuth-Shim-Prozess mehr – das Upstream-Projekt erwähnt zwar einen, hat ihn aber nicht veröffentlicht. Dieser Fork setzt OAuth daher direkt in derselben Express-App um.

  • Bewusst zustandslos: Access- und Refresh-Tokens sind signierte JWTs (ohne Datenbank); registrierte OAuth-Clients und labstende Autorisierungscodes werden im Speicher vorgehalten. Ein Neustart führt ledlich dazu, dass Claude.ai stillschweigend erneut registriert wird – was sein MCP-Client bereits abdeckt.

  • Konten über eine Umgebungsvariable: ACCOUNTS_JSON statt einer Datei auf der Platte, da das Dateisystem von Render nicht dauerhaft ist. Die dateibasierte ACCOUNTS_FILE funktioniert weiterhin für den lokalen/VPS-Einsatz.

  • CalDAV-/Kalender-Tools entfernt – für dieses Deployment nicht nötig, reduziert die Abhängigkeiten (tsdav, ical.js).

Related MCP server: IMAP MCP Server

Architektur

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

Lokale Einrichtung

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

Bereitstellung auf Render

Siehe docs/DEPLOY_RENDER.md für die vollständige Schritt-für-Schritt-Anleitung (GitHub-Push, Render-Webservice, eigene Domain, Netcup-DNS, Verbindung von Claude.ai).

Konten

Siehe docs/ACCOUNTS.md für das accounts.json-Schema und die Einrichtung der jeweiligen Anbieter (App-Passwörter bei Gmail, Netcup Webhosting IMAP/SMTP und warum Hotmail/Outlook.com einen separaten OAuth2-Flow benötigt).

Claude verfügbare Tools

Tool

Zweck

list_accounts

Konfigurierte Postfächer auflisten (id, label, default, From) – niemals Zugangsdaten

list_folders

IMAP-Ordner auflisten

list_messages

Die neuesten N Nachrichten in einem Ordner

search_messages

Serverseitige IMAP-Suche

get_message

Vollständiger E-Mail-Text + Header + Metadaten zu Anhängen

send_message

Über SMTP senden (optional eine Kopie nach „Sent")

create_draft

RFC-822-Nachricht erzeigen und in an Drafts APPEND

mark_read

\Seen umschalten

move_message

Nachrichten zwischen Ordnern verschieben

delete_message

Löschen (zerstörend – stattdessen lieber in den Papierkorb verschieben)

License

MIT – siehe LICENSE. Original von Markus Wanner (masonr25/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,013 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