proton-mail-mcp
# Proton Mail MCP Server
[](https://www.npmjs.com/package/proton-mail-mcp)
[](https://opensource.org/licenses/MIT)
[](https://glama.ai/mcp/servers/sethbang/proton-mail-mcp)
A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that gives AI assistants full access to your Proton Mail account -- send, read, search, and organize email over SMTP and IMAP.
> ⚠️ **Unofficial — not affiliated with Proton.** This is an independent, community-built project. It is **not** developed, endorsed, sponsored, or supported by Proton AG. "Proton", "Proton Mail", and "Proton Mail Bridge" are trademarks of Proton AG, used here only to describe interoperability. It talks to Proton Mail through the locally-run Proton Mail Bridge (or, for sending, optionally Proton's standard SMTP submission endpoint); no Proton private API is used. Use at your own risk.
> **Upgrading from 1.x?** 2.0 sends mail through Bridge by default and changes a few tool behaviours. Run `npx -y proton-mail-mcp@2 migrate` to see what affects your configs, and read [MIGRATION.md](MIGRATION.md).
## Demo

## Features
- **Send, reply, and forward** email through Bridge with threading headers; dedicated `reply_all_email` tool; recipients as `a@x`, `Name <a@x>` or `"Doe, Jane" <a@x>`, separated by commas or semicolons
- **Drafts** -- `save_draft`, `saveAsDraft` on replies and forwards for review, and `send_draft` to send one later
- **Markdown bodies** -- pass `markdownBody` to `send_email` / `reply_email` / `reply_all_email` / `forward_email`; rendered to HTML
- **Read email** via IMAP through [Proton Mail Bridge](https://proton.me/mail/bridge)
- **Attachments** -- send files as base64 or by path from a folder you allow (`ALLOW_FILE_ATTACH_DIR`), download to memory or to disk (`saveTo` + `ALLOW_FILE_DOWNLOAD_DIR`), forward a subset by part number
- **Search** messages by sender, recipient, subject, body, date, flags, size, List-ID, attachment presence, attachment name (substring), and attachment MIME type
- **Organize** -- move, delete, and flag/unflag messages individually or in bulk; bulk-update labels too
- **Bulk operations** -- `bulk_move`, `bulk_delete`, `bulk_update_flags`, `bulk_update_labels` with `dryRun` preview and XOR uid/match input
- **Folder & label management** -- `create_folder`, `create_label`, `rename_folder`, `delete_folder` (non-destructive on Proton); `empty_folder` (opt-in via `ALLOW_EMPTY_FOLDER=true`; not recommended)
- **Labeling** -- `update_message_labels` adds and removes Proton labels on a message (additive — message stays in its source folder)
- **Aggregations** -- `count_messages`, `folder_stats`, `top_senders` (with `excludeSelf` + per-row direction) for inbox analytics
- **Thread mutations** -- `move_thread`, `delete_thread`, `flag_thread` with optional cross-folder walk; `get_thread` dedupes by Message-ID across mailbox copies
- **Snippets** -- optional `includeSnippet` on `list_messages` and `search_messages` for at-a-glance previews
- **List folders** with message and unread counts; folder names resolve forgivingly (`sent`, `Work` for `Folders/Work`) with "did you mean" suggestions
- **Diagnostics** -- `check_connection` / `proton-mail-mcp doctor` say which port, TLS setting or password is wrong
- **Honest accounting** -- post-STORE FETCH verify on flags/labels surfaces silently-dropped operations as `notApplied`; sent-copy lookup confirms the send without holding the call (`pending` when Proton hasn't filed the copy yet); Reply-To rewrites are surfaced in the send response
- **Safety first** -- delete moves to Trash by default (via special-use resolver), read-only mode via `READONLY=true`, `dryRun` on all bulk ops, MCP tool annotations for client-side confirmation prompts, path-traversal defense on filesystem-touching tools
- **Security hardened** -- input validation, credential sanitization, rate limiting (10 sends a minute, at most 50 recipients a message), attachment size limits
- Works with any MCP-compatible client (Claude Desktop, Claude Code, Cursor, etc.)
## Prerequisites
- [Node.js](https://nodejs.org/) v24+
- A [Proton Mail](https://proton.me/mail) account
- [Proton Mail Bridge](https://proton.me/mail/bridge) running locally. The server reads, searches and sends through it, using the Bridge password from Bridge's mailbox details. (To send through Proton's [SMTP submission service](https://proton.me/support/smtp-submission) instead, set `PROTONMAIL_HOST=smtp.protonmail.ch`, `PROTONMAIL_PORT=587` and its SMTP token as the password; reading still needs Bridge.)
## Quick Start
### Claude Desktop: install the bundle
The server is also packaged as an [MCP Bundle](https://github.com/modelcontextprotocol/mcpb) (`.mcpb`). With a bundle, Claude Desktop installs the server and shows a settings form for your address, Bridge password and ports, so there is no JSON to edit.
1. Download `proton-mail-mcp-<version>.mcpb` from the [Releases page](https://github.com/sethbang/proton-mail-mcp/releases). Or build it from a clone with `npm install && npm run build && npm run mcpb:pack`; it is written to `dist/`.
2. Double-click the file, or drag it into Claude Desktop's **Settings → Extensions**.
3. Fill in the settings from Proton Mail Bridge's mailbox details: your address, the Bridge password, and the **IMAP port** and **SMTP port**. If Bridge shows SSL for a protocol, turn on **IMAP uses SSL** or **SMTP uses SSL** (`IMAP_SECURE` / `PROTONMAIL_SECURE`). The hosts already point at Bridge (`127.0.0.1`).
If something doesn't connect, ask Claude to run `check_connection`.
### Add to your MCP client
Add the following to your client's MCP server configuration (Claude Desktop, Claude Code, Cursor, etc.):
```json
{
"mcpServers": {
"protonmail": {
"command": "npx",
"args": ["-y", "proton-mail-mcp"],
"env": {
"PROTONMAIL_USERNAME": "your-email@protonmail.com",
"PROTONMAIL_PASSWORD": "your-bridge-password"
}
}
}
}
```
That's it — `npx` will download and run the server automatically. It connects to Bridge on its default ports (IMAP 1143, SMTP 1025, both STARTTLS). If Bridge shows other ports or SSL in its mailbox details, add `IMAP_PORT` / `PROTONMAIL_PORT` (and `IMAP_SECURE` / `PROTONMAIL_SECURE`); `proton-mail-mcp doctor --print-config` works them out for you. See [Configuration](#configuration) for all available environment variables.
### Install from source
If you prefer to run from a local clone:
```bash
git clone https://github.com/sethbang/proton-mail-mcp.git
cd proton-mail-mcp
npm install
npm run build
```
Then use this MCP config instead:
```json
{
"mcpServers": {
"protonmail": {
"command": "node",
"args": ["/absolute/path/to/proton-mail-mcp/build/index.js"],
"env": {
"PROTONMAIL_USERNAME": "your-email@protonmail.com",
"PROTONMAIL_PASSWORD": "your-bridge-password"
}
}
}
}
```
## Tools
### Sending
All send tools return the Message-ID of the sent message in their response. The five send tools (`send_email`, `reply_email`, `reply_all_email`, `forward_email`, `send_draft`) then look for the sent copy in the resolved `\Sent` folder and lead the response with a machine-parseable token: `[sent-copy:verified]` (found, with a `Sent copy UID: N in Sent` clause), or `[sent-copy:pending]` when it hasn't appeared within about 5 s. Proton can take 30 s or more to file it, and SMTP accepting the message is what counts, so the call doesn't wait for it. Pass `verifySent: "wait"` to look for up to about 30 s instead; a miss then reports `[sent-copy:unverified]`. None of the three means the send failed: every send result also carries `smtp:accepted` right after the `sent-copy` token, e.g. `[sent-copy:pending smtp:accepted]`. To confirm a pending copy later, call `get_thread` with the Message-ID. When `replyTo` was requested, `[reply-to:preserved|rewritten|stripped|pending|unverified]` reports whether Proton kept it.
> 🛡️ **HTML sanitization defaults to ON.** Send / reply / forward / save_draft tools strip `<script>`, event handlers, inline `style` attributes, and remote `<img>` beacons via a conservative allowlist before delivery. Pass `sanitizeHtml: false` to preserve full-fidelity HTML for trusted-content workflows. The success response notes when sanitization ran.
>
> ⚠️ **Display-name spoofing partially defended.** `fromName` rejects values containing `@` by default — without this guard, a `fromName` like `"Anthropic Security <security@anthropic.com>"` reaches the wire as `Anthropic Security security@anthropic.com` after angle-bracket sanitization, which mail clients render as a forged sender. Pass `allowAddressLikeFromName: true` to override for legitimate product names. SMTP itself still prevents *address-level* spoofing (the envelope `From:` is bound to your authenticated identity), and arbitrary display names without `@` are still allowed (e.g. `"CEO of Acme"`) — treat `fromName` like any other user-controllable string.
All send/reply/forward/save_draft tools accept an alternative `markdownBody` parameter (rendered to HTML via [marked](https://github.com/markedjs/marked)) — mutually exclusive with `body`+`isHtml`. `sanitizeHtml` applies after Markdown rendering.
> 🛡️ **Outbound preview + self-only lock.** `send_email`, `reply_email`, `reply_all_email`, `forward_email` and `send_draft` accept `dryRun: true` — it runs all validation and resolves the complete recipient set (To/CC/BCC, including the reply-all fan-out) and returns it **without sending**, leading with an `[outbound:*]` token and an explicit list of any external (non-self) recipients. Use it to confirm exactly who would receive the mail before a live call. For throwaway/QA accounts, set `RESTRICT_OUTBOUND_TO_SELF=true` (see [Environment variables](#environment-variables)) to *refuse* any live send to a non-self recipient — preventing an agent from fanning real mail out to external addresses embedded in seed data. (Preview is caller-opt-in; the env lock is enforced server-side with no per-call override.)
#### `send_email`
Send an email using Proton Mail SMTP.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `to` | Yes | Recipient address(es): `a@x.com`, `Name <a@x.com>` or `"Doe, Jane" <a@x.com>`, separated by commas or semicolons. Errors name any entry that isn't an address |
| `subject` | Yes | Subject line |
| `body` | Conditional | Plain text or HTML content. Required unless `markdownBody` is provided |
| `isHtml` | No | Whether `body` is HTML (default: `false`) |
| `markdownBody` | No | Markdown source — rendered to HTML before sending. Mutually exclusive with `body`/`isHtml`. Proton stores only the HTML, so the message reads back as HTML |
| `sanitizeHtml` | No | Strip scripts, event handlers, inline styles, and remote `<img>` beacons via a conservative allowlist when the body is HTML. **Default `true`**. Pass `false` to preserve full-fidelity HTML. No-op on plain-text |
| `cc` | No | CC recipient(s), same formats as `to` |
| `bcc` | No | BCC recipient(s), same formats as `to` |
| `replyTo` | No | Reply-To address. Proton can rewrite it to the From address (in live tests, even a `+alias` of the account's own address), reported as `[reply-to:rewritten]`; don't count on it reaching the recipient |
| `fromName` | No | Display name for the From field. Rejects values containing `@` by default (display-name-as-address spoofing defense — see warning above). Pass `allowAddressLikeFromName: true` to override for legitimate cases (product names with `@`) |
| `allowAddressLikeFromName` | No | Opt-in escape valve for `fromName` containing `@`. Default `false` |
| `attachments` | No | Array of `{filename, content, contentType}` or `{path, filename?, contentType?}`. `content` is base64 (validated). `path` is a file relative to `ALLOW_FILE_ATTACH_DIR`, read by the server, so large files don't pass through the model; absolute paths, `..` and symlinks out of the folder are refused. `contentType` is inferred from the filename when omitted. 25 MB in total (Proton's limit) |
| `dryRun` | No | Validate and resolve the full recipient set (To/CC/BCC) + subject + body **without sending**. Returns a preview leading with an `[outbound:*]` token and an explicit list of any external (non-self) recipients (default: `false`) |
| `verifySent` | No | How long to look for the Sent copy: `"quick"` (default: about 5 s, then `[sent-copy:pending]`) or `"wait"` (about 30 s; a miss is `[sent-copy:unverified]`). Either way the message was sent |
#### `reply_email`
Reply to a message with proper threading headers (In-Reply-To, References). Includes the quoted original message with attribution by default.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | UID of the message to reply to |
| `body` | Conditional | Reply body content. Required unless `markdownBody` is provided |
| `folder` | No | Folder containing the original message (default: `INBOX`) |
| `isHtml` | No | Whether `body` is HTML (default: `false`) |
| `markdownBody` | No | Markdown source. Mutually exclusive with `body`/`isHtml` |
| `sanitizeHtml` | No | Strip scripts, event handlers, inline styles, and remote `<img>` beacons via a conservative allowlist when the body is HTML. **Default `true`**. Pass `false` to preserve full-fidelity HTML. No-op on plain-text |
| `cc` | No | Additional CC recipients, same formats as `send_email`'s `to` |
| `bcc` | No | BCC recipients, same formats as `send_email`'s `to` |
| `replyAll` | No | Reply to all recipients instead of just sender (default: `false`). Prefer the dedicated `reply_all_email` tool for discoverability |
| `includeQuote` | No | Include quoted original message below reply (default: `true`) |
| `dryRun` | No | Resolve the reply recipients (incl. reply-all fan-out) + subject **without sending**; returns a preview of who would receive it (default: `false`) |
| `verifySent` | No | How long to look for the Sent copy: `"quick"` (default: about 5 s, then `[sent-copy:pending]`) or `"wait"` (about 30 s; a miss is `[sent-copy:unverified]`). Either way the message was sent |
| `saveAsDraft` | No | Save the message to Drafts (threading headers included) instead of sending it, for a person to review; send it later with [`send_draft`](#send_draft) (default: `false`) |
#### `reply_all_email`
Reply to all original recipients (sender + TO + CC), excluding the authenticated user. Same threading + quoting semantics as `reply_email`. Use this instead of `reply_email` + `replyAll: true` for clarity. Self-exclusion covers the whole recipient set including the primary `To`: replying-all to a message **you** sent reaches the original recipients rather than looping back to you.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | UID of the message to reply to |
| `body` | Conditional | Reply body content. Required unless `markdownBody` is provided |
| `folder` | No | Folder containing the original message (default: `INBOX`) |
| `isHtml` | No | Whether `body` is HTML (default: `false`) |
| `markdownBody` | No | Markdown source. Mutually exclusive with `body`/`isHtml` |
| `sanitizeHtml` | No | Strip scripts, event handlers, inline styles, and remote `<img>` beacons via a conservative allowlist when the body is HTML. **Default `true`**. Pass `false` to preserve full-fidelity HTML. No-op on plain-text |
| `cc` | No | Additional CC recipients beyond original to+cc, same formats as `send_email`'s `to` |
| `bcc` | No | BCC recipients, same formats as `send_email`'s `to` |
| `includeQuote` | No | Include quoted original message below reply (default: `true`) |
| `dryRun` | No | Resolve the full reply-all fan-out (sender + original To + CC, minus self) **without sending**; returns a preview of every recipient. Recommended before a live reply-all on unfamiliar mail (default: `false`) |
| `verifySent` | No | How long to look for the Sent copy: `"quick"` (default: about 5 s, then `[sent-copy:pending]`) or `"wait"` (about 30 s; a miss is `[sent-copy:unverified]`). Either way the message was sent |
| `saveAsDraft` | No | Save the message to Drafts (threading headers included) instead of sending it, for a person to review; send it later with [`send_draft`](#send_draft) (default: `false`) |
#### `forward_email`
Forward a message to new recipients. Original attachments are carried forward by default. Unlike reply, a forward does **not** set `In-Reply-To`/`References` — it starts its own conversation and leaves the original message's `\Answered` flag untouched.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | UID of the message to forward |
| `to` | Yes | Recipient address(es), same formats as `send_email`'s `to` |
| `folder` | No | Folder containing the original message (default: `INBOX`) |
| `body` | No | Optional message to prepend above the forwarded content |
| `isHtml` | No | Whether `body` is HTML (default: `false`) |
| `markdownBody` | No | Markdown source for the prepended message. Mutually exclusive with `body`/`isHtml` |
| `sanitizeHtml` | No | Strip scripts, event handlers, inline styles, and remote `<img>` beacons in the prepended HTML body. Does NOT sanitize the forwarded original content. **Default `true`**; pass `false` to preserve full-fidelity HTML |
| `cc` | No | CC recipients, same formats as `to` |
| `bcc` | No | BCC recipients, same formats as `to` |
| `includeAttachments` | No | Include the original's attached files in the forward (default: `true`). Images embedded in its body aren't included; name them in `attachmentParts` to add them. Pass `false` to strip all attachments |
| `attachmentParts` | No | Forward only the listed MIME part numbers (e.g. `["2", "3.1"]`). Discover parts via `list_attachments`. Mutually exclusive with `includeAttachments: false` |
| `dryRun` | No | Resolve recipients (To/CC/BCC) + subject + attachment count **without sending or downloading attachment bytes**; returns a recipient preview (default: `false`) |
| `verifySent` | No | How long to look for the Sent copy: `"quick"` (default: about 5 s, then `[sent-copy:pending]`) or `"wait"` (about 30 s; a miss is `[sent-copy:unverified]`). Either way the message was sent |
| `saveAsDraft` | No | Save the message to Drafts (threading headers included) instead of sending it, for a person to review; send it later with [`send_draft`](#send_draft) (default: `false`) |
#### `save_draft`
Save an email as a draft without sending it. The draft is placed in the user's `\Drafts` special-use folder (resolved at runtime; falls back to literal `Drafts` if no annotation). Returns the draft UID when available.
> ⓘ Drafts always go to the Drafts folder; there is no `folder` parameter.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `to` | Yes | Recipient address(es), same formats as `send_email`'s `to` |
| `subject` | Yes | Subject line |
| `body` | Conditional | Plain text or HTML content. Required unless `markdownBody` is provided |
| `isHtml` | No | Whether `body` is HTML (default: `false`) |
| `markdownBody` | No | Markdown source — rendered to HTML before saving. Mutually exclusive with `body`/`isHtml` |
| `sanitizeHtml` | No | Strip scripts, event handlers, inline styles, and remote `<img>` beacons via a conservative allowlist when the body is HTML. **Default `true`**. No-op on plain-text |
| `cc` | No | CC recipient(s), same formats as `to` |
| `bcc` | No | BCC recipient(s), same formats as `to` |
| `replyTo` | No | Reply-To address. The saved draft is checked; if the server didn't keep it, the result says `[reply-to:dropped]` and `send_draft` would send without one. `send_email` sets one and reports a rewrite, but can't make Proton keep it |
| `fromName` | No | Display name for the From field. Rejects values containing `@` by default (display-name-as-address spoofing defense — see warning above). Pass `allowAddressLikeFromName: true` to override for legitimate cases (product names with `@`) |
| `allowAddressLikeFromName` | No | Opt-in escape valve for `fromName` containing `@`. Default `false` |
| `attachments` | No | Same as `send_email` |
| `replaceDraftUid` | No | UID of a prior draft to replace. A full replacement: fields left out (cc, bcc, replyTo…) aren't carried over. Saves the new draft first and deletes the old one only on success. Refused if the UID isn't in Drafts, or if the old draft looks unrelated (different subject, no shared recipient) |
| `replaceUnrelated` | No | Allow `replaceDraftUid` to replace a draft that looks unrelated (default: `false`) |
Drafts keep their BCC recipients.
#### `send_draft`
Send a draft from the Drafts folder, then remove it from Drafts. It goes to the draft's To, CC and BCC exactly as saved; BCC recipients aren't shown to the others. Works for drafts from `save_draft`, from `saveAsDraft` on a reply or forward, or written in Proton's apps. The same safeguards as `send_email` apply: the rate limit, the 50-recipient limit, `RESTRICT_OUTBOUND_TO_SELF`, and Sent-copy verification. Refuses a draft that isn't from this account.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | UID of the draft in the Drafts folder (`save_draft` returns it) |
| `threadWith` | No | For a reply: `{folder, uid}` of the message it answers. Bridge drops a saved draft's threading headers, so they're rebuilt from this message; a `saveAsDraft` result gives the exact value |
| `dryRun` | No | Show the recipients and subject without sending (default: `false`) |
| `verifySent` | No | How long to look for the Sent copy: `"quick"` (default: about 5 s, then `[sent-copy:pending]`) or `"wait"` (about 30 s; a miss is `[sent-copy:unverified]`). Either way the message was sent |
### Reading
#### `check_connection`
Diagnose the IMAP (Bridge) and SMTP connections. No parameters, sends no mail, opens no mailbox. Reports for each endpoint whether the configured port is listening, whether it greets as the right protocol in the configured TLS mode, and whether the login is accepted. When a local port fails, it scans Bridge's usual port ranges and names the port Bridge is actually on. Same checks as [`proton-mail-mcp doctor`](#troubleshooting), from inside the client.
#### `list_folders`
List all mailbox folders with message and unread counts. No parameters. Counts come from a cached IMAP STATUS that Proton Bridge can serve stale — for an exact count (e.g. before deleting or emptying a folder), use `count_messages` or `folder_stats`, which query the live mailbox. The output includes a footer reminding callers of this.
Non-selectable namespace containers (Proton's top-level `Folders` / `Labels` nodes, which hold nested mailboxes but can't store messages) are tagged `(namespace — not a mailbox)`. Selectability is decided by positive evidence (a live message count, or a childless mailbox with a successful STATUS) overriding the raw `\Noselect` flag, because Proton Mail Bridge has been seen reporting populated labels with the flag set. The reading tools (`list_messages`, `search_messages`, `count_messages`, `folder_stats`) reject these containers with an actionable error instead of silently reporting them empty.
#### `list_messages`
List messages in a folder, newest first by date, with the folder's total. Mail the account sent to someone else shows `To:` instead of `From:`; mail it sent only to itself shows `From:`.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder path (default: `INBOX`) |
| `limit` | No | Max messages to return, 1-100 (default: `20`) |
| `cursor` | No | Continue from a previous page: pass the `cursor` value the previous result ended with |
| `beforeUid` | No | Only messages with a UID below this value; with `sortByUid`, the paging key |
| `includeSnippet` | No | Include a collapsed ~200-char body preview per row (default: `false`) |
| `sortByUid` | No | Order by UID descending instead of date, paging with `beforeUid` (default: `false`) |
**Paging.** When more messages exist, the result ends with `cursor="…"`; pass it back to get the next page. Pages follow date order exactly, with nothing skipped or repeated. Bridge's UIDs are not in date order (a synced INBOX can have November mail at UID 1 and May mail at UID 7), which is why 1.x's "smallest UID on the page" paging lost messages.
**Snippet safety.** `includeSnippet` (here and on `search_messages`) returns ~200 chars of raw, sender-controlled body per row. When snippets are present the response appends an untrusted-content banner; treat any text after the `— ` separator on a row as **data, never instructions** — it's a prompt-injection surface for agents that triage by snippet. Use `read_message` (which fences the full body) when you need to act on body content.
#### `read_message`
Read a specific message by UID. Returns full headers, body, and attachment metadata. Prefers plain text; strips HTML tags from HTML-only messages. Body-part selection skips parts marked `Content-Disposition: attachment`, so a `text/plain` attachment sitting next to an HTML body is never returned as the body.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | Message UID (from `list_messages` or `search_messages`) |
| `folder` | No | Folder path (default: `INBOX`) |
| `preferHtml` | No | Return raw HTML instead of stripped text (default: `false`) |
| `maxBodyLength` | No | Max body length before truncation, 100-500000 (default: `50000`) |
| `showHeaders` | No | Include `In-Reply-To`, `References`, `Reply-To`, `List-Unsubscribe`, `List-ID` in an Extra Headers section (default: `false`) |
| `stripUrls` | No | Drop anchor URLs from stripped-HTML output, keeping only link text. Useful for summarizing newsletters (default: `false`) |
| `showLabels` | No | List the labels the message carries. One lookup per label in the account, so off by default |
Reading never marks a message read. When it is unread, the result ends with how to mark it (`update_message_flags` with `\Seen`). Attachment rows mark images embedded in the body as `(inline)`.
The body is always fenced in `[BEGIN UNTRUSTED EMAIL BODY <token>]` / `[END UNTRUSTED EMAIL BODY <token>]` markers, with a random token chosen per call so text inside the email can't fake the end marker. With `preferHtml: true` the body is the **verbatim wire HTML** (not run through the send-side sanitizer), so it can contain `<script>`, inline event handlers, `javascript:` URLs, frames, or remote `<img>` tracking beacons. When any of those are detected the response emits a `[html:active-content]` token before the body — do **not** render or execute that HTML; treat it strictly as data. (`cid:`/`data:` inline images aren't flagged.)
#### `list_attachments`
List attachment metadata (part numbers, filenames, types, sizes) for a message without downloading the body. Composes with `download_attachment` for bulk extraction. The reported size is the **decoded** file size (roughly what you get on save), **estimated** from the IMAP-encoded octet count — base64 parts are ~37% smaller decoded than their wire size. It's displayed with a leading `~` because it's approximate (±~2 bytes, not byte-exact — don't assert on it or pre-allocate buffers); the exact byte count comes from `download_attachment`, which reports the real decoded length.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | Message UID |
| `folder` | No | Folder containing the message (default: `INBOX`) |
#### `download_attachment`
Download an attachment by MIME part number. Use `list_attachments` or `read_message` first to see available parts. By default returns base64-encoded content inline. Bad part numbers produce an actionable error listing known parts.
When the `ALLOW_FILE_DOWNLOAD_DIR` env var is set, the optional `saveTo` parameter writes the decoded bytes to disk inside that allowlist root and returns the file path + size instead of base64 — avoids blowing the token budget on large attachments. Path safety: rejects absolute paths, any path (`..`, symbolic links) that leads outside that folder, and hidden names (a file or folder starting with `.`). An existing file is not replaced unless you pass `overwrite: true`, and a symbolic link is never written through. If the configured directory doesn't exist, you get an actionable "create it first" error rather than a raw `ENOENT`.
> ⓘ **Pre-flight size guard.** When called without `saveTo`, the guard compares the attachment's **base64-encoded** size (what the inline response actually costs) against a ~40 KB cap — roughly a 29 KB decoded file. Larger attachments throw upfront, since the inline base64 would overflow most MCP framework response caps; the error reports both the decoded and encoded sizes so they line up with the threshold. To download larger files, set `ALLOW_FILE_DOWNLOAD_DIR` in your client config and pass `saveTo`. For Claude Desktop, add to `claude_desktop_config.json`:
>
> ```json
> {
> "mcpServers": {
> "proton-mail": {
> "command": "npx",
> "args": ["-y", "proton-mail-mcp"],
> "env": {
> "ALLOW_FILE_DOWNLOAD_DIR": "/Users/you/proton-attachments"
> }
> }
> }
> }
> ```
>
> Then call `download_attachment` with `saveTo: "report.pdf"` (relative to that directory). The response returns the file path + byte count instead of inline base64.
>
> ⚠️ **For an agent to *read back* what it saved, the same directory must also be mounted into the agent's workspace/file tools.** `ALLOW_FILE_DOWNLOAD_DIR` only grants this server permission to *write* there — it does not grant the calling agent permission to read it. If the two don't overlap, the agent can save an attachment but not open it, making "download this attachment and tell me what's in it" a dead end. Point `ALLOW_FILE_DOWNLOAD_DIR` at a folder that's already connected to the agent's environment (e.g. a Claude Cowork directory) so the round-trip works end-to-end.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | Message UID |
| `partNumber` | Yes | MIME part number (from `read_message` / `list_attachments`) |
| `folder` | No | Folder containing the message (default: `INBOX`) |
| `saveTo` | No | Relative path inside `ALLOW_FILE_DOWNLOAD_DIR` to write the decoded attachment to. Requires the env var to be set |
| `overwrite` | No | With `saveTo`: replace a file that already exists at that path (default `false`) |
| `asText` | No | Return a text, JSON, XML or CSV attachment as text (fenced as untrusted) instead of base64 (default: `false`). Ignored with `saveTo`; the ~40 KB inline cap still applies |
#### `search_messages`
Search messages by various criteria. `since` is inclusive, `before` is exclusive.
> ⓘ **Dates are UTC calendar days**, the zone every timestamp in the results is shown in. The server widens Bridge's search by a day on each side and applies the exact range itself, so a message at `03:14 UTC` on May 26 matches `since: "2026-05-26"` wherever the server runs.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder to search (default: `INBOX`) |
| `from` | No | Filter by sender |
| `to` | No | Filter by recipient |
| `subject` | No | Case-insensitive substring of the decoded subject; emoji, accents and multi-word phrases work |
| `body` | No | Filter by body content (substring match) |
| `since` | No | Messages on or after this date (`YYYY-MM-DD`, UTC, inclusive) |
| `before` | No | Messages strictly before this date (`YYYY-MM-DD`, UTC, exclusive) |
| `seen` | No | `true` = read, `false` = unread |
| `flagged` | No | Filter by flagged/starred status |
| `larger` | No | Messages larger than this many bytes (maps to IMAP `LARGER`) |
| `smaller` | No | Messages smaller than this many bytes (maps to IMAP `SMALLER`) |
| `listId` | No | Filter by List-ID header substring (useful for newsletters/mailing lists) |
| `hasAttachment` | No | `true`: messages with at least one attached file; `false`: messages without one. Images embedded in an HTML body (logos, banners) don't count. Checks the newest 500 candidates by date |
| `attachmentName` | No | Case-insensitive substring of any file part's name (e.g. `"invoice"`, `".pdf"`), embedded images included |
| `attachmentType` | No | Case-insensitive MIME-type prefix of any file part (e.g. `"application/pdf"`, `"image/"`), embedded images included |
| `limit` | No | Max results, 1-100 (default: `20`) |
| `cursor` | No | Continue from a previous page, as for `list_messages` |
| `includeSnippet` | No | Include a collapsed ~200-char body preview per row (default: `false`) |
> ⓘ For subject/body queries on freshly-sent mail, results may lag by 30–60 seconds (Proton's index updates asynchronously). The response surfaces a staleness footer pointing at `list_messages`, or `get_thread` with the Message-ID, when applicable.
#### `get_thread`
Get all messages in a conversation thread by walking In-Reply-To and References headers. Returns messages sorted chronologically (oldest first).
Prefer `messageId` — Message-IDs are globally unique, so this sidesteps the UID-collision footgun (UIDs are per-folder in IMAP) and walks INBOX + Sent + All Mail by default to catch replies that span folders. (uid mode is single-folder and will silently undercount a cross-folder thread.) Output rows are tagged `UID X @FolderName` in both modes, and the response dedupes by Message-ID across mailbox copies — the same physical message appearing in INBOX and All Mail collapses into one row tagged `(also in: All Mail)` instead of double-counting the thread. A thread member that lives in a user folder (e.g. `Folders/Development`) and surfaces only via the All Mail virtual copy is rewritten to its real storage folder **and** UID, so the `folder`/`uid` pair each row reports is valid in a single-folder tool (`move_message` / `delete_message`) rather than an All Mail UID that would misfire.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `messageId` | No | RFC 5322 Message-ID (preferred over `uid`+`folder`) |
| `uid` | No | UID of a thread message (used when `messageId` is omitted; folder-scoped) |
| `folder` | No | Folder the UID lives in when using `uid` mode (default: `INBOX`) |
| `folders` | No | Override the default folder walk when `messageId` is set (default: `["INBOX", "Sent", "All Mail"]`) |
| `limit` | No | Max messages to return, 1-50 (default: `25`) |
**Scope: reply chain only.** This walks `In-Reply-To`/`References`, so it returns the reply chain. **Forwards are not included** — a forward doesn't reference the original (it starts its own conversation), so a forwarded copy of a message won't appear in that message's thread. A 1-result thread doesn't mean a bug when only forwards (not replies) exist.
### Organizing
#### `move_message`
Move a message to a different folder. Returns the new UID in the destination folder when available (requires UIDPLUS server support). The destination must be a folder: moving into `Labels/…` is refused (use `update_message_labels`), as is moving into the folder the message is already in. Moving a UID from All Mail or Starred is resolved to the message's real folder first (Bridge refuses moves out of those views). If the same message is also shown in INBOX or Sent, the result says it leaves there too; the Sent copy of mail you sent yourself is a separate message and stays.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | Message UID |
| `destination` | Yes | Destination folder (e.g. `Archive`, `Spam`, `Folders/Work`; `Work` resolves to `Folders/Work`) |
| `folder` | No | Source folder (default: `INBOX`) |
| `dryRun` | No | Preview the move, with the message's date, sender and subject, without changing anything (default: `false`) |
#### `delete_message`
Delete a message. By default moves to Trash for safety (resolved via special-use annotation); `permanent: true` with `confirm: true` deletes it for good, the way Proton does: it is moved to Trash and removed there, then checked to be gone (removing it in place would only take it out of that folder). Returns the new UID in Trash when available. Soft-deleting a message that is **already in Trash** is a no-op on the server; the tool says so and how to delete it permanently.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | Message UID |
| `folder` | No | Folder containing the message (default: `INBOX`) |
| `permanent` | No | If `true`, permanently expunge instead of moving to Trash (default: `false`). Requires `confirm: true` |
| `confirm` | No | Must be `true` with `permanent: true`: a permanent delete can't be undone (default: `false`) |
| `dryRun` | No | Preview the delete, with the message's date, sender and subject, without changing anything; needs no `confirm` (default: `false`) |
#### `update_message_flags`
Add or remove flags on a message. System flags: `\Seen` (read), `\Flagged` (starred), `\Answered`, `\Draft`. `\Recent` (server-managed) and `\Deleted` (doesn't delete on Proton; use `delete_message`) are refused as flags to add; `\Deleted` can be removed, to clear one left by an earlier failed delete. The same flag can't be in both lists. A system flag written without its backslash or in another case (`Seen`, `\seen`) gets "Did you mean `\Seen`?". User-defined keywords without a backslash prefix are also accepted (alphanumeric + underscore, e.g. `Important`, `Custom_Tag`), though Bridge usually drops them.
Post-STORE verify: the server's FETCH response is checked against the requested operation. Flags the server failed to apply (commonly user keywords silently dropped by Proton Mail Bridge) are reported in the response as `no-op (not applied): ...`.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | Message UID |
| `folder` | No | Folder containing the message (default: `INBOX`) |
| `flagsToAdd` | No | Flags to add (e.g. `["\\Seen", "\\Flagged"]`) |
| `flagsToRemove` | No | Flags to remove (e.g. `["\\Seen"]`) |
#### `update_message_labels`
Add or remove Proton **labels** on a message. Labels live under the `Labels/` namespace and are additive — the message stays in its source folder while gaining or losing label tags.
- **Add** is implemented as IMAP `COPY` from the source folder to `Labels/<name>`. The source UID is unchanged.
- **Remove** locates the message in the label mailbox by its `Message-ID` header and `messageDelete`s that UID — removing only the label, not the underlying message.
Adds are strict: copying to a missing label throws `Label not found: <path>` (create it first with `create_label`). Removes are idempotent — removing a label that doesn't apply, or doesn't exist as a mailbox, is a silent no-op.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `uid` | Yes | Message UID in the source folder |
| `folder` | No | Source folder containing the message (default: `INBOX`) |
| `labelsToAdd` | No | Labels to add, by name or path, any case (e.g. `["Important", "Labels/Work"]`) |
| `labelsToRemove` | No | Labels to remove, by name or path |
#### `mark_all_read`
Mark all unread messages in a folder as read. Optionally limit to messages older than a given date. Pass `dryRun: true` to preview the affected count without flipping any flags.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder to mark as read (default: `INBOX`) |
| `olderThan` | No | Only mark messages strictly before this date (`YYYY-MM-DD`, UTC, exclusive) |
| `dryRun` | No | Preview the count of unread messages that would be marked, without flipping any flags (default: `false`) |
#### `bulk_move`
Move many messages in a single IMAP operation. Accepts either an explicit `uids` array or `match` criteria (XOR, not both). Supports `dryRun: true` to preview which UIDs would be affected without making changes — match-based dry-runs run the SEARCH results through a FETCH-based existence pass so the preview matches what the live operation will actually do (Proton Mail Bridge's SEARCH index lags FETCH for ~1–2s after a recent move/delete, and the preview would otherwise list phantom UIDs that have already left the folder). Reports `notFound[]` for UIDs the pre-check didn't see. Same dry-run accuracy applies to `bulk_delete`, `bulk_update_flags`, and `bulk_update_labels`.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Source folder (default: `INBOX`) |
| `destination` | Yes | Destination folder path |
| `uids` | No | Explicit array of UIDs to move (max 1000; XOR with `match`) |
| `match` | No | Search criteria to select messages (XOR with `uids`) |
| `dryRun` | No | Preview without moving (default: `false`) |
#### `bulk_delete`
Delete many messages in a single IMAP operation. Same XOR `uids`/`match` input and `dryRun` support as `bulk_move`. Defaults to soft-delete via the resolved Trash path. A subject/body `match` appends a staleness warning — Proton's content SEARCH lags ~30–60s, so recent mail can be silently missed; prefer `from:`/date filters or explicit `uids` for destructive cleanup.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder containing the messages (default: `INBOX`) |
| `uids` | No | Explicit array of UIDs to delete (max 1000; XOR with `match`) |
| `match` | No | Search criteria to select messages (XOR with `uids`) |
| `permanent` | No | Permanently expunge instead of moving to Trash (default: `false`). Requires `confirm: true`. |
| `confirm` | No | Must be `true` when `permanent` is `true` — acknowledges the expunge is irreversible (default: `false`) |
| `dryRun` | No | Preview without deleting (default: `false`; needs no confirmation) |
#### `bulk_update_flags`
Add or remove flags on many messages in a single IMAP operation. Same XOR `uids`/`match` input and `dryRun` support. Reports `notApplied: string[]` for flags the server silently dropped across every affected UID (e.g. Proton's user-keyword drop).
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder containing the messages (default: `INBOX`) |
| `uids` | No | Explicit array of UIDs (max 1000; XOR with `match`) |
| `match` | No | Search criteria to select messages (XOR with `uids`) |
| `flagsToAdd` | No | Flags to add (e.g. `["\\Seen", "\\Flagged"]`) |
| `flagsToRemove` | No | Flags to remove (e.g. `["\\Seen"]`) |
| `dryRun` | No | Preview without updating (default: `false`) |
#### `bulk_update_labels`
Add or remove Proton labels on many messages in a single IMAP operation. Same XOR `uids`/`match` input and `dryRun` support as the other bulk tools. Adds are batched (one COPY of the joined UID range per label); removes walk each label mailbox by Message-ID. Reports `notApplied: string[]` for labels with no observed effect (e.g., a remove for a label none of the UIDs actually carried).
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Source folder containing the messages (default: `INBOX`) |
| `uids` | No | Explicit array of UIDs (max 1000; XOR with `match`) |
| `match` | No | Search criteria to select messages (XOR with `uids`) |
| `labelsToAdd` | No | Labels to add, by name or path, any case (e.g. `["Work"]`, `["Labels/Work"]`). Each must already exist (create it with `create_label`) |
| `labelsToRemove` | No | Labels to remove, by name or path |
| `dryRun` | No | Preview without updating (default: `false`) |
#### `create_folder`
Create a new mailbox folder. Idempotent — succeeds silently if the folder already exists, and reports its real spelling if it exists in another case. A bare name goes under `Folders/` (`Receipts` creates `Folders/Receipts`). **`Labels/...` paths are rejected** with a redirect to the dedicated `create_label` tool. `.` and `..` path segments are rejected — symmetric with `delete_folder`, so anything you can create here you can also clean up.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `path` | Yes | Folder to create: a name (`Receipts`) or path (`Folders/Receipts`, `Folders/Newsletters/Politics`) |
#### `create_label`
Create a new Proton label. Pass the label name; a `Labels/` prefix is accepted too. Idempotent; if the label exists in another case, the response gives its real name.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `name` | Yes | Label name, e.g. `Important`. Labels can't be nested, so no `/` beyond an optional `Labels/` prefix |
#### `rename_folder`
Rename an existing folder or label. **Restricted to the `Folders/` and `Labels/` namespaces on both `from` and `to`** so system mailboxes (INBOX, Sent, Trash, etc.) can't be renamed — without this guard, `rename_folder(from: "INBOX", to: ...)` would succeed against Proton Mail Bridge and relocate INBOX's contents. `.` and `..` path segments are rejected on both ends. **Cross-namespace renames are also rejected** (`Folders/X` → `Labels/Y` and vice versa) with an actionable error pointing at `bulk_move` / `update_message_labels` for the right primitive. Missing-source errors are translated to an actionable message (post-failure `status()` probe so Proton's bare `Command failed` doesn't leak through).
| Parameter | Required | Description |
|-----------|----------|-------------|
| `from` | Yes | Current path (`Folders/Old` or `Labels/Old`) |
| `to` | Yes | New path (`Folders/New` or `Labels/New`) |
#### `delete_folder`
Delete a folder or label container. Restricted to the `Folders/` and `Labels/` namespaces so system mailboxes (INBOX, Sent, Trash, etc.) cannot be removed.
> ⓘ **`.` and `..` segments are allowed here.** `delete_folder` accepts them (e.g. `Folders/../Escape`): IMAP treats paths as opaque literal names with no parent-dir semantics, so rejecting them would add no security and would block cleanup of such paths created by other IMAP clients or older versions of this MCP. `create_folder` / `rename_folder` still reject those segments where keeping confusable paths out of existence is the point.
What happens to the mail:
- Deleting a `Folders/...` path doesn't delete its messages, but takes them out of every folder: they remain only in `All Mail`, which is easy to lose track of. Pass `moveContentsTo` (e.g. `Archive` or `INBOX`) to move the mail there first; if a move fails, nothing is deleted.
- Deleting a `Labels/...` path removes the label; the messages stay in their folders.
- **Nested folders** are deleted with it, and their mail is counted and moved too. Pass `dryRun: true` first to see the nested folders and per-folder message counts.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `path` | Yes | Path to delete (must start with `Folders/` or `Labels/`) |
| `moveContentsTo` | No | Folders only: move all of the folder's mail, nested folders included, here before deleting |
| `dryRun` | No | Show the nested folders and message counts without deleting (default: `false`) |
#### `empty_folder`
Permanently empty a folder via atomic UID `EXPUNGE` (`client.messageDelete`). Requires `confirm: true`. By default restricted to Trash and Junk to prevent accidents; set `allowAnyFolder: true` to target any folder. Pass `dryRun: true` to preview the count that would be deleted without touching any mail (no `confirm` required for a dry run).
> ⚠️ **Not registered by default.** Set `ALLOW_EMPTY_FOLDER=true` in the environment to opt in. **Enabling is not recommended** — Trash is the user's last line of defense against destructive agent actions. The web UI empties Trash in two clicks; the convenience of delegating that to an LLM rarely justifies the irreversibility. Leave it off unless you have a specific automation that needs it.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | Yes | Folder to empty |
| `confirm` | Yes\* | Must be `true` to proceed (\*not required when `dryRun: true`) |
| `allowAnyFolder` | No | Allow emptying folders other than Trash/Junk (default: `false`) |
| `dryRun` | No | Preview the count that would be deleted without deleting anything (default: `false`) |
#### `count_messages`
Return a count of messages matching optional criteria, backed by IMAP SEARCH. No envelope fetch — just a number.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder to count in (default: `INBOX`) |
| `match` | No | Optional search criteria to narrow the count |
#### `folder_stats`
Return total/unread counts plus scanned-envelope aggregations: oldest message date, newest message date, and total message bytes. Response includes `scanned` and `truncated` fields for transparency.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder to analyze (default: `INBOX`) |
| `scanLimit` | No | Max envelopes to scan for aggregations, 1-20000 (default: `5000`) |
#### `top_senders`
Return a sender frequency table over a configurable date range, sorted by message count descending. Collapses display-name variants of the same address. Each row carries a `direction: "self"|"received"` tag so callers scanning `All Mail` (which spans Sent) can tell outbound from inbound.
> 🛡️ **Display names are attacker-controlled.** Buckets are keyed by email address; the row label uses the *most frequently observed* display name for that address, so a single email with a spoofed `From` name (e.g. `"Your Bank" <attacker@x>`) can't poison the label for an address. The email address is always shown alongside the name — treat the name as untrusted and key any trust decision on the address.
> ⓘ `excludeSelf` defaults to `true`: the authenticated user's own outgoing messages are left out of the table unless you pass `excludeSelf: false`.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `folder` | No | Folder to analyze (default: `INBOX`) |
| `since` | No | Count messages on or after this date (`YYYY-MM-DD`, UTC, inclusive) |
| `before` | No | Count messages strictly before this date (`YYYY-MM-DD`, UTC, exclusive) |
| `limit` | No | Max senders to return, 1-200 (default: `20`) |
| `scanLimit` | No | Max envelopes to scan, 1-20000 (default: `5000`) |
| `excludeSelf` | No | Drop rows whose address matches `PROTONMAIL_USERNAME` (default: `true`) |
When the table comes back empty but envelopes were scanned, the response explains that `excludeSelf: true` filtered everything (the usual cause on a self-to-self or outbound-only folder) and points at `excludeSelf: false` — so an empty table isn't misread as "folder empty" or a tool failure.
#### `move_thread`
Move all messages in a thread to a destination folder. Identified by Message-ID. By default it acts only in the seed message's own folder; set `acrossFolders: true` to walk INBOX + Sent + All Mail. When the walk surfaces a thread member only via All Mail (e.g. the message actually lives in `Folders/Archive`), the server expands the search across user folders to find the real storage location before mutating — without that step the operation would no-op against All Mail under Proton's label model. Dry-runs include an `acrossFolders` scope hint when the default `false` is in effect.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `messageId` | Yes | RFC 5322 Message-ID of any message in the thread |
| `destination` | Yes | Destination folder path |
| `acrossFolders` | No | `false` (default): act only in the seed message's own folder. `true`: walk INBOX + Sent + All Mail |
| `dryRun` | No | Preview without moving (default: `false`) |
#### `delete_thread`
Delete all messages in a thread. By default it acts only in the seed message's own folder; set `acrossFolders: true` to walk INBOX + Sent + All Mail.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `messageId` | Yes | RFC 5322 Message-ID of any message in the thread |
| `permanent` | No | Permanently expunge instead of moving to Trash (default: `false`). Requires `confirm: true` |
| `confirm` | No | Must be `true` with `permanent: true` (default: `false`) |
| `acrossFolders` | No | `false` (default): act only in the seed message's own folder. `true`: walk INBOX + Sent + All Mail |
| `dryRun` | No | Preview each message's folder, UID, date and subject, and its other copies, without deleting (default: `false`) |
#### `flag_thread`
Add or remove flags on all messages in a thread. By default it acts only in the seed message's own folder; set `acrossFolders: true` to walk INBOX + Sent + All Mail.
| Parameter | Required | Description |
|-----------|----------|-------------|
| `messageId` | Yes | RFC 5322 Message-ID of any message in the thread |
| `flagsToAdd` | No | Flags to add (e.g. `["\\Seen", "\\Flagged"]`) |
| `flagsToRemove` | No | Flags to remove (e.g. `["\\Seen"]`) |
| `acrossFolders` | No | `false` (default): act only in the seed message's own folder. `true`: walk INBOX + Sent + All Mail |
| `dryRun` | No | Preview without updating (default: `false`) |
### Inbox cleanup workflows
**Move all newsletters from a sender to Archive**
1. `search_messages(folder: "INBOX", listId: "politics.substack.com", limit: 5)` — confirm matches.
2. `bulk_move(folder: "INBOX", match: { listId: "politics.substack.com" }, destination: "Archive", dryRun: true)` — preview the affected UIDs.
3. `bulk_move(folder: "INBOX", match: { listId: "politics.substack.com" }, destination: "Archive")` — commit.
**Identify and prune the noisiest senders**
1. `top_senders(folder: "INBOX", since: "2025-01-01")` — frequency table.
2. `count_messages(folder: "INBOX", match: { from: "noreply@noisy.com" })` — exact count.
3. `bulk_delete(folder: "INBOX", match: { from: "noreply@noisy.com" }, permanent: false, dryRun: true)` — preview.
4. `bulk_delete(folder: "INBOX", match: { from: "noreply@noisy.com" }, permanent: false)` — soft-delete to Trash.
5. _(Optional, opt-in only)_ `empty_folder(folder: "Trash", confirm: true)` — permanent cleanup. Requires `ALLOW_EMPTY_FOLDER=true` in the environment; **not recommended** — the Proton web UI empties Trash in two clicks and that's safer than handing the capability to an agent.
## Configuration
### Environment Variables
**SMTP** (the username and a password are required):
| Variable | Default | Description |
|----------|---------|-------------|
| `PROTONMAIL_USERNAME` | -- | Your Proton Mail email address |
| `PROTONMAIL_PASSWORD` | -- | The Bridge password (from Bridge's mailbox details, not your Proton login password). With `smtp.protonmail.ch`, an [SMTP token](https://proton.me/support/smtp-submission) |
| `PROTONMAIL_PASSWORD_FILE` | -- | Alternative: path to a file containing the password (one trailing newline is ignored) |
| `PROTONMAIL_PASSWORD_COMMAND` | -- | Alternative: shell command that prints the password, run once at startup (10s limit). See [Keeping the password out of client configs](#keeping-the-password-out-of-client-configs) |
| `PROTONMAIL_HOST` | `127.0.0.1` | SMTP host. Defaults to Proton Mail Bridge; before 2.0.0 the default was `smtp.protonmail.ch` |
| `PROTONMAIL_PORT` | `1025` on this machine, else `587` | SMTP port. When unset: `1025` (Bridge's default) for a host on this machine (`127.0.0.1`, `localhost`, `::1`), `587` for any other host, such as `smtp.protonmail.ch`. Check Bridge's mailbox details if Bridge moved it, and set it for Bridge on another machine |
| `PROTONMAIL_SECURE` | `false` | `false`: STARTTLS (Bridge's default). `true`: TLS from the first byte (Bridge's SSL mode, or port 465) |
Set exactly one of `PROTONMAIL_PASSWORD`, `PROTONMAIL_PASSWORD_FILE`, `PROTONMAIL_PASSWORD_COMMAND`; setting more than one is a startup error.
**IMAP (for read/search tools):**
| Variable | Default | Description |
|----------|---------|-------------|
| `IMAP_HOST` | `127.0.0.1` | Proton Mail Bridge host |
| `IMAP_PORT` | `1143` | Bridge IMAP port |
| `IMAP_SECURE` | `false` | `false`: STARTTLS (Bridge's default). `true` for Bridge's SSL mode |
| `IMAP_USERNAME` | _falls back to SMTP username_ | Bridge username |
| `IMAP_PASSWORD` | _falls back to `PROTONMAIL_PASSWORD`_ | Bridge password, if it differs |
**Other:**
| Variable | Default | Description |
|----------|---------|-------------|
| `DEBUG` | `false` | Enable verbose logging to stderr |
| `READONLY` | `false` | Disable all mutating tools (send/reply/forward, drafts, move/delete/flags/labels, bulk_*, create/rename/delete folders + labels, empty_folder, thread mutations). `download_attachment` stays available and can still write files with `saveTo`; leave `ALLOW_FILE_DOWNLOAD_DIR` unset to prevent disk writes |
| `RESTRICT_OUTBOUND_TO_SELF` | `false` | Lock the send-family tools to self-sends only: a live `send_email`/`reply_email`/`reply_all_email`/`forward_email`/`send_draft` to any recipient other than `PROTONMAIL_USERNAME` is refused (with the blocked external addresses named). No per-call override. Off by default (blocking external mail is wrong for a general-purpose server); independent of `READONLY`. Use `dryRun: true` to preview the would-block outcome. Intended for throwaway/QA accounts to stop agents fanning real mail to external addresses in seed data. |
| `ALLOW_EMPTY_FOLDER` | `false` | Register the `empty_folder` tool. **Not recommended** — see the [`empty_folder`](#empty_folder) section for why. Independent of `READONLY` (which still disables it). |
| `ALLOW_FILE_DOWNLOAD_DIR` | _unset_ | Allowlist directory enabling `download_attachment.saveTo`. When unset, the `saveTo` parameter is rejected and attachments always return as inline base64. When set to an existing directory, `saveTo` paths resolve inside it; absolute paths, `..` traversal, and symlink escapes are rejected. |
| `ALLOW_FILE_ATTACH_DIR` | _unset_ | Folder `send_email` and `save_draft` may read attachments from, given as a `path` relative to it. Absolute paths, `..` and symlinks out of it are refused. When unset, attachments must be passed as base64 `content`. |
### Keeping the password out of client configs
Bridge issues a new password whenever an account is removed and re-added, and every client config holding the old one breaks. Store it once and point each client at it instead. On macOS, with Keychain:
```sh
security add-generic-password -s proton-bridge -a you@proton.me -T /usr/bin/security -w # prompts for the Bridge password
```
```json
"PROTONMAIL_PASSWORD_COMMAND": "/usr/bin/security find-generic-password -s proton-bridge -a you@proton.me -w"
```
`-T /usr/bin/security` lets the lookup read the item without a Keychain approval dialog. Without it, macOS asks the first time; the command has 10 seconds and no terminal, so a dialog left unanswered fails startup. Click **Always Allow**, or delete the item and add it again with `-T`. Desktop apps start servers with a minimal `PATH`, so give the command's absolute path (`/usr/bin/security`, `/opt/homebrew/bin/op`, and so on).
On Linux, `secret-tool lookup service proton-bridge` (libsecret) or `pass show proton-bridge` work the same way, or use `PROTONMAIL_PASSWORD_FILE` with a `chmod 600` file. After rotating the password, update the one stored copy and restart the client. The command's output is never logged, and a failing command is reported by exit status only.
## Troubleshooting
When tools fail, or a tool call seems to hang, run the doctor with the same environment your client uses:
```sh
npx -y proton-mail-mcp doctor # from a source checkout: node build/index.js doctor
npx -y proton-mail-mcp doctor --print-config # plus a ready-to-paste client config
npx -y proton-mail-mcp doctor --no-scan # skip scanning for Bridge on other ports
```
It checks, for IMAP and SMTP separately:
- **Is anything listening on the configured port?** Bridge moves to the next free port when its default (IMAP 1143, SMTP 1025) is taken, without warning, which strands every client config. When a local port fails, the doctor scans Bridge's usual ranges and prints the fix, e.g. `fix IMAP_PORT=1144`.
- **Is it actually a mail server, in the configured TLS mode?** It catches a port held by an unrelated program (which accepts connections and never answers) and a `*_SECURE` flag that doesn't match the port.
- **Is the login accepted?** A rejection usually means a stale Bridge password (Bridge -> your account -> mailbox details).
- **Are credentials protected?** Without SSL, the server logs in only after STARTTLS. A program on Bridge's port that doesn't offer it (local mail catchers such as Mailpit and MailHog default to 1025) is refused rather than given the password.
**Certificate errors.** Bridge serves a self-signed certificate issued for `127.0.0.1`. The server verifies it: for a loopback host it trusts the operating system's certificate store, where Bridge installs its certificate on macOS. If the certificate is still rejected (on Linux, say), export it from Bridge (Settings → Advanced → Export TLS certificates) and set `NODE_EXTRA_CA_CERTS` to the exported certificate file in the server's `env`. Use `127.0.0.1` as the host, not `localhost`, since that is the name the certificate is issued for. Don't set `NODE_TLS_REJECT_UNAUTHORIZED=0`: it turns off certificate checking for every connection the process makes. Earlier versions needed it for IMAP over STARTTLS; this one doesn't, and warns at startup and in `check_connection` while it is set.
The probes only read each server's greeting. Credentials go only to the configured endpoint, and scan results are suggestions, never applied automatically. `--print-config` replaces a literal password with a placeholder and prints the config in three shapes: a single server object (for clients with a "paste config" box), a full `mcpServers` file, and `KEY=VALUE` lines. The JSON is generated, so it never contains the curly quotes that copying from a rendered page can introduce.
The same checks are available inside a client as the [`check_connection`](#check_connection) tool, and connection errors from every other tool say which endpoint failed and how to fix it.
## Proton Mail Bridge quirks
A few observable behaviors of Proton Mail Bridge that affect tool output. Documented here so agents and humans don't mis-diagnose them as tool bugs.
- **All Mail is eventually consistent.** Moving a message into Trash strips it from All Mail, but the All Mail listing may transiently still show the moved message for a short window (seconds to a minute). If you need authoritative state immediately after a move, query the destination folder directly.
- **Messages moved into Trash may carry the `\Recent` flag.** Bridge re-flags the moved copy as `\Recent` (the server-managed "new arrival" indicator from RFC 3501), which can cause downstream tools that treat `\Recent` as "unread" to display Trash items as unread. `\Seen` state is independent and unchanged by the move.
- **SEARCH lags FETCH for content predicates.** `search_messages` with `subject` / `body` filters may take 30–60 seconds to surface a freshly-sent message because Bridge's content index updates asynchronously. The tool response surfaces a footer on zero-result subject/body queries pointing at `list_messages` or Message-ID lookup. SEARCH on `from` / `to` / date is typically immediate.
- **`top_senders` over All Mail includes Sent.** Because All Mail spans Sent, scans there will count your own outgoing addresses unless you keep the default `excludeSelf: true`. Each row carries a `direction` tag (`self`/`received`) so the table is honest about which side of the conversation each sender represents.
- **Proton's label model cascades moves between folders.** When you move a message from INBOX to Trash, Proton also strips the `All Mail` label as a side-effect (All Mail excludes Trash). A subsequent `bulk_*` op against All Mail with the original UIDs will correctly report them as not-present-at-execute-time — the response wording calls this out explicitly so it's not mistaken for a tool failure.
## Development
```bash
npm run build # Compile TypeScript
npm run watch # Compile in watch mode
npm run test # Run tests
npm run test:watch # Run tests in watch mode
npm run lint # Lint with ESLint
npm run format # Format with Prettier
npm run inspector # Launch MCP inspector
npm run mcpb:validate # Validate manifest.json against the MCP Bundle schema
npm run mcpb:pack # Build dist/proton-mail-mcp-<version>.mcpb (run after build)
```
## Acknowledgments
Originally based on [protonmail-mcp](https://github.com/amotivv/protonmail-mcp) by [amotivv, inc.](https://amotivv.com)
## License
MIT -- see [LICENSE](LICENSE) for details.
TDQS
Scored across 33 tools
Most tools target distinct resources and actions, and the single/bulk/thread families are explicitly differentiated by scope (UID, match criteria, or thread Message-ID). The only deliberate overlap is reply_all_email versus reply_email with replyAll:true, which the description acknowledges, so an agent can still choose correctly.
Tool names are consistently snake_case and mostly follow a verb_noun pattern such as list_messages, move_thread, and update_message_labels. Minor deviations like folder_stats and top_senders are noun-first, but the overall convention is readable and predictable.
At 33 tools the surface is heavy for a mail server, with many near-parallel variants (message/bulk/thread moves, deletes, flags, and labels, plus separate reply/reply_all tools). While mail is a complex domain, several tools could be consolidated without losing capability.
The tool set covers connection diagnostics, folder and label lifecycle, message listing/reading/searching, move/delete/flag/label operations, attachments, drafts, sending/reply/forward, thread-level operations, and aggregate stats. Core workflows and lifecycle operations have no obvious dead ends.