# stalwart-mail-mcp [Health: Active]

**Category:** 💬 Communication  
**Repository:** https://github.com/cybersmurf/stalwart-mail-mcp  
**GitHub Stars:** 0  
**npm Downloads (last month):** 612  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/stalwart-mail-mcp

## Description
Mail and contacts on a self-hosted Stalwart server via JMAP: search, read, OCR, send, drafts.

## Tools
Capabilities this server exposes over MCP:

- **mail_list_mailboxes** — Returns the available accounts (your mailbox plus shared ones), folders with message counts (unread) and the addresses you can send from.
Call it first when you do not know which folders or accounts exist. Changes nothing.
- **mail_search_emails** — Searches mail (full text, sender, recipient, subject, folder, date, unread, attachments) or lists a whole thread.
Returns message ids (for mail_get_email), thread, sender, date and a preview. Newest first, paging through limit/offset.
Without a filter it returns the latest messages from all folders (trash included) — for “what is new” use mailbox="inbox", unread=true.
- **mail_get_email** — Returns a whole message by id (from mail_search_emails): headers, body text (HTML is converted to text) and the list of attachments.
mail_get_attachment reads an attachment's content (PDF, image, text). To reply use mail_send_email with in_reply_to_id. Changes nothing (does not mark the message as read).
- **mail_get_attachment** — Downloads an attachment of a received message, saves it to disk and returns its content: text for text files, the text of every page for PDFs, the picture for images.
Scans (PDF pages without a text layer) and photos of documents are read through OCR, tables included; pages that came from OCR are marked “(OCR)” — treat numbers from them with some caution and ask for a preview when a figure matters.
Other types (docx, xlsx, zip…) only return the path of the saved file.
Pick the attachment by name or by its number from the list in mail_get_email; a message with a single attachment needs neither. The message itself is not changed.
- **mail_send_email** — Sends an e-mail from the mailbox — a new one, or a reply (in_reply_to_id). A copy is stored in Sent.
It sends IMMEDIATELY and cannot be undone. Send only when the user explicitly said the message should go out; otherwise create a draft (mail_create_draft).
Verify the recipient before sending — never guess an unknown address, look it up with mail_search_contacts.
- **mail_create_draft** — Saves a message as a draft in the Drafts folder (does not send). The user can then review it in webmail or on the phone and send it themselves, or mail_send_draft sends it by id. Same parameters as mail_send_email (including replying via in_reply_to_id and attachments).
- **mail_send_draft** — Sends an existing draft by id (from mail_create_draft or from a search in the drafts folder). Sends immediately — only on the user's explicit instruction.
- **mail_delete_draft** — Permanently deletes a draft by id. Works only on messages flagged as drafts — it never deletes sent or received mail.
- **mail_search_contacts** — Finds an e-mail address or phone number: searches the address books (your own and shared ones) and also the mail history (who wrote to you and whom you wrote to, matching the query).
Use it whenever you need a person's or company's address before sending anything. Without a query it lists the whole address book.
- **mail_add_contact** — Creates a contact in an address book. Default is the signed-in mailbox's own address book; pass the account of a shared mailbox to store it in the shared one (everyone with access sees it, on phones too through CardDAV).
Check mail_search_contacts first so you do not create a duplicate.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "stalwart-mail-mcp": {
    "command": "npx",
    "args": ["-y","stalwart-mail-mcp"],
    "env": {
      "STALWART_URL": "",
      "STALWART_USER": "",
      "STALWART_PASSWORD": "",
      "STALWART_TOKEN": ""
    }
  }
}
```

**Requires environment variables:** `STALWART_URL`, `STALWART_USER`, `STALWART_PASSWORD`, `STALWART_TOKEN` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What the stalwart-mail-mcp MCP server does

The stalwart-mail-mcp MCP server gives an MCP-compatible client access to a mailbox hosted by Stalwart. It can list mailboxes and folders, search messages by content and metadata, retrieve complete messages, and inspect conversation threads. Message HTML is converted to text, while attachments are exposed separately.

Email actions include composing and sending new messages, replying within a thread, creating drafts, sending drafts, and deleting drafts. Contact tools search address books and people found in mail history, and can add contacts to an own or shared address book. The tool names use the `mail_` prefix by default, with an option to change it.

## How it works

The stdio deployment runs as a Node process launched by the MCP client. It communicates with the mailbox over HTTPS using JMAP protocols and the mailbox account's credentials. Nothing needs to be installed on the Stalwart host for this mode.

A remote mode runs the process alongside Stalwart and exposes it as a custom connector. This allows supported Claude environments, including claude.ai, mobile apps, and desktop chat, to reach the mailbox through Stalwart's OAuth sign-in flow. In that mode, the server does not retain mailbox credentials.

Attachment handling depends on the file type. Text and HTML can be returned as readable text, PDFs can be processed page by page, images are returned as images, and unsupported formats such as DOCX, XLSX, and ZIP are saved with their path returned. Scanned PDF pages and photographed documents can be sent to a configured OCR provider. OCR may use hosted services, a custom OpenAI-compatible endpoint, or local Ollama or LM Studio models.

## Setup and configuration

Install the stalwart-mail-mcp MCP server from npm with `npx -y stalwart-mail-mcp`, or download the packaged `.mcpb` release for Claude Desktop. Configure `STALWART_URL`, `STALWART_USER`, and either `STALWART_PASSWORD` or `STALWART_TOKEN`. The password is sent using Basic authentication; a token uses Bearer authentication.

Optional settings control language, tool-name prefixes, branding, attachment download location, timezone, OCR provider, model, API key, and base URL. `MISTRAL_API_KEY` enables the Mistral shortcut for OCR. Attachment saving and OCR can be configured independently.

Capabilities that write data can be removed from the tool list with environment settings. Disable sending to prevent email transmission, disable drafts to remove draft creation and deletion, disable contact editing to prevent new contacts, and disable attachments to remove attachment retrieval. `MAIL_SAVE_ATTACHMENTS=false` keeps opened attachments from being written to disk.

## Tools and capabilities

Available tools include:

- `mail_list_mailboxes` for accounts, shared mailboxes, folders, counts, allowed senders, and address books.
- `mail_search_emails` for full-text, sender, recipient, subject, folder, date, unread, attachment, and thread searches.
- `mail_get_email` for retrieving a complete message and listing its attachments.
- `mail_get_attachment` for reading text, PDFs, OCR results, and images, with optional file saving.
- `mail_send_email` for new messages and replies with disk-based attachments.
- `mail_create_draft`, `mail_send_draft`, and `mail_delete_draft` for draft workflows.
- `mail_search_contacts` and `mail_add_contact` for contact lookup and creation.

Sending is immediate and cannot be undone, so the tool guidance requires explicit user instruction before sending and favors drafts otherwise. OCR is the only feature that sends mailbox content outside the mail server, unless a local OCR model is selected. Long scans may need page ranges when a local model exceeds the MCP client's tool timeout.

_Full upstream README: https://allmcps.com/mcp/stalwart-mail-mcp/readme_

