@mgcrea/mcp-apple-mail 1.4.0 → 1.7.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/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-CGg9tIuQ.js";
2
+ import { a as loadConfig, b as MAIL_SURFACE, j as BUILD_INFO, r as createServer } from "./server-BlDyuhLT.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
@@ -286,16 +286,8 @@ declare class MailboxMap {
286
286
  }
287
287
  //#endregion
288
288
  //#region src/client/mail.d.ts
289
- /**
290
- * The facade every tool talks to. It owns three things the tools should not
291
- * each re-decide: which lane answers a question, what to say when a lane is
292
- * unavailable, and the read-after-write rule.
293
- */
294
289
  type MessageSummary = {
295
290
  ref: string;
296
- id: number;
297
- accountUuid: string;
298
- mailbox: string;
299
291
  subject: string | null;
300
292
  sender: string | null;
301
293
  dateReceived: string | null;
@@ -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/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/server.ts","../src/tools/index.ts"],"mappings":";;;;;cAkBa,YAAY;;;;cCWZ,6BAA6B;WACtB;EAElB,YAAY;;;;;;;;;;;;;;;;;;;;KCTF;;EAEV;;EAEA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;KAKU;;EAEV;;EAEA;;EAEA;;EAEA;;cAiBW,sBAAmB,OAAU,kBAAqB;;;;;;;;;;;;;;;cC3CzD,cAAY,EAAA;;;;;;;;;;;;;;;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DI,YACJ,aACA;IAAQ;IAAc;MACrB,QAAQ;EAoBL,gBAAgB,mBAAmB;EAKnC,YAAY;IAChB;IACA;IACA;IACA;IACA;IACA;IACA;MACE;EAaE,eACJ,aACA;IACE;IACA;IACA;IACA;IACA;MAED;;;;;;;;;;;;;;;;;;;;;cChnCQ;KAED;EACV;EACA;EACA;;cAKW,YAAS,KAAS;cAGlB,YAAS,gBAAkB;;cA2B3B,qBAAkB,MAAU,iBAAe,YAAY;;;cChDvD;cACA;KAED;EACV,QAAQ;EACR,SAAS;;EAET,YAAY;;KAGF;EACV,QAAQ;EACR,QAAQ;;;;;;;cAQG,eAAY,MAAU,wBAAsB;;;KCtB7C;;;;;EAKV;;;;;;;;;;;;cAaW,gBAAa,QAChB,WAAS,QACT,iBAAe,KAClB"}
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/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/server.ts","../src/tools/index.ts"],"mappings":";;;;;cAkBa,YAAY;;;;cCWZ,6BAA6B;WACtB;EAElB,YAAY;;;;;;;;;;;;;;;;;;;;KCTF;;EAEV;;EAEA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;KAKU;;EAEV;;EAEA;;EAEA;;EAEA;;cAiBW,sBAAmB,OAAU,kBAAqB;;;;;;;;;;;;;;;cC3CzD,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;GA8CP,EAAA,KAAA;KAEC,SAAS,EAAE,aAAa;;;;;cAMvB,aAAU,MAAS,OAAO,eAA2B;;;KCvDtD;EACV;EACA;EACA;;;;;;;;;EASA;;EAEA;;;;;;;;;;;;;;;;;;;;;KCEU;EACV,SAAS;EACT;EACA;;EAEA,cAAc;IAAe;;EAC7B;EACA;EACA;EACA;;;;KC1BU;EACV;EACA,QAAQ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MAAU,iBAAe,YAAY;;;cChDvD;cACA;KAED;EACV,QAAQ;EACR,SAAS;;EAET,YAAY;;KAGF;EACV,QAAQ;EACR,QAAQ;;;;;;;cAQG,eAAY,MAAU,wBAAsB;;;KCtB7C;;;;;EAKV;;;;;;;;;;;;cAaW,gBAAa,QAChB,WAAS,QACT,iBAAe,KAClB"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
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-CGg9tIuQ.js";
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-BlDyuhLT.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 };
@@ -1,4 +1,4 @@
1
- import { AppBusyError as MailBusyError, AppNotRunningError as MailNotRunningError, AppleAutomationError, AppleAutomationError as AppleMailError, BaseConfigSchema, IndexUnavailableError, OsascriptTimeoutError, PlatformError, PreconditionError, ProtocolError, SchemaDriftError, TccDeniedError, WritesDisabledError, assertStaticScript, confirmArg, createOsascriptRunner, detectEpoch, escapeLike, fingerprintSchema, inspectFile, limitArg, mapOsaError, openReadOnly, parseBool, parseConfig, parseIntOpt, parseList, promptArg, readPackageIdentity, registerSurfaceResources, registerWorkflowPrompt, requiredPromptArg, tableMap, trimmed, withBusyRetry, wrap } from "@mgcrea/mcp-apple-core";
1
+ import { AppBusyError as MailBusyError, AppNotRunningError as MailNotRunningError, AppleAutomationError, AppleAutomationError as AppleMailError, BaseConfigSchema, IndexUnavailableError, OsascriptTimeoutError, PlatformError, PreconditionError, ProtocolError, SchemaDriftError, TccDeniedError, WritesDisabledError, assertStaticScript, confirmArg, createOsascriptRunner, detectEpoch, escapeLike, fingerprintSchema, inspectFile, limitArg, mapOsaError, openReadOnly, parseBool, parseConfig, parseIntOpt, parseList, promptArg, readPackageIdentity, registerSurfaceResources, registerWorkflowPrompt, requiredPromptArg, resolveLimit, tableMap, trimmed, withBusyRetry, wrap } from "@mgcrea/mcp-apple-core";
2
2
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, statSync, writeFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { basename, dirname, join, resolve, sep } from "node:path";
@@ -12,8 +12,8 @@ const pkg = readPackageIdentity(new URL("../package.json", import.meta.url), {
12
12
  const BUILD_INFO = {
13
13
  name: pkg.name,
14
14
  version: pkg.version,
15
- gitCommit: "1779320",
16
- gitCommitDate: "2026-08-30T12:29:09+02:00"
15
+ gitCommit: "24d3fc4",
16
+ gitCommitDate: "2026-09-01T14:32:08+02:00"
17
17
  };
18
18
  //#endregion
19
19
  //#region src/client/errors.ts
@@ -1335,7 +1335,15 @@ function maxQuoteLevel(el, depth) {
1335
1335
  * composer to its minimum and push it off-screen first (macOS clamps it back to
1336
1336
  * leave a 40px sliver — that residue is not removable from outside Mail's
1337
1337
  * process, as the window server ignores alpha changes from a foreign
1338
- * connection), then hand the user's app back before sending.
1338
+ * connection), then put the window back exactly where it was found before the
1339
+ * user's app is handed back.
1340
+ *
1341
+ * Restoring is NOT cosmetic. Mail persists the compose window's frame, so a
1342
+ * composer left at [1, 1] off-screen is inherited by the next one the user
1343
+ * opens by hand -- and on a send that only saves a draft, the window this
1344
+ * shrank is the very window the caller is told is "open in Mail for review".
1345
+ * So a window whose geometry cannot be read back is not moved at all: the flash
1346
+ * of a composer coming forward is worth less than a window stuck at [1, 1].
1339
1347
  *
1340
1348
  * Failure is reported, never fatal: a quoted send still beats a lost one.
1341
1349
  */
@@ -1353,9 +1361,24 @@ function stripCitation(windowName) {
1353
1361
  // An empty subject names the window something else; the composer is frontmost regardless.
1354
1362
  if (!win) win = wins[0];
1355
1363
 
1356
- // Out of sight before Mail comes forward, so the user sees as little as possible.
1357
- try { win.size = [1, 1]; } catch (e) {}
1358
- try { win.position = [-100000, -100000]; } catch (e) {}
1364
+ // Read the real geometry BEFORE moving: once the window is off-screen the
1365
+ // window server answers with what it clamped to, not what the user chose.
1366
+ var was = null;
1367
+ try { was = { size: win.size(), position: win.position() }; } catch (e) { was = null; }
1368
+ var unhide = function () {
1369
+ if (!was) return;
1370
+ // Position first, so the window grows back from the right top-left corner.
1371
+ try { win.position = was.position; } catch (e) {}
1372
+ try { win.size = was.size; } catch (e) {}
1373
+ };
1374
+
1375
+ // Out of sight before Mail comes forward, so the user sees as little as
1376
+ // possible -- and only when the geometry came back, because hiding a window
1377
+ // we have no way to put back is how it stays hidden.
1378
+ if (was) {
1379
+ try { win.size = [1, 1]; } catch (e) {}
1380
+ try { win.position = [-100000, -100000]; } catch (e) {}
1381
+ }
1359
1382
 
1360
1383
  var previous = prop(function () {
1361
1384
  return SE.applicationProcesses.whose({ frontmost: true })[0].name();
@@ -1388,6 +1411,10 @@ function stripCitation(windowName) {
1388
1411
  stripped = false;
1389
1412
  }
1390
1413
 
1414
+ // Before the caller sends, saves, or leaves this window on screen, and on the
1415
+ // failure path too: a strip that threw must not cost the user their composer.
1416
+ unhide();
1417
+
1391
1418
  if (previous && previous !== "Mail") {
1392
1419
  try { SE.processes.byName(previous).frontmost = true; } catch (e) {}
1393
1420
  }
@@ -1932,8 +1959,10 @@ const SEND_MESSAGE = script(`
1932
1959
  * * **Threading.** `In-Reply-To` and `References` are set by Mail's own
1933
1960
  * `reply` command, which needs the original message. A recreated reply
1934
1961
  * draft looks perfect and starts a new thread.
1935
- * * **Attachments.** They can be read but not re-attached; the dictionary has
1936
- * no verb for adding one to an outgoing message.
1962
+ * * **Attachments.** Adding one to an outgoing message IS possible:
1963
+ * `content.attachments.push(Mail.Attachment({fileName: Path(f)}))`, measured
1964
+ * on macOS 26.6. What is missing is a file to point at. The bytes live in the
1965
+ * original's sidecar tree, and extracting them first is not done here.
1937
1966
  *
1938
1967
  * Both are refused rather than silently dropped. A draft that is correct in
1939
1968
  * every visible respect except the part nobody checks is the exact failure the
@@ -2049,9 +2078,9 @@ const UPDATE_DRAFT = script(`
2049
2078
  return ok({
2050
2079
  replaced: false, degraded: true, capability: "attachments", draft: facts,
2051
2080
  reason:
2052
- "This draft carries " + attachments + " attachment(s). Mail's scripting interface can " +
2053
- "read an attachment but has no verb for adding one to an outgoing message, so " +
2054
- "recreating the draft would silently drop them.",
2081
+ "This draft carries " + attachments + " attachment(s). Recreating it would silently drop " +
2082
+ "them: their bytes live inside the original message, not as files this can point at, and " +
2083
+ "re-attaching means extracting them first, which is not done here.",
2055
2084
  hint: "Edit the body in Mail directly, which keeps the attachments."
2056
2085
  });
2057
2086
  }
@@ -2837,9 +2866,6 @@ var AppleMailClient = class {
2837
2866
  mailbox: entry.mailbox,
2838
2867
  id: row.rowid
2839
2868
  }),
2840
- id: row.rowid,
2841
- accountUuid: entry.accountUuid,
2842
- mailbox: entry.mailbox,
2843
2869
  subject: row.subject,
2844
2870
  sender,
2845
2871
  dateReceived: row.dateReceived,
@@ -3294,14 +3320,14 @@ var AppleMailClient = class {
3294
3320
  });
3295
3321
  }
3296
3322
  #withRef(m) {
3297
- const ref = {
3298
- accountUuid: m.accountUuid,
3299
- mailbox: m.mailbox,
3300
- id: m.id
3301
- };
3323
+ const { id, accountUuid, mailbox, ...rest } = m;
3302
3324
  return {
3303
- ...m,
3304
- ref: encodeRef(ref)
3325
+ ...rest,
3326
+ ref: encodeRef({
3327
+ accountUuid,
3328
+ mailbox,
3329
+ id
3330
+ })
3305
3331
  };
3306
3332
  }
3307
3333
  };
