Purpose
mail-mcp-server is an MCP (Model Context Protocol) server that connects to AI clients via stdio and provides AI agents with read-only access to mailboxes. It targets two types of mailboxes: on-premises Microsoft Exchange (via EWS and NTLM, using a regular domain password, with no Microsoft Graph required) and any IMAP mailbox that supports password login (tested with Mail.ru and Gmail).
Main capabilities
- Read-only access: Read-only is enforced at the protocol level; write commands are rejected before being sent; downloading emails does not mark them as read.
- Searchable attachments: Extracts and indexes text from PDF, Word, Excel, PowerPoint, ZIP archives, attached emails, Outlook .msg, and winmail.dat, so agents can find contract content inside attachments, not just the email that carries it.
- Word-form-aware search: Supports Russian and English, covering subject, body, addresses, and attachments; duplicates of the same email appear only once, and conversations can be tracked across folders.
- Local copy and offline use: During synchronization, emails are downloaded in one go, converted to Markdown on the local machine, and indexed with Lucene; tools read only the local copy and do not connect to the mail server, so answers do not depend on the mail server and can be used offline. Synchronization runs only when the user requests it.
- Multiple mailbox support: One server can be configured with multiple mailboxes; passwords can be stored in Windows Credential Manager, a password manager, or environment variables, and literal passwords can also be used.
- Account protection: Each synchronization logs in only once and does not retry; after a password is rejected, attempts stop until the user corrects it, reducing the risk of domain account lockout.
- Privacy: There is no proprietary cloud service; conversion and indexing are done locally; the local copy is unfiltered, and the AI client will still see the content returned by tools; an optional secret filter can mask passwords and verification codes in responses.
Usage
- Install JDK 25 and pandoc 3.x (pandoc is required and must be in PATH).
- Get the jar: download mail-mcp-server.jar from the latest release, or build it yourself. If there is no local JDK or pandoc, you can use a Docker image ghcr.io/igorolv/mail-mcp-server (with fewer password storage options); it can also be launched with JBang:
jbang --quiet mail-mcp-server@igorolv/mail-mcp-server(pandoc is still required). - In
%USERPROFILE%\.mail-mcp-server\connections.json(on other platforms it is~/.mail-mcp-server/connections.json)Add one record for each mailbox in (), specifying the password source (Windows Credential Manager, a command that prints the password, an environment variable, or a literal password). - Register the server in the MCP client, using the absolute path to the jar (e.g., Claude Code).
- Ask the agent to perform synchronization. The first sync downloads the entire mailbox, which may take a long time, so keep the client open; if interrupted, you can ask it to resume. For large mailboxes or when you need to view progress in the terminal, use mail-sync.
- Test by asking the agent questions, such as "Which mailboxes can you read?" or "Find the email about the supply contract in the work mailbox from last week."
Except for listConnections, every tool requires a connection parameter. Offline maintenance, login recovery, and Gmail OAuth2 authorization are performed via commands in the terminal.
Use Cases
Read-only scenarios in which an AI agent needs to retrieve content from local Exchange or IMAP mailboxes, especially where text inside attachments (contracts, reports, etc.) needs to be searched; environments that require data localization and do not want emails to pass through third-party cloud services.
Limitations
- Version 0.1.1, developed and tested on Windows.
- Requires JDK 25 and pandoc 3.x; the Docker approach supports fewer password storage methods.
- Read-only; mailboxes cannot be modified.
- The first sync must download the entire mailbox, which takes a long time.
- The local copy is unfiltered, and AI clients can see the content returned by the tool.
- Building requires the JDK 25 toolchain; tests do not connect to real mail servers.
Tech Stack and License
Java 25, Gradle 9, Spring Boot 4.2.0-RC1, Spring AI 2.1.0-RC1 MCP server (stdio), Apache HttpClient 5.6.5, Eclipse Angus Mail 2.0.5, Apache Lucene 10.5.2, pandoc 3.x, Apache PDFBox 3.0.5, Apache POI 5.4.1. Licensed under the Apache License 2.0.