@mgcrea/mcp-apple-mail 1.36.2 → 1.38.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/README.md +13 -3
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +27 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{server-ynr059Dx.js → server-D-UcpTRv.js} +417 -80
- package/dist/server-D-UcpTRv.js.map +1 -0
- package/package.json +2 -2
- package/dist/server-ynr059Dx.js.map +0 -1
package/README.md
CHANGED
|
@@ -165,7 +165,15 @@ wrong:
|
|
|
165
165
|
164,156-byte PDF advertises 224,634.
|
|
166
166
|
|
|
167
167
|
`list_attachments` therefore reports `sizeBytes` from the file on disk and a `retrievable` flag
|
|
168
|
-
saying whether
|
|
168
|
+
saying whether the bytes are on disk, rather than guessing from the message.
|
|
169
|
+
|
|
170
|
+
An attachment with `retrievable: false` has not been downloaded by Mail, which on a Gmail account
|
|
171
|
+
caching messages without their attachments is most older mail. `save_attachment` then asks Mail to
|
|
172
|
+
save it, and Mail's `save` fetches it from the server first; the result says `from: "mail"`. Mail
|
|
173
|
+
also keeps what it fetched, so the attachment reads `retrievable: true` afterwards. Mail has to be
|
|
174
|
+
running and online, a large file can take a while (Mail allows itself two minutes), and Mail writes into a
|
|
175
|
+
staging folder inside `APPLE_MAIL_ATTACHMENT_DIR` that is removed after the copy, never into the
|
|
176
|
+
destination itself.
|
|
169
177
|
|
|
170
178
|
## Security
|
|
171
179
|
|
|
@@ -182,8 +190,10 @@ Once implemented, sending will default to leaving a **draft** open for review; a
|
|
|
182
190
|
requires both `ALLOW_WRITES` and an explicit `confirm: true`.
|
|
183
191
|
|
|
184
192
|
**No secrets.** The server holds no credential of any kind — its access is the macOS permission you
|
|
185
|
-
granted the host app. There is nothing here to leak, and nothing is sent anywhere:
|
|
186
|
-
|
|
193
|
+
granted the host app. There is nothing here to leak, and nothing is sent anywhere: the server makes
|
|
194
|
+
no network calls at all. What reaches a network is Mail itself, doing what it was asked: sending,
|
|
195
|
+
checking for new mail, and also `save_attachment` asking it to download an attachment from your own
|
|
196
|
+
mail server.
|
|
187
197
|
|
|
188
198
|
**Attachments.** `save_attachment` can only write inside `APPLE_MAIL_ATTACHMENT_DIR`, and the
|
|
189
199
|
filename is reduced to its basename first — a sender who names their attachment
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as loadConfig, b as MAIL_SURFACE, j as BUILD_INFO, r as createServer } from "./server-
|
|
2
|
+
import { a as loadConfig, b as MAIL_SURFACE, j as BUILD_INFO, r as createServer } from "./server-D-UcpTRv.js";
|
|
3
3
|
import { runStdioServer } from "@mgcrea/mcp-apple-core";
|
|
4
4
|
//#region src/cli.ts
|
|
5
5
|
const LOG_PREFIX = "apple-mail-mcp";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppBusyError as MailBusyError, AppNotRunningError as MailNotRunningError, AppleAutomationError, AppleAutomationError as AppleMailError, ArrivalRow, ArrivalSource, BuildInfo, Era, FileIdentity, IndexUnavailableError, InterferenceWatch, JxaEnvelope, ListenLedger, Logger, OsascriptRunner, OsascriptTimeoutError, PlatformError, PreconditionError, ProtocolError, SchemaDriftError, TccDeniedError, Watch, WatchRegistry, WritesDisabledError, assertStaticScript, createOsascriptRunner, inspectFile, mapOsaError, normalizeFilter, withBusyRetry } from "@mgcrea/mcp-apple-core";
|
|
1
|
+
import { AppBusyError as MailBusyError, AppNotRunningError as MailNotRunningError, AppleAutomationError, AppleAutomationError as AppleMailError, ArrivalRow, ArrivalSource, BuildInfo, Era, FileIdentity, IndexUnavailableError, InterferenceWatch, JxaEnvelope, ListenLedger, Logger, OsascriptRunner, OsascriptTimeoutError, PlatformError, PreconditionError, PreconditionError as PreconditionError$1, ProtocolError, SchemaDriftError, TccDeniedError, Watch, WatchRegistry, WritesDisabledError, assertStaticScript, createOsascriptRunner, inspectFile, mapOsaError, normalizeFilter, withBusyRetry } from "@mgcrea/mcp-apple-core";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
4
4
|
import { DatabaseSync } from "node:sqlite";
|
|
@@ -193,6 +193,14 @@ type EditComposerArgs = {
|
|
|
193
193
|
attachments?: string[];
|
|
194
194
|
save?: boolean;
|
|
195
195
|
expectHead?: string;
|
|
196
|
+
/**
|
|
197
|
+
* With `expectHead`: the head is the draft's whole stored text (up to its
|
|
198
|
+
* cap), so below 120 characters the window must hold exactly that text, not
|
|
199
|
+
* merely begin it. Sent for a draft that is not a reply, whose stored text is
|
|
200
|
+
* its own; a reply's runs on into its quote, which the window lists apart. An
|
|
201
|
+
* app that predates it ignores it and checks the prefix.
|
|
202
|
+
*/
|
|
203
|
+
expectWhole?: boolean;
|
|
196
204
|
};
|
|
197
205
|
type ReachReport = {
|
|
198
206
|
ok: boolean;
|
|
@@ -395,7 +403,10 @@ type ParsedMessage = {
|
|
|
395
403
|
headers: Record<string, string | null>;
|
|
396
404
|
body: string;
|
|
397
405
|
bodyFrom: "text/plain" | "text/html" | "none";
|
|
398
|
-
/**
|
|
406
|
+
/**
|
|
407
|
+
* `retrievable` says whether the bytes are on disk. When they are not,
|
|
408
|
+
* save_attachment has Mail download them, which needs Mail running and online.
|
|
409
|
+
*/
|
|
399
410
|
attachments: (Attachment & {
|
|
400
411
|
retrievable: boolean;
|
|
401
412
|
})[];
|
|
@@ -659,6 +670,14 @@ declare class MailboxMap {
|
|
|
659
670
|
* `[Gmail]/`-stripped, then final path segment, then case-insensitive.
|
|
660
671
|
*/
|
|
661
672
|
resolveMailboxName(account: MailAccount, wanted: string): string;
|
|
673
|
+
/**
|
|
674
|
+
* `resolveMailboxName` for a name a caller asked for, with `resolveAccount`'s
|
|
675
|
+
* second chance: the account came out of a list that can be stale by design,
|
|
676
|
+
* so a name it lacks earns one fresh read before it is refused. A mailbox
|
|
677
|
+
* created in Mail, or synced from another device, since that list was taken
|
|
678
|
+
* is then found on the first call rather than the one after.
|
|
679
|
+
*/
|
|
680
|
+
resolveMailbox(account: MailAccount, wanted: string): Promise<string>;
|
|
662
681
|
/**
|
|
663
682
|
* Map an Envelope Index `mailboxes.url` onto a scriptable account + mailbox.
|
|
664
683
|
* The URL host is the account UUID (verified against live Mail), so this join
|
|
@@ -1009,13 +1028,17 @@ declare class AppleMailClient {
|
|
|
1009
1028
|
* The destination is resolved and then checked to be inside
|
|
1010
1029
|
* `APPLE_MAIL_ATTACHMENT_DIR`, so a filename of `../../.ssh/authorized_keys`
|
|
1011
1030
|
* lands nowhere. Existing files are never overwritten.
|
|
1031
|
+
*
|
|
1032
|
+
* When the bytes are not on disk, which on a Gmail account caching messages
|
|
1033
|
+
* without their attachments is most older mail, Mail is asked to download
|
|
1034
|
+
* the attachment (see `#fetchFromMail`).
|
|
1012
1035
|
*/
|
|
1013
|
-
saveAttachment(ref: string,
|
|
1036
|
+
saveAttachment(ref: string, requested: string, opts?: {
|
|
1014
1037
|
overwrite?: boolean;
|
|
1015
1038
|
}): Promise<{
|
|
1016
1039
|
path: string;
|
|
1017
1040
|
bytes: number;
|
|
1018
|
-
from: "inline" | "sidecar";
|
|
1041
|
+
from: "inline" | "sidecar" | "mail";
|
|
1019
1042
|
}>;
|
|
1020
1043
|
/** Set flags across refs, one Apple Event per distinct mailbox. */
|
|
1021
1044
|
setFlags(refs: string[], flags: {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/build-info.ts","../src/client/errors.ts","../src/client/locate.ts","../src/config.ts","../src/client/ax.ts","../src/client/mime.ts","../src/client/emlx.ts","../src/client/schema.ts","../src/client/envelope.ts","../src/client/mailbox-map.ts","../src/client/mail.ts","../src/client/ref.ts","../src/client/watch.ts","../src/tools/watch.ts","../src/server.ts","../src/tools/index.ts"],"mappings":";;;;;cAkBa,YAAY;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/build-info.ts","../src/client/errors.ts","../src/client/locate.ts","../src/config.ts","../src/client/ax.ts","../src/client/mime.ts","../src/client/emlx.ts","../src/client/schema.ts","../src/client/envelope.ts","../src/client/mailbox-map.ts","../src/client/mail.ts","../src/client/ref.ts","../src/client/watch.ts","../src/tools/watch.ts","../src/server.ts","../src/tools/index.ts"],"mappings":";;;;;cAkBa,YAAY;;;;cCeZ,6BAA6B;WACtB;EAElB,YAAY;;;;;;;;;;;;;;;;;;;;KCbF;;EAEV;;EAEA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;KAKU;;EAEV;;EAEA;;EAEA;;EAEA;;cAiBW,sBAAmB,OAAU,kBAAqB;;;;;;;;;;;;;;;cC3CzD,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFP,EAAA,KAAA;KAEC,SAAS,EAAE,aAAa;;;;;cAMvB,aAAU,MAAS,OAAO,eAA2B;;;KCxCtD;EAAgB;EAAgB;EAAc;;;KAG9C;;;;;;;;;EASV;;;;;;;;;;;EAWA;;EAEA;;;;;;;;EAQA;;EAEA;;EAEA;;EAEA;EACA;EACA;;EAEA;;EAEA;EACA;;;;;;EAMA;;EAEA;;EAEA;;;;;;EAMA;;EAEA;;KAGU;EACV;EACA;;;;;;;EAOA;EACA;EACA;IAAU;IAAc;;EACxB;EACA;EACA;;;;;;;;EAQA;;KAGU;EACV;;EAEA;EACA;;KAiBU;EACV;EACA;;cAGW;;UAUJ;;SAOA,KACL,MAAK,OAAO,YACZ,OAAM,oBACL;EAKH;;EAKA,SAAS;;;;;;;EAcH,UAAU,sBAAsB,QAAQ;;;;;;;;;;;;EAmBxC,aAAa,MAAM,mBAAmB,QAAQ;;;;;;;;EA0C9C,WAAW;;;;;;;;;;;;;;;;;;EAqBX,SAAS,QAAQ;;;;;;;;;;;;;;;SA2BhB,aAAa;;kBAUJ;;;;;;;;;;;;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reconditionError, O as SchemaDriftError, S as MailNotRunningError, T as PlatformError, _ as locateEnvelopeIndex, a as loadConfig, c as decodeRef, d as assertStaticScript, f as createOsascriptRunner, g as inspectFile, h as MailboxMap, i as registerTools, j as BUILD_INFO, k as TccDeniedError, l as encodeRef, m as withBusyRetry, n as SERVER_VERSION, o as AppleMailClient, p as mapOsaError, r as createServer, s as REF_VERSION, t as SERVER_NAME, u as groupRefsByMailbox, v as AppleMailError, w as OsascriptTimeoutError, x as MailBusyError, y as IndexUnavailableError } from "./server-
|
|
1
|
+
import { A as WritesDisabledError, C as MessageNotFoundError, D as ProtocolError, E as PreconditionError, O as SchemaDriftError, S as MailNotRunningError, T as PlatformError, _ as locateEnvelopeIndex, a as loadConfig, c as decodeRef, d as assertStaticScript, f as createOsascriptRunner, g as inspectFile, h as MailboxMap, i as registerTools, j as BUILD_INFO, k as TccDeniedError, l as encodeRef, m as withBusyRetry, n as SERVER_VERSION, o as AppleMailClient, p as mapOsaError, r as createServer, s as REF_VERSION, t as SERVER_NAME, u as groupRefsByMailbox, v as AppleMailError, w as OsascriptTimeoutError, x as MailBusyError, y as IndexUnavailableError } from "./server-D-UcpTRv.js";
|
|
2
2
|
export { AppleMailClient, AppleMailError, BUILD_INFO, IndexUnavailableError, MailBusyError, MailNotRunningError, MailboxMap, MessageNotFoundError, OsascriptTimeoutError, PlatformError, PreconditionError, ProtocolError, REF_VERSION, SERVER_NAME, SERVER_VERSION, SchemaDriftError, TccDeniedError, WritesDisabledError, assertStaticScript, createOsascriptRunner, createServer, decodeRef, encodeRef, groupRefsByMailbox, inspectFile, loadConfig, locateEnvelopeIndex, mapOsaError, registerTools, withBusyRetry };
|