@@ -3906,7 +3932,7 @@ const registerComposeTools = (server, client) => {
3906
3932
  });
3907
3933
  }));
3908
3934
  server.registerTool("apple_mail_update_draft", {
3909
- description: "Replace the body of an unsent draft. Mail has no way to edit a saved draft — its `content` is read-only and there is no open or edit command — so this RECREATES it: a new draft with the same recipients and a new body, and the old one deleted once the replacement is confirmed present. The ref you passed in is DEAD afterwards and the result carries the new one. It REFUSES rather than doing damage, and returns `replaced: false` with a reason when it does: on a reply or forward draft, because In-Reply-To is set by Mail's reply command and a recreated one would silently start a new thread; on a draft carrying attachments, because they cannot be re-attached; and on anything that is not in the Drafts mailbox, because deleting a sent or received message and writing a lookalike is not editing. In every refusal the original is untouched. If the replacement cannot be confirmed the original is KEPT and you are told there are now two — never assume a clean swap without reading `replaced`.",
3935
+ description: "Replace the body of an unsent draft. Mail has no way to edit a saved draft — its `content` is read-only and there is no open or edit command — so this RECREATES it: a new draft with the same recipients and a new body, and the old one deleted once the replacement is confirmed present. The ref you passed in is DEAD afterwards and the result carries the new one. It REFUSES rather than doing damage, and returns `replaced: false` with a reason when it does: on a reply or forward draft, because In-Reply-To is set by Mail's reply command and a recreated one would silently start a new thread; on a draft carrying attachments, because their bytes are not available as files to re-attach; and on anything not in the Drafts mailbox, because deleting a sent or received message and writing a lookalike is not editing. In every refusal the original is untouched. If the replacement cannot be confirmed the original is KEPT and you are told there are now two — never assume a clean swap without reading `replaced`.",
3910
3936
  inputSchema: {
3911
3937
  ref: messageRefArg,
3912
3938
  body: z.string().min(1).describe("The complete new body. This REPLACES the draft's text rather than appending to it, so include everything that should remain — read the draft first with apple_mail_get_message if you are editing rather than rewriting."),
@@ -4042,7 +4068,7 @@ const registerSearchTools = (server, client) => {
4042
4068
  }, async (args) => wrap(async () => {
4043
4069
  const result = await client.searchMessages({
4044
4070
  ...args,
4045
- limit: Math.min(args.limit ?? 25, client.config.maxResults),
4071
+ limit: resolveLimit(args.limit, client.config.maxResults),
4046
4072
  offset: args.offset ?? 0
4047
4073
  });
4048
4074
  if (!result) return {
@@ -4079,7 +4105,7 @@ const registerSearchTools = (server, client) => {
4079
4105
  },
4080
4106
  annotations: { readOnlyHint: true }
4081
4107
  }, async ({ ref, limit }) => wrap(async () => {
4082
- const messages = await client.threadOf(ref, Math.min(limit ?? 50, client.config.maxResults));
4108
+ const messages = await client.threadOf(ref, resolveLimit(limit, client.config.maxResults, 50));
4083
4109
  if (!messages) return {
4084
4110
  degraded: true,
4085
4111
  capability: "search-index",
@@ -4107,7 +4133,7 @@ const registerSearchTools = (server, client) => {
4107
4133
  note: "No accounts are visible to this server."
4108
4134
  };
4109
4135
  const box = mailbox ?? (resolved.mailboxes.includes("INBOX") ? "INBOX" : "Inbox");
4110
- const result = await client.listRecent(resolved, box, limit ?? 25);
4136
+ const result = await client.listRecent(resolved, box, resolveLimit(limit, client.config.maxResults));
4111
4137
  const lanes = await client.lanes();
4112
4138
  return {
4113
4139
  account: resolved.name,
@@ -4218,4 +4244,4 @@ const createServer = (opts) => {
4218
4244
  //#endregion
4219
4245
  export { WritesDisabledError as A, MessageNotFoundError as C, ProtocolError as D, PreconditionError as E, SchemaDriftError as O, MailNotRunningError as S, PlatformError as T, locateEnvelopeIndex as _, loadConfig as a, MAIL_SURFACE as b, decodeRef as c, assertStaticScript as d, createOsascriptRunner as f, inspectFile as g, MailboxMap as h, registerTools as i, BUILD_INFO as j, TccDeniedError as k, encodeRef as l, withBusyRetry as m, SERVER_VERSION as n, AppleMailClient as o, mapOsaError as p, createServer as r, REF_VERSION as s, SERVER_NAME as t, groupRefsByMailbox as u, AppleMailError as v, OsascriptTimeoutError as w, MailBusyError as x, IndexUnavailableError as y };
4220
4246
 
4221
- //# sourceMappingURL=server-CGg9tIuQ.js.map
4247
+ //# sourceMappingURL=server-BlDyuhLT.js.map