mail-mcp

mail-mcp

A self-hosted, multi-mailbox MCP server that exposes IMAP/SMTP operations as tools for AI agents, enabling email management like listing folders, reading, searching, sending, and moving messages via natural language.

Category
Visit Server

README

mail-mcp

CI Coverage Version Node.js Version License: MIT PRs Welcome

Self-hosted, provider-agnostic mail service. Point it at any mailbox's IMAP/SMTP credentials and it exposes:

  • REST API mirroring the common mailbox operations: list folders, list/get/search messages, send, flag, move, delete, quota (best-effort).
  • Webhooks (message.received) via a persistent IMAP IDLE watcher — fires an HTTP POST (with a per-webhook bearer secret) whenever new mail arrives, retried with exponential backoff (up to 6 attempts) if the receiving endpoint fails.
  • MCP server (Streamable HTTP, POST /mcp) exposing the same operations as tools, so any MCP-compatible agent can use it directly.

Multi-mailbox from the start: add as many accounts as you want to config/accounts.json.

Request bodies on the REST API are validated with Zod (lib/schemas.js) — invalid payloads get a 422 ERR_VALIDATION_FAILED with field-level errors instead of reaching the mail layer. Webhook subscriptions persist in SQLite (config/webhooks.sqlite, via better-sqlite3) instead of a flat JSON file. Messages larger than MAIL_MCP_MAX_MESSAGE_SIZE (default 25MB) are returned with bodyTruncated: true and no parsed body/attachments, to avoid loading huge messages into memory.

Setup

npm install
cp .env.example .env   # fill in MAIL_MCP_API_TOKEN and one MAILMCP_PASS_<ID> per account

Copy config/accounts.json.example to config/accounts.json (gitignored — no passwords in this file either, those live only in .env):

[
  {
    "id": "example",
    "user": "user@example.com",
    "imap": { "host": "imap.example.com", "port": 993, "secure": true },
    "smtp": { "host": "smtp.example.com", "port": 465, "secure": true }
  }
]

The password for account id: "example" is read from MAILMCP_PASS_EXAMPLE.

node index.js

Runs on 127.0.0.1:4900 by default (see MAIL_MCP_PORT). Put it behind a reverse proxy with TLS if you need to reach it from outside the host.

systemd

An example unit is in deploy/mail-mcp.service — copy it to /etc/systemd/system/, adjust paths, and it loads secrets from /root/mail-mcp/.env via EnvironmentFile.

Auth

Every REST and MCP request requires Authorization: Bearer <MAIL_MCP_API_TOKEN>.

Tests

npm test              # run once
npm run test:coverage # run with coverage report

Coverage covers the pure/logic modules (lib/schemas.js, lib/accounts.js, lib/webhooks-store.js). lib/mailclient.js and lib/idle-watcher.js talk to real IMAP/SMTP servers and are exercised through manual end-to-end testing instead of unit tests — they're excluded from the coverage badge so it isn't misleading.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured