@miguelarios/email-mcp 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.0 (2026-09-18)
4
+
5
+ - New `rename_folder` tool. An IMAP mailbox could be created but never renamed, so reorganising a folder tree meant `create_folder`, then `move_email` for every message, then `delete_email` — three tools and a per-message round trip for something IMAP expresses as a single `RENAME`, which also carries child folders along with the parent (PR #110, `claude/email-mcp-issues-ii6e3m-rename-folder`).
6
+ - `rename_folder` reports both paths as the server returned them rather than as requested. A server may normalise the hierarchy delimiter or prefix the personal namespace — `Work` can come back as `INBOX.Work` — and the `RENAME` response is the authority on where the folder ended up, so a caller does not have to assume its request survived intact (PR #110, `claude/email-mcp-issues-ii6e3m-rename-folder`).
7
+ - Renaming a folder now drops the special-use cache. `getSpecialUseFolder` caches flag → path for the process lifetime, and a rename can move the very Sent, Drafts or Trash mailbox it cached, which would then cost a failed append on the next `send_email`. Every entry is dropped rather than the one guessed to be affected: re-resolving costs one `LIST` (PR #110, `claude/email-mcp-issues-ii6e3m-rename-folder`).
8
+ - A blank `path`, a blank `newPath`, or a `newPath` equal to `path` is rejected with `INVALID_INPUT` before the connection is opened. IMAP cannot express any of the three, and the protocol error a server returns for them names neither argument, so the caller would otherwise have to guess which end was wrong (PR #110, `claude/email-mcp-issues-ii6e3m-rename-folder`).
9
+ - New `delete_folder` tool. A folder could be created but never removed, so an account only ever accumulated folders — there was no way to undo a `create_folder` typo, let alone tidy a tree (PR #111, `claude/email-mcp-issues-ii6e3m-delete-folder`).
10
+ - `delete_folder` asks the user to confirm first, and the prompt names the folder's message count as well as its path. This delete is irreversible in a way `delete_email` is not: the messages go with the folder and do **not** land in Trash, so "delete Projects/Work" and "delete Projects/Work and its 412 messages" are different decisions. The count comes from a `STATUS` issued before the gate, and is echoed in the result as `messages` (PR #111, `claude/email-mcp-issues-ii6e3m-delete-folder`).
11
+ - A folder the server will not `STATUS` — a `\Noselect` hierarchy node has no messages to count — is still confirmed and still deleted. The prompt simply drops the count clause, `messages` is absent from the output, and the `DELETE` itself raises the real error if there is one (PR #111, `claude/email-mcp-issues-ii6e3m-delete-folder`).
12
+ - Deleting `INBOX` is rejected with `INVALID_INPUT` before anything is asked or connected, whatever its casing. RFC 3501 §6.3.4 makes it an error and servers answer with a bare `NO`; spending a confirmation on a request that cannot succeed teaches the user that confirming does not mean the thing happened (PR #111, `claude/email-mcp-issues-ii6e3m-delete-folder`).
13
+ - Deleting a folder drops the special-use cache, for the same reason a rename does: the folder just removed may be the Sent, Drafts or Trash mailbox `getSpecialUseFolder` resolved, and a stale entry costs an append to a folder that is gone (PR #111, `claude/email-mcp-issues-ii6e3m-delete-folder`).
14
+ - Whether a folder with sub-folders can be deleted is left to the server. RFC 3501 permits either answer and real servers differ, so a refusal surfaces rather than being pre-empted by a guess about this server's behaviour (PR #111, `claude/email-mcp-issues-ii6e3m-delete-folder`).
15
+ - New `copy_email` tool. IMAP `COPY` had no tool at all, so keeping a message in two places — filing a receipt into a project folder while leaving it in the inbox — meant `move_email` plus a second move back, which changes the message's UID twice and loses it from the source in between (PR #112, `claude/email-mcp-issues-ii6e3m-copy-email`).
16
+ - It is a separate tool rather than a flag on `move_email` because the two differ in more than a verb: the result carries destination UIDs a move has no equivalent for, and `move_email` is annotated `idempotentHint: true` while a second `COPY` genuinely files a second copy (PR #112, `claude/email-mcp-issues-ii6e3m-copy-email`).
17
+ - On a server with UIDPLUS, `copied` pairs each source UID with the UID its copy took in the destination, read from the `COPYUID` response — which is what lets a caller flag or move the copy afterwards without re-searching. Without the extension the mapping is absent rather than guessed: the copy still happened, and the source `uids` still come back (PR #112, `claude/email-mcp-issues-ii6e3m-copy-email`).
18
+ - A copy the server refuses is reported as an error rather than a success. imapflow's copy command catches a server `NO` — `[TRYCREATE]` for a destination that does not exist is the likely one — logs a warning and resolves `false`, which without this would have been indistinguishable from a successful copy on a server that simply has no UIDPLUS data to report (PR #112, `claude/email-mcp-issues-ii6e3m-copy-email`).
19
+ - A `destination` equal to the source `folder` is rejected with `INVALID_INPUT` before connecting. It is legal IMAP and duplicates every message in place, which is never what a caller reaching for "copy to a folder" means (PR #112, `claude/email-mcp-issues-ii6e3m-copy-email`).
20
+ - New `get_thread` tool: give it any message in a conversation — the root or any reply — and it returns the whole thread, oldest first. Reading a conversation previously meant `get_email` for the `References` chain and then `search_emails` guesses against the subject line, which catches unrelated mail with the same subject and misses replies that changed it (PR #116, `claude/email-mcp-issues-ii6e3m-get-thread`).
21
+ - Two mechanisms, in order of preference. A server advertising `OBJECTID` or `X-GM-EXT-1` assigns every message a thread id and answers a search on it with the whole conversation — authoritative, and it catches replies whose `References` chain was mangled in transit. Otherwise the chain is walked: RFC 5322 §3.6.4 has every reply carry the root's `Message-ID` in its `References`, so one search for messages that either *are* the root or *cite* it returns the thread. RFC 5256's `THREAD` command would be a third option, but imapflow exposes no way to issue it (PR #116, `claude/email-mcp-issues-ii6e3m-get-thread`).
22
+ - `In-Reply-To` is read and searched alongside `References`. Plenty of mailers send a reply carrying only that header, so without it such a reply was missing from the thread entirely, and anchoring `get_thread` on one made it its own root and lost every ancestor. `References` still wins where both are present, since its first entry is the true root (PR #116, `claude/email-mcp-issues-ii6e3m-get-thread`).
23
+ - Only the mailbox select is forgiving when walking the folder list. A failure in the search or the fetch now propagates instead of being swallowed into a `count: 0` that reads like a conversation with no messages in it (PR #116, `claude/email-mcp-issues-ii6e3m-get-thread`).
24
+ - The `References` header is unfolded before parsing. RFC 5322 §2.2.3 lets a long chain run across continuation lines, and a chain split mid-header would otherwise lose every id after the first line — which on a long thread is most of it (PR #116, `claude/email-mcp-issues-ii6e3m-get-thread`).
25
+ - The Sent folder is searched alongside the anchor's folder by default, because a conversation with your own replies missing from it is not the conversation. `folders` overrides that; a folder that cannot be opened is skipped rather than failing the call, since a partial thread is more use than none. The same message filed in two folders is de-duplicated by `Message-ID`, and each row is tagged with the `folder` it was found in so a follow-up `get_email` knows where to look (PR #116, `claude/email-mcp-issues-ii6e3m-get-thread`).
26
+ - Summaries, not bodies: a long thread returned in full would be most of a context window, and `get_email` already fetches any one message (PR #116, `claude/email-mcp-issues-ii6e3m-get-thread`).
27
+ - `search_emails` now uses the server's own `SORT` command (RFC 5256) where the server advertises it, instead of sorting every result set here. Up to 1000 results that meant fetching *every* envelope in the set to return a page of 50; past 1000 it reversed the UID list instead, so any non-date sort was ordered within the page only — page 2 of a subject sort on a large folder was not the second page of anything. With `SORT` the whole result set is ordered server-side, the page is exact at any size, and only that page's envelopes cross the wire (PR #117, `claude/email-mcp-issues-ii6e3m-imap-sort`).
28
+ - The previous client-side path remains as the fallback, so nothing regresses on a server without `SORT` — including its >1000 approximation, which is now documented as a property of that path rather than of `search_emails`. The fallback also catches a server that advertises `SORT` but rejects the command: an older server accepting only `US-ASCII` answers `BADCHARSET`, and a search never fails over it (PR #117, `claude/email-mcp-issues-ii6e3m-imap-sort`).
29
+ - **Behaviour note:** server-side ordering is not byte-identical to the fallback, because RFC 5256 defines the keys differently. `SUBJECT` sorts on the *base* subject with `Re:`/`Fwd:` prefixes stripped, and `FROM` sorts on the sender's mailbox address, where the fallback prefers the display name (PR #117, `claude/email-mcp-issues-ii6e3m-imap-sort`).
30
+ - A non-ASCII filter now reaches `SORT` instead of silently falling back. imapflow's search compiler prepends a `CHARSET UTF-8` pair to the search key whenever a value carries non-ASCII, which is how RFC 3501 SEARCH takes a charset — but RFC 5256 SORT gives the charset its own slot, so the pair would have produced `UID SORT (REVERSE DATE) UTF-8 CHARSET UTF-8 SUBJECT "café"`, a syntax error the server answers BAD. The pair is lifted out and its value used for the slot (PR #117, `claude/email-mcp-issues-ii6e3m-imap-sort`).
31
+ - `FETCH` streams in sequence order rather than in the order of the UID set it is given, so the server's ordering is reapplied to the page after fetching. Missing that would have produced a correctly sorted UID list rendered in the wrong order — silently, and only on servers with `SORT` (PR #117, `claude/email-mcp-issues-ii6e3m-imap-sort`).
32
+ - imapflow has no `SORT` command, so the new internal `imapSort` module drives its `exec` and search compiler directly. Both are imapflow internals, which is why every entry point fails soft: no capability, a rejected command, or a client version that moved the compiler all return `null` and leave the caller on the client-side path (PR #117, `claude/email-mcp-issues-ii6e3m-imap-sort`).
33
+ - New `URL_RESOLVE_PROXY` environment variable routes link resolution through an HTTP proxy. Rendering an email to markdown resolves the links in it, which means a GET to every distinct URL the message contains; those hosts see the request come from whatever machine the server runs on — a home connection, typically — and marketing links are often instrumented precisely to record that. The links come from senders the user did not choose. Takes an `http://` or `https://` URL, credentials included if the proxy needs them. IMAP and SMTP connections are unaffected (PR #118, `claude/email-mcp-issues-ii6e3m-url-proxy`).
34
+ - A proxy that cannot be used **disables resolution rather than falling back to a direct fetch**. An unparseable value, or a scheme other than `http`/`https`, logs the reason to stderr and leaves links unresolved. Resolving directly at that point would disclose exactly the address the setting exists to protect, so it fails closed — a typo is not silently indistinguishable from a working proxy (PR #118, `claude/email-mcp-issues-ii6e3m-url-proxy`).
35
+ - The proxy agent is built once and reused, keyed on the environment value so a changed setting rebuilds rather than sticking, and closed on shutdown alongside the URL cleaner. Where no proxy is configured the `dispatcher` key is omitted from the fetch entirely, so an unproxied request is byte-for-byte what it was before (PR #118, `claude/email-mcp-issues-ii6e3m-url-proxy`).
36
+ - `URL_RESOLVE_DISABLE` still wins over a configured proxy, and the SSRF guard is unchanged and independent: private-range, loopback and reserved-suffix targets are never fetched, proxy or not (PR #118, `claude/email-mcp-issues-ii6e3m-url-proxy`).
37
+ - Adds `undici` as a runtime dependency. Node's global `fetch` is undici, but it exposes no way to construct a `ProxyAgent` and there is no proxy option in the standard fetch init, so the class has to come from the package. Ambient `HTTPS_PROXY`-style variables are deliberately not read: capturing this traffic should be a decision the operator made (PR #118, `claude/email-mcp-issues-ii6e3m-url-proxy`).
38
+ - Declares `engines.node` as `>=20.18.1`, which is what the new `undici` dependency requires. Only this package gains the field — #24 tracks doing it across the monorepo (PR #118, `claude/email-mcp-issues-ii6e3m-url-proxy`).
39
+ - `package-lock.json` now carries this package's real version, which the 0.14.0 release bumped in `package.json` but not in the lockfile (PR #118, `claude/email-mcp-issues-ii6e3m-url-proxy`).
40
+ - `send_email` gained `replyAll`. Replying to everyone previously meant reading the original, copying `From`, `To` and `Cc` out by hand, remembering to strip your own address, and passing the result back — every step a chance to drop someone from the thread. With `replyAll: true` and a `replyToUid`, `to` becomes the original's `Reply-To` (or its `From`) plus everyone on its `To`, and `cc` becomes its `Cc` (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
41
+ - `Reply-To` *replaces* `From` rather than joining it. RFC 5322 §3.6.2 makes that header the author's statement of where replies belong, which is what lands a mailing-list reply on the list rather than on both the list and the individual who posted (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
42
+ - Every address the account owns — `IMAP_USER`, `SMTP_USER` and anything in `SMTP_ALLOWED_FROM` — is dropped, so the reply is not addressed back to the sender. The two users are usually the same but nothing requires it, and an allow-listed alias is just as much "us" for this purpose. De-duplication falls out of the same pass, keeping an address at the strongest position it held since `To` outranks `Cc` (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
43
+ - The original's `Bcc` is carried over when there is one. A received message never names its blind recipients, so there is normally nothing to carry; a message read back out of `Sent` or `Drafts` does carry them, and dropping them there would quietly narrow a thread the account itself started. They remain blind (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
44
+ - `get_email` output gained `replyTo` and `bcc`, both optional and omitted rather than empty when the message carries no such header. `fetchEmail` parsed them and then discarded them (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
45
+ - The send confirmation now names the derived recipients. That required fetching the original *before* the confirmation gate rather than after it, at the cost of one extra `FETCH` per confirmation round trip — which is the price of a confirmation that says who the mail is going to rather than one the user answers blind (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
46
+ - `to` is no longer listed in `send_email`'s `required` input fields, since `replyAll` supplies it and JSON Schema cannot express "required unless another field is set". The handler still rejects a call with neither, and rejects `replyAll` without `replyToUid`. An explicit `to`, `cc` or `bcc` overrides the corresponding derived list field by field — "reply to everyone, but send it to Ada" is a real request (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
47
+ - The nobody-but-us refusal is evaluated on the effective recipients, after an explicit `to`/`cc`/`bcc` has overridden the derived ones — not on the derived lists before them. A caller who supplied `to` has named someone, and the derivation finding only this account is then nothing to refuse over (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
48
+ - When every derived recipient turns out to be the account itself the call fails rather than sending a reply to nobody; when only `To` empties out, the derived `Cc` is promoted rather than emitting a message with an empty `To` header (PR #113, `claude/email-mcp-issues-ii6e3m-reply-all`).
49
+ - **Behaviour change:** a reply sent with `send_email` (`replyToUid` set) now carries the quoted original below the new body, the way a mail client writes it. Replies previously went out bare, so a recipient saw "Sounds good" with no indication of what was good, and a thread assembled from these replies read as a series of disconnected fragments — clients thread on headers, but they still *show* the quote, because that is what makes a reply legible on a phone or in a digest. Pass `quoteOriginal: false` for the previous behaviour (PR #114, `claude/email-mcp-issues-ii6e3m-quote-reply`).
50
+ - The attribution line is `On <date>, <Name> <address> wrote:`, falling back to the bare address when the sender has no display name, and dropping the date clause rather than emitting `On ,` when the original has no `Date` header (PR #114, `claude/email-mcp-issues-ii6e3m-quote-reply`).
51
+ - The quote follows whichever body the reply uses: `text` gets a `>`-prefixed original, `html` gets a `<blockquote type="cite">`, and a reply carrying both gets both so its two parts do not disagree about what was said. A reply with *neither* body gets the text quote alone, since there is nothing else for it to carry (PR #114, `claude/email-mcp-issues-ii6e3m-quote-reply`).
52
+ - Quote prefixing follows RFC 3676 §4.5: an already-quoted line gains a level (`> x` becomes `>> x`) rather than an indent, so nesting depth survives each pass through a thread instead of drifting rightwards. A blank line becomes a bare `>` rather than `"> "`, so the quote carries no trailing whitespace (PR #114, `claude/email-mcp-issues-ii6e3m-quote-reply`).
53
+ - The original's HTML is sanitised before it goes into the quote, through the same allowlist `get_email`'s markdown rendering already used. Quoting it verbatim would have re-sent the sender's `<script>`, `<style>`, tracking pixels and document wrapper under the replier's own From, to every recipient of the reply — the text path escapes for exactly this reason, and the HTML path now matches it. An original whose markup sanitises away to nothing falls back to its text body (PR #114, `claude/email-mcp-issues-ii6e3m-quote-reply`).
54
+ - Where the original lacks the part being quoted it is converted — HTML to markdown for a text quote, plain text HTML-escaped into a `<pre>` for an HTML one. The escaping is not cosmetic: the original is untrusted content being placed into a document we compose (PR #114, `claude/email-mcp-issues-ii6e3m-quote-reply`).
55
+ - Quoting can never fail a send. A conversion error yields no quote for that part, an original with no body yields none at all, and the whole step is guarded so that anything unforeseen leaves the reply the caller wrote intact (PR #114, `claude/email-mcp-issues-ii6e3m-quote-reply`).
56
+ - New `forward_email` tool. Passing a message on previously meant reconstructing it: `get_email` for the body, `download_attachment` for each file, then `send_email` with the bytes re-encoded as base64 attachments and the headers retyped by hand into the body. Every attachment made a round trip through the model's context, and the forwarded-from block was whatever the caller remembered to write (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
57
+ - The body is reproduced under the conventional `---------- Forwarded message ----------` block naming the original's From, Date, Subject, To and Cc. Lines the original does not have are omitted rather than left blank — a message with no `Cc` should not claim an empty one. An optional `note` goes above the block (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
58
+ - A multi-line `note` keeps its line breaks in the HTML part. It was escaped into a single `<p>` with no `<br>`, so an HTML-capable client showed a covering note as one run-on paragraph while the text part kept its shape — the two parts are emitted precisely so they say the same thing (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
59
+ - The text part is always built, since every message can carry one, so an HTML-only original is rendered to markdown for it. An HTML part is emitted only when the original had HTML: inventing markup for a plain-text original gains the recipient nothing (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
60
+ - Attachments are re-attached by part ID, straight from IMAP to SMTP. They never enter a tool result, so `EMAIL_MAX_INLINE_BYTES` — which exists to keep payloads out of the model's context — deliberately does not apply; `includeAttachments: false` is the control for a message with large attachments (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
61
+ - A forward starts a new thread: no `In-Reply-To`, no `References`. Threading it under the original would file it into a conversation the new recipients were never part of (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
62
+ - Sending asks the user to confirm first, and `saveToDrafts` bypasses that gate so a forward can be reviewed in a mail client before it goes. The original is fetched before the gate, so the prompt names its subject and a nonexistent UID fails as a lookup error rather than after the user has agreed to send (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
63
+ - The subject defaults to `Fwd: <original subject>`, and is not prefixed again when the original is already a forward (PR #115, `claude/email-mcp-issues-ii6e3m-forward`).
64
+
3
65
  ## 0.14.0 (2026-09-16)
4
66
 
5
67
  - `get_email` and `search_emails` now report attachments that carry `Content-Disposition: inline` with a filename. Apple Mail (iOS and macOS) writes forwarded file attachments that way, so a forwarded message with a real PDF attached previously reported `hasAttachments: false` and an empty `attachments` array — the part was in the MIME source the whole time, and `download_attachment` retrieved it correctly when given the `partId` by hand. Content-ID distinguishes the two inline cases: an image the HTML body references carries one, a forwarded file does not, so embedded signature logos are still not listed as attachments (PR #107, `claude/exciting-wozniak-55ly2k`).
package/README.md CHANGED
@@ -7,7 +7,9 @@ MCP server for email via IMAP/SMTP — search, read, send, and manage emails and
7
7
  Speaks MCP revision **2026-07-28** over stdio, and still serves 2025-era clients from the same tool definitions.
8
8
  Every tool declares a `title`, all four behaviour annotations, and an `outputSchema`, and returns validated `structuredContent`.
9
9
 
10
- `send_email` (when sending, not when saving a draft), `send_draft`, and `delete_email` with `permanent: true` ask the user to confirm first. Set `PIM_MCP_CONFIRM=off` to skip confirmation in headless use.
10
+ `send_email` and `forward_email` (when sending, not when saving a draft), `send_draft`, `delete_email` with `permanent: true`, and `delete_folder` ask the user to confirm first. Set `PIM_MCP_CONFIRM=off` to skip confirmation in headless use.
11
+
12
+ Requires Node.js **20.18.1 or newer**.
11
13
 
12
14
  ## Usage
13
15
 
@@ -48,6 +50,10 @@ Optional env vars: `IMAP_PORT` (default 993), `IMAP_SECURE` (default true), `SMT
48
50
  deliberately.
49
51
  - `EMAIL_ATTACHMENT_DIR` — directory that gates `send_email` file attachments. Path-based attachments (`attachments[].path`) are rejected unless this is set, and only files resolving inside it are allowed. Use `attachments[].content` for inline content without setting this.
50
52
  - `URL_RESOLVE_DISABLE` — set to `1`/`true` to skip network link-resolution when rendering email to markdown; links are left unresolved in the output.
53
+ - `URL_RESOLVE_PROXY` — route link resolution through an HTTP proxy, so the machine running
54
+ the server does not hand its IP address to every host an email links to. Takes an
55
+ `http://` or `https://` URL, with credentials if the proxy needs them
56
+ (`http://user:pass@proxy.internal:3128`). See [Link resolution and your IP address](#link-resolution-and-your-ip-address).
51
57
  - `SMTP_AUTO_SENT` — set to `true` if your provider auto-files sent mail, so the server skips the extra IMAP append to Sent.
52
58
  - `SMTP_ALLOWED_FROM` — comma-separated allowlist of additional visible `From` addresses that `send_email` may use via its `from` parameter. Any address not in this list (and not `SMTP_USER`) is rejected. Read [Deliverability](#deliverability-spf-dkim-and-dmarc) before setting it.
53
59
 
@@ -72,25 +78,70 @@ server trust you.
72
78
  `SMTP_FROM_NAME` and the per-call `fromName` change only the display name, never the address, so they carry no
73
79
  deliverability risk. Prefer them when you just want a distinct agent identity on a shared mailbox.
74
80
 
75
- ## Tools (12)
81
+ ## Tools (17)
76
82
 
77
83
  See [docs/tools/email-mcp.md](../../docs/tools/email-mcp.md) for full parameter and output details.
78
84
 
79
85
  | Tool | Description |
80
86
  |------|-------------|
81
- | `search_emails` | Search and filter emails by folder, sender, subject, date, flags |
87
+ | `search_emails` | Search and filter emails by folder, sender, subject, date, flags — server-side `SORT` where available |
82
88
  | `get_email` | Fetch full email by UID — headers, body, attachment metadata, calendar invitation parts |
83
- | `send_email` | Compose and send via SMTP, reply with threading, save as draft, or use an allowed visible From address |
89
+ | `get_thread` | Fetch the whole conversation a message belongs to, oldest first |
90
+ | `send_email` | Compose and send via SMTP, reply or reply-all with threading, save as draft, or use an allowed visible From address |
84
91
  | `send_draft` | Send an existing draft from the Drafts folder |
92
+ | `forward_email` | Forward a message with its attachments and an optional note |
85
93
  | `move_email` | Move emails between folders |
94
+ | `copy_email` | Copy emails into another folder, leaving the originals in place |
86
95
  | `mark_email` | Set/unset flags (read, unread, flagged) |
87
96
  | `delete_email` | Move to trash or permanently delete |
88
97
  | `list_folders` | List all IMAP folders with special-use flags |
89
98
  | `create_folder` | Create an IMAP folder |
99
+ | `rename_folder` | Rename an IMAP folder, or move it under a different parent |
100
+ | `delete_folder` | Delete an IMAP folder and everything in it (asks to confirm) |
90
101
  | `download_attachment` | Download attachment by email UID and part ID |
91
102
  | `get_email_raw` | Export email as raw .eml |
92
103
  | `get_folder_status` | Get total and unread message counts for a folder |
93
104
 
105
+ ## Sorting
106
+
107
+ `search_emails` uses the server's own `SORT` command (RFC 5256) when the server advertises
108
+ the capability. The whole result set is ordered server-side, only the requested page's
109
+ envelopes come across the wire, and pagination is exact however large the folder is.
110
+
111
+ A filter carrying non-ASCII is issued under the charset imapflow's compiler asks for, lifted into the slot RFC 5256 gives it rather than left in the search key where it would be a syntax error.
112
+
113
+ Without `SORT`, the previous behaviour stands: the result set is fetched and sorted here,
114
+ and beyond 1000 messages a non-date sort is approximate — ordered within the page only.
115
+ The same fallback catches a server that advertises `SORT` but rejects the command (an
116
+ older server that only accepts `US-ASCII`, say, answers `BADCHARSET`), so a search never
117
+ fails over it.
118
+
119
+ Server-side ordering is not byte-identical to the fallback, because RFC 5256 defines the
120
+ keys differently: `SUBJECT` sorts on the *base* subject with `Re:`/`Fwd:` stripped, and
121
+ `FROM` sorts on the sender's mailbox address where the fallback prefers the display name.
122
+
123
+ ## Link resolution and your IP address
124
+
125
+ Rendering an email to markdown resolves the links in it, which means a GET to every distinct
126
+ URL the message contains. Those hosts see the request come from whatever machine the server
127
+ runs on — a home connection, typically — and marketing links are often instrumented precisely
128
+ to record that. The links come from senders you did not choose.
129
+
130
+ Set `URL_RESOLVE_PROXY` to an `http://` or `https://` proxy URL and every resolution fetch
131
+ goes through it instead. Credentials are supported in the URL. Nothing else about the
132
+ server's traffic is proxied: IMAP and SMTP connections are unaffected.
133
+
134
+ **A proxy that cannot be used disables resolution rather than falling back to a direct
135
+ fetch.** If the value is unparseable or has a scheme other than `http`/`https`, the server
136
+ logs the reason to stderr and leaves links unresolved. Resolving directly at that point would
137
+ disclose exactly the address the setting exists to protect, so it fails closed.
138
+
139
+ Unset the variable to resolve directly (the default), or `URL_RESOLVE_DISABLE=1` to skip
140
+ resolution entirely — that still wins over a configured proxy.
141
+
142
+ The SSRF guard is unchanged and independent: private-range, loopback and reserved-suffix
143
+ targets are never fetched, proxy or not.
144
+
94
145
  ## Resources
95
146
 
96
147
  Attachments and message sources are addressable as `imap://` resources, not just
@@ -118,6 +169,49 @@ Neither template is enumerable — there is no `resources/list` entry for them,
118
169
  listing every attachment in an account would mean walking every message. Discover
119
170
  them through `resources/templates/list`, and find part IDs with `get_email`.
120
171
 
172
+ ## Replying to everyone
173
+
174
+ `send_email` with `replyAll: true` (and a `replyToUid`) works out the recipients from the
175
+ message being replied to, so `to` becomes optional:
176
+
177
+ | Field | Derived from |
178
+ |-------|--------------|
179
+ | `to` | The original's `Reply-To` if it has one, otherwise its `From` — plus everyone on its `To`. |
180
+ | `cc` | The original's `Cc`. |
181
+ | `bcc` | The original's `Bcc`, when it has one. |
182
+
183
+ `Reply-To` replaces `From` rather than joining it, per RFC 5322 §3.6.2 — which is what makes
184
+ replying to a mailing list land on the list.
185
+
186
+ Every address this account owns (`IMAP_USER`, `SMTP_USER`, and anything in `SMTP_ALLOWED_FROM`)
187
+ is dropped, so the reply is not addressed back to the sender, and an address in more than one
188
+ header is kept once at its strongest position. An explicit `to`, `cc` or `bcc` overrides the
189
+ corresponding derived list, field by field.
190
+
191
+ A received message carries no `Bcc` header, so there is usually nothing to carry over. One read
192
+ back out of `Sent` or `Drafts` does, and those recipients ride along — still blind, as `Bcc`
193
+ always is — so replying-all to your own sent mail does not silently narrow the thread.
194
+
195
+ The original is fetched before the send confirmation, so the prompt names the derived recipients:
196
+ the caller sees who the mail is going to before agreeing to send it.
197
+
198
+ ## Quoting on replies
199
+
200
+ A reply (`send_email` with `replyToUid`) carries the quoted original below the new body,
201
+ the way a mail client writes it: an `On <date>, <Name> <address> wrote:` attribution line,
202
+ then the original as `>`-prefixed text, as an HTML `<blockquote>`, or both — matching
203
+ whichever of `text`/`html` the reply itself uses. Pass `quoteOriginal: false` for a bare reply.
204
+
205
+ The original's HTML is sanitised before it is quoted, through the same allowlist used when
206
+ rendering a message to markdown — quoting it verbatim would re-send a sender's script, style
207
+ and tracking pixels under your own From to everyone on the reply.
208
+
209
+ Prefixing follows RFC 3676 §4.5, so an already-quoted line gains a level (`> x` → `>> x`)
210
+ rather than an indent and nesting depth survives a long thread. Where the original lacks the
211
+ part being quoted, it is converted — HTML to markdown for a text quote, plain text escaped
212
+ into the HTML one. If the original has no body, or the conversion fails, the reply goes out
213
+ unquoted rather than not at all.
214
+
121
215
  ## Sending attachments
122
216
 
123
217
  `send_email` takes attachments three ways:
@@ -1,5 +1,13 @@
1
+ /** Closes the proxy agent, if one was built. Part of shutdown. */
2
+ export declare function disposeUrlProxy(): Promise<void>;
1
3
  export declare function disposeUrlCleaner(): Promise<void>;
2
4
  export declare function cleanUrl(urlStr: string): Promise<string>;
5
+ /**
6
+ * Strips inbound email HTML down to {@link SANITIZE_OPTIONS}: script and style
7
+ * contents go entirely, the document wrapper and any unlisted tag go, tracking
8
+ * pixels and hidden elements go.
9
+ */
10
+ export declare function sanitizeEmailHtml(html: string): string;
3
11
  export declare function htmlToMarkdown(html: string): Promise<string>;
4
12
  /**
5
13
  * Guard against SSRF via email-embedded links. Checks the *initial* URL only —
@@ -1 +1 @@
1
- {"version":3,"file":"htmlToMarkdown.d.ts","sourceRoot":"","sources":["../src/htmlToMarkdown.ts"],"names":[],"mappings":"AAkBA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKvD;AAkBD,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS9D;AAmBD,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqHlE;AAyBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAuCjD"}
1
+ {"version":3,"file":"htmlToMarkdown.d.ts","sourceRoot":"","sources":["../src/htmlToMarkdown.ts"],"names":[],"mappings":"AAqEA,kEAAkE;AAClE,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAKrD;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKvD;AAkBD,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS9D;AAgFD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmElE;AAyBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAuCjD"}
@@ -2,6 +2,7 @@ import { appendFileSync } from "node:fs";
2
2
  import URLCleaner from "@backrunner/url-cleaner";
3
3
  import sanitize from "sanitize-html";
4
4
  import TurndownService from "turndown";
5
+ import { ProxyAgent } from "undici";
5
6
  // Supplemental tracking params not covered by uBlock/AdGuard lists
6
7
  const SUPPLEMENTAL_TRACKING_PARAMS = ["_ke", "sc_cid", "campaign_id"];
7
8
  // Lazy-init singleton — constructed on first use, reused thereafter
@@ -12,6 +13,48 @@ function getCleaner() {
12
13
  }
13
14
  return cleanerInstance;
14
15
  }
16
+ /** Keyed on the env value, so a changed setting rebuilds rather than sticking. */
17
+ let routeCache;
18
+ function proxyRoute() {
19
+ const key = process.env.URL_RESOLVE_PROXY?.trim() ?? "";
20
+ if (routeCache?.key === key)
21
+ return routeCache.route;
22
+ // The old agent is no longer reachable; close it rather than leak its
23
+ // sockets. Nothing awaits this — it is a teardown, not a step.
24
+ if (routeCache?.route.kind === "proxied") {
25
+ void routeCache.route.dispatcher.close().catch(() => { });
26
+ }
27
+ let route;
28
+ if (key === "") {
29
+ route = { kind: "direct" };
30
+ }
31
+ else {
32
+ try {
33
+ const url = new URL(key);
34
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
35
+ route = { kind: "broken", reason: `unsupported proxy scheme "${url.protocol}"` };
36
+ }
37
+ else {
38
+ route = { kind: "proxied", dispatcher: new ProxyAgent(key) };
39
+ }
40
+ }
41
+ catch (err) {
42
+ route = {
43
+ kind: "broken",
44
+ reason: err instanceof Error ? err.message : String(err),
45
+ };
46
+ }
47
+ }
48
+ routeCache = { key, route };
49
+ return route;
50
+ }
51
+ /** Closes the proxy agent, if one was built. Part of shutdown. */
52
+ export async function disposeUrlProxy() {
53
+ if (routeCache?.route.kind === "proxied") {
54
+ await routeCache.route.dispatcher.close().catch(() => { });
55
+ }
56
+ routeCache = undefined;
57
+ }
15
58
  export async function disposeUrlCleaner() {
16
59
  if (cleanerInstance) {
17
60
  await cleanerInstance.dispose();
@@ -59,62 +102,80 @@ function isHiddenElement(style) {
59
102
  s.includes("opacity:0") ||
60
103
  s.includes("opacity: 0"));
61
104
  }
105
+ /**
106
+ * The one policy for inbound email HTML: what may survive from a message we
107
+ * did not write.
108
+ *
109
+ * Used both when rendering to markdown and when quoting an original into an
110
+ * outgoing reply. The second is why this is shared rather than inlined —
111
+ * quoting unsanitised HTML would re-send a sender's script, style and tracking
112
+ * pixels under our own From, to every recipient of the reply.
113
+ */
114
+ const SANITIZE_OPTIONS = {
115
+ allowedTags: [
116
+ "p",
117
+ "br",
118
+ "b",
119
+ "i",
120
+ "em",
121
+ "strong",
122
+ "a",
123
+ "ul",
124
+ "ol",
125
+ "li",
126
+ "h1",
127
+ "h2",
128
+ "h3",
129
+ "h4",
130
+ "h5",
131
+ "h6",
132
+ "table",
133
+ "tr",
134
+ "td",
135
+ "th",
136
+ "thead",
137
+ "tbody",
138
+ "blockquote",
139
+ "pre",
140
+ "code",
141
+ "hr",
142
+ "span",
143
+ "div",
144
+ "img",
145
+ ],
146
+ allowedAttributes: {
147
+ a: ["href"],
148
+ img: ["src", "alt", "width", "height", "style"],
149
+ },
150
+ exclusiveFilter: (frame) => {
151
+ // Remove tracking pixels
152
+ if (frame.tag === "img") {
153
+ const w = Number.parseInt(frame.attribs.width || "", 10);
154
+ const h = Number.parseInt(frame.attribs.height || "", 10);
155
+ if ((w >= 0 && w <= 1) || (h >= 0 && h <= 1))
156
+ return true;
157
+ const style = frame.attribs.style || "";
158
+ if (isHiddenElement(style))
159
+ return true;
160
+ }
161
+ // Remove hidden elements
162
+ const style = frame.attribs?.style || "";
163
+ if (style && isHiddenElement(style))
164
+ return true;
165
+ return false;
166
+ },
167
+ };
168
+ /**
169
+ * Strips inbound email HTML down to {@link SANITIZE_OPTIONS}: script and style
170
+ * contents go entirely, the document wrapper and any unlisted tag go, tracking
171
+ * pixels and hidden elements go.
172
+ */
173
+ export function sanitizeEmailHtml(html) {
174
+ return sanitize(html, SANITIZE_OPTIONS);
175
+ }
62
176
  export async function htmlToMarkdown(html) {
63
177
  // Step 1: Sanitize
64
- const clean = sanitize(html, {
65
- allowedTags: [
66
- "p",
67
- "br",
68
- "b",
69
- "i",
70
- "em",
71
- "strong",
72
- "a",
73
- "ul",
74
- "ol",
75
- "li",
76
- "h1",
77
- "h2",
78
- "h3",
79
- "h4",
80
- "h5",
81
- "h6",
82
- "table",
83
- "tr",
84
- "td",
85
- "th",
86
- "thead",
87
- "tbody",
88
- "blockquote",
89
- "pre",
90
- "code",
91
- "hr",
92
- "span",
93
- "div",
94
- "img",
95
- ],
96
- allowedAttributes: {
97
- a: ["href"],
98
- img: ["src", "alt", "width", "height", "style"],
99
- },
100
- exclusiveFilter: (frame) => {
101
- // Remove tracking pixels
102
- if (frame.tag === "img") {
103
- const w = Number.parseInt(frame.attribs.width || "", 10);
104
- const h = Number.parseInt(frame.attribs.height || "", 10);
105
- if ((w >= 0 && w <= 1) || (h >= 0 && h <= 1))
106
- return true;
107
- const style = frame.attribs.style || "";
108
- if (isHiddenElement(style))
109
- return true;
110
- }
111
- // Remove hidden elements
112
- const style = frame.attribs?.style || "";
113
- if (style && isHiddenElement(style))
114
- return true;
115
- return false;
116
- },
117
- });
178
+ const clean = sanitizeEmailHtml(html);
118
179
  // Step 2: Convert to markdown
119
180
  const td = new TurndownService({
120
181
  headingStyle: "atx",
@@ -247,15 +308,19 @@ export function isBlockedUrl(raw) {
247
308
  }
248
309
  return false;
249
310
  }
250
- async function fetchOne(url, timeoutMs, log) {
311
+ async function fetchOne(url, timeoutMs, log, dispatcher) {
251
312
  const controller = new AbortController();
252
313
  const timer = setTimeout(() => controller.abort(), timeoutMs);
253
314
  const start = Date.now();
254
315
  try {
316
+ // `dispatcher` is undici's, which Node's global fetch accepts. The key is
317
+ // omitted rather than passed as undefined when resolving directly, so the
318
+ // unproxied request is byte-for-byte what it was before.
255
319
  const res = await fetch(url, {
256
320
  method: "GET",
257
321
  redirect: "follow",
258
322
  signal: controller.signal,
323
+ ...(dispatcher ? { dispatcher } : {}),
259
324
  });
260
325
  clearTimeout(timer);
261
326
  controller.abort();
@@ -325,6 +390,15 @@ async function resolveUrls(urls) {
325
390
  // Markdown conversion still proceeds; links stay as their original URLs.
326
391
  return new Map();
327
392
  }
393
+ const route = proxyRoute();
394
+ if (route.kind === "broken") {
395
+ // Fail closed. Resolving direct here would hand this machine's IP to every
396
+ // host an email links to, which is what the proxy was configured to stop.
397
+ const remedy = "Fix the proxy URL, or unset the variable to resolve links directly.";
398
+ console.error(`[email-mcp] URL_RESOLVE_PROXY is set but unusable (${route.reason}); link resolution is disabled. ${remedy}`);
399
+ return new Map();
400
+ }
401
+ const dispatcher = route.kind === "proxied" ? route.dispatcher : undefined;
328
402
  const debug = process.env.DEBUG_URL_RESOLVE === "1";
329
403
  const timeoutMs = debug
330
404
  ? Number.parseInt(process.env.URL_RESOLVE_TIMEOUT || String(DEFAULT_TIMEOUT), 10)
@@ -349,7 +423,7 @@ async function resolveUrls(urls) {
349
423
  for (let attempt = 0; attempt < MAX_ATTEMPTS && remaining.length > 0; attempt++) {
350
424
  if (attempt > 0)
351
425
  retryRounds++;
352
- const results = await pooledResolve(remaining, POOL_SIZE, (url) => fetchOne(url, timeoutMs, log));
426
+ const results = await pooledResolve(remaining, POOL_SIZE, (url) => fetchOne(url, timeoutMs, log, dispatcher));
353
427
  const timedOut = [];
354
428
  for (const r of results) {
355
429
  if (r.status === "ok") {
@@ -1 +1 @@
1
- {"version":3,"file":"htmlToMarkdown.js","sourceRoot":"","sources":["../src/htmlToMarkdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,eAAe,MAAM,UAAU,CAAC;AAEvC,mEAAmE;AACnE,MAAM,4BAA4B,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEtE,oEAAoE;AACpE,IAAI,eAAe,GAAsB,IAAI,CAAC;AAE9C,SAAS,UAAU;IACjB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,IAAI,UAAU,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAChC,eAAe,GAAG,IAAI,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,MAAc;IAC7C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,G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AAM,KAAK,SAAS,EAAE,CAAC;gBAClC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACrB,qEAAqE;gBACrE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,gCAAgC;gBAChC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;gBAChC,WAAW,EAAE,CAAC;YAChB,CAAC;QACH,CAAC;QAED,SAAS,GAAG,QAAQ,CAAC;IACvB,CAAC;IAED,6DAA6D;IAC7D,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,SAAS,GACb,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,WAAW,eAAe,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrF,GAAG,CACD,YAAY,aAAa,IAAI,IAAI,CAAC,MAAM,cAAc,SAAS,CAAC,MAAM,aAAa,SAAS,QAAQ,WAAW,UAAU,SAAS,EAAE,CACrI,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { ImapFlow } from "imapflow";
2
+ /** RFC 5256 §3 sort keys, for the fields `search_emails` exposes. */
3
+ declare const SORT_KEYS: {
4
+ readonly date: "DATE";
5
+ readonly from: "FROM";
6
+ readonly subject: "SUBJECT";
7
+ };
8
+ export type SortField = keyof typeof SORT_KEYS;
9
+ /** True when the connected server advertises RFC 5256 SORT. */
10
+ export declare function supportsSort(client: ImapFlow): boolean;
11
+ /**
12
+ * Issues `UID SORT` for one search criteria object, returning UIDs in the
13
+ * server's order, or `null` when the command could not be used.
14
+ */
15
+ export declare function uidSort(client: ImapFlow, criteria: unknown, sortBy: SortField, sortOrder: "asc" | "desc"): Promise<number[] | null>;
16
+ export {};
17
+ //# sourceMappingURL=imapSort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imapSort.d.ts","sourceRoot":"","sources":["../src/imapSort.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIzC,qEAAqE;AACrE,QAAA,MAAM,SAAS;;;;CAIL,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,SAAS,CAAC;AAiD/C,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAMtD;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,KAAK,GAAG,MAAM,GACxB,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CA+C1B"}