apple-mail-mcp 2.17.3 → 2.17.4

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.
Files changed (2) hide show
  1. package/build/index.js +34 -7
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -84154,8 +84154,18 @@ var defaultConnect = async (cfg) => {
84154
84154
  }
84155
84155
  return client;
84156
84156
  };
84157
- function resolveMailboxPath(mailbox, _mode) {
84158
- if (!mailbox) return "INBOX";
84157
+ var SPECIAL_USE_ALIASES = {
84158
+ "all mail": "\\all",
84159
+ archive: "\\archive",
84160
+ drafts: "\\drafts",
84161
+ sent: "\\sent",
84162
+ "sent mail": "\\sent",
84163
+ trash: "\\trash",
84164
+ spam: "\\junk",
84165
+ junk: "\\junk",
84166
+ starred: "\\flagged"
84167
+ };
84168
+ function staticMailboxAlias(mailbox) {
84159
84169
  const map = {
84160
84170
  "all mail": "[Gmail]/All Mail",
84161
84171
  "sent mail": "[Gmail]/Sent Mail",
@@ -84169,6 +84179,21 @@ function resolveMailboxPath(mailbox, _mode) {
84169
84179
  };
84170
84180
  return map[mailbox.trim().toLowerCase()] ?? mailbox;
84171
84181
  }
84182
+ async function resolveMailboxPath(client, mailbox, _mode) {
84183
+ if (!mailbox) return "INBOX";
84184
+ try {
84185
+ const resolved = await resolveMailbox(client, mailbox);
84186
+ if (resolved.kind === "found") return resolved.path;
84187
+ const flag = SPECIAL_USE_ALIASES[mailbox.trim().toLowerCase()];
84188
+ if (flag) {
84189
+ const boxes = await client.list();
84190
+ const special = boxes.find((b) => b.specialUse?.toLowerCase() === flag);
84191
+ if (special) return special.path;
84192
+ }
84193
+ } catch {
84194
+ }
84195
+ return staticMailboxAlias(mailbox);
84196
+ }
84172
84197
  function buildCriteria(a, listMode) {
84173
84198
  const c = {};
84174
84199
  if (a.query) c.or = [{ subject: a.query }, { from: a.query }];
@@ -84277,7 +84302,7 @@ async function run(args, listMode, deps) {
84277
84302
  throw new Error(`No selectable IMAP mailboxes found for account ${cfg.accountLabel}.`);
84278
84303
  }
84279
84304
  } else {
84280
- paths = [resolveMailboxPath(args.mailbox, listMode ? "list" : "search")];
84305
+ paths = [await resolveMailboxPath(client, args.mailbox, listMode ? "list" : "search")];
84281
84306
  }
84282
84307
  const limit = args.limit ?? 50;
84283
84308
  const offset = args.offset ?? 0;
@@ -84353,7 +84378,9 @@ function imapUnreadCount(mailbox, deps = {}) {
84353
84378
  return useClient(
84354
84379
  deps,
84355
84380
  async (client) => {
84356
- const s = await client.status(resolveMailboxPath(mailbox, "list"), { unseen: true });
84381
+ const s = await client.status(await resolveMailboxPath(client, mailbox, "list"), {
84382
+ unseen: true
84383
+ });
84357
84384
  return s.unseen ?? 0;
84358
84385
  },
84359
84386
  true
@@ -84785,7 +84812,7 @@ async function imapMoveMessageById(id, destMailbox, deps = {}) {
84785
84812
  error: ambiguousMailboxError(destMailbox, dest.candidates, cfg.accountLabel)
84786
84813
  };
84787
84814
  }
84788
- const destPath = dest.kind === "found" ? dest.path : resolveMailboxPath(destMailbox, "list");
84815
+ const destPath = dest.kind === "found" ? dest.path : await resolveMailboxPath(client, destMailbox, "list");
84789
84816
  const lock = await client.getMailboxLock(ref.path);
84790
84817
  try {
84791
84818
  const moved = assertMutated(
@@ -84822,7 +84849,7 @@ async function resolveTrashPath(client) {
84822
84849
  if (named) return named.path;
84823
84850
  } catch {
84824
84851
  }
84825
- if (!listed) return resolveMailboxPath("trash", "list");
84852
+ if (!listed) return staticMailboxAlias("trash");
84826
84853
  try {
84827
84854
  const created = await client.mailboxCreate(FALLBACK_TRASH_PATH);
84828
84855
  return created?.path || FALLBACK_TRASH_PATH;
@@ -85076,7 +85103,7 @@ function imapBatchMove(ids, destMailbox, deps = {}) {
85076
85103
  ids,
85077
85104
  deps,
85078
85105
  async (c, uids) => {
85079
- const dest = await findMailboxPathOrThrow(c, destMailbox) ?? resolveMailboxPath(destMailbox, "list");
85106
+ const dest = await findMailboxPathOrThrow(c, destMailbox) ?? await resolveMailboxPath(c, destMailbox, "list");
85080
85107
  assertMutated(
85081
85108
  await c.messageMove(uids, dest, { uid: true }),
85082
85109
  `IMAP move of ${uids.length} message(s) to "${dest}"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apple-mail-mcp",
3
- "version": "2.17.3",
3
+ "version": "2.17.4",
4
4
  "description": "MCP server for Apple Mail - read, search, send, and manage emails via Claude and other AI assistants",
5
5
  "type": "module",
6
6
  "main": "build/index.js",