mail-mcp-oauth
Allows the server to access Gmail mailboxes via IMAP/SMTP, enabling tools to list folders, search and read messages, send messages, create drafts, mark messages as read, move messages, and delete messages using Gmail app passwords.
Provides mail integration for Netcup webhosting mailboxes via IMAP/SMTP, supporting folder listing, message search and retrieval, sending messages, creating drafts, marking messages read, moving messages, and deleting messages.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mail-mcp-oauthsearch my inbox for invoices from Acme and summarize the latest one"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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). DCR client registrations are also signed JWTs (the
client_idcarries its own registration), so a restart needs no re-registration. In-flight auth codes are the only in-memory state, and they live 2 minutes.Persistent login: a successful
/authorizesets a signed, 10-yearmcp_sessioncookie, so later re-authorizations (Claude.ai re-checks periodically; Render free cold-starts trigger one) complete silently with no login prompt. Revoke by rotatingJWT_SECRET. See docs/DEPLOY_RENDER.md.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).
Related MCP server: Gmail MCP Server
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)
└── /healthLocal 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 devDeploying 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 configured mailboxes (id, label, default, From) — never credentials |
| Enumerate IMAP mailboxes |
| Newest N messages in a folder |
| Server-side IMAP search |
| Full body + headers + attachment metadata |
| Send (Gmail API / Brevo / SMTP depending on account, optionally copies to Sent) |
| Build RFC-822 and APPEND to Drafts |
| Toggle |
| Move between folders |
| Delete (destructive — prefer move to Trash) |
License
MIT — see LICENSE. Original work by Markus Stöger (maxx3250/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.40500 npm96MIT
- 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.-