apple-mail-mcp 2.13.1 → 2.13.2
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/build/index.js +59 -7
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -84652,6 +84652,25 @@ function withErrorHandling(handler, errorPrefix) {
|
|
|
84652
84652
|
};
|
|
84653
84653
|
}
|
|
84654
84654
|
|
|
84655
|
+
// src/tools/mailboxListing.ts
|
|
84656
|
+
var LOCAL_STORE_NAMES = ["on my mac", "on my computer", "local", "local folders"];
|
|
84657
|
+
function isLocalStoreName(name) {
|
|
84658
|
+
return LOCAL_STORE_NAMES.includes(name.trim().toLowerCase());
|
|
84659
|
+
}
|
|
84660
|
+
function unlistableStoreError(account, error2, knownAccounts) {
|
|
84661
|
+
const scope = account ? ` for "${account}"` : "";
|
|
84662
|
+
const parts = [`Could not list mailboxes${scope}: ${error2 ?? "Mail declined the request"}`];
|
|
84663
|
+
if (knownAccounts.length > 0) {
|
|
84664
|
+
parts.push(`Accounts on this Mac: ${knownAccounts.join(", ")}.`);
|
|
84665
|
+
}
|
|
84666
|
+
if (account && isLocalStoreName(account)) {
|
|
84667
|
+
parts.push(
|
|
84668
|
+
`"${account}" is Mail's LOCAL store, not an account \u2014 its mailboxes are not children of any account, so they cannot be reached with an \`account\` argument. Enumerating them is not yet supported.`
|
|
84669
|
+
);
|
|
84670
|
+
}
|
|
84671
|
+
return parts.join("\n\n");
|
|
84672
|
+
}
|
|
84673
|
+
|
|
84655
84674
|
// src/tools/batchResults.ts
|
|
84656
84675
|
async function hybridBatchCounts(ids, appleFn, imapFn) {
|
|
84657
84676
|
const distinctIds = [...new Set(ids)];
|
|
@@ -86693,13 +86712,17 @@ ${r.base64}`,
|
|
|
86693
86712
|
registerTool(
|
|
86694
86713
|
"list-mailboxes",
|
|
86695
86714
|
{
|
|
86696
|
-
description: "Use when: discovering the mailbox/folder names (and unread/message counts) available in an account, e.g. before moving messages or searching a specific mailbox.\nReturns: each mailbox's name with its unread (and, for IMAP, total message) count, plus a count.\nDo not use when: you want the messages inside a mailbox (use list-messages or search-messages) or the list of accounts (use list-accounts).",
|
|
86715
|
+
description: "Use when: discovering the mailbox/folder names (and unread/message counts) available in an account, e.g. before moving messages or searching a specific mailbox.\nReturns: each mailbox's name with its unread (and, for IMAP, total message) count, plus a count. A source that could not be read is NAMED \u2014 the result carries `partial: true` + `failedAccounts` and the list is a floor, not the complete set \u2014 and a listing Mail refused outright (e.g. an account that does not exist) returns an ERROR naming the accounts that do exist, never an empty list.\nDo not use when: you want the messages inside a mailbox (use list-messages or search-messages) or the list of accounts (use list-accounts).\nNote: Mail's local \"On My Mac\" mailboxes are not part of any account and are not currently enumerated by this tool.",
|
|
86697
86716
|
inputSchema: {
|
|
86698
86717
|
account: external_exports.string().optional().describe("Account to list mailboxes from")
|
|
86699
86718
|
},
|
|
86700
86719
|
outputSchema: {
|
|
86701
86720
|
mailboxes: external_exports.array(external_exports.object({}).passthrough()).optional(),
|
|
86702
|
-
count: external_exports.number().optional()
|
|
86721
|
+
count: external_exports.number().optional(),
|
|
86722
|
+
// Declared explicitly: the SDK stamps additionalProperties:false on a bare
|
|
86723
|
+
// zod shape, so an undeclared key makes the CLIENT reject the result.
|
|
86724
|
+
partial: external_exports.boolean().optional(),
|
|
86725
|
+
failedAccounts: external_exports.array(external_exports.string()).optional()
|
|
86703
86726
|
}
|
|
86704
86727
|
},
|
|
86705
86728
|
withErrorHandling(async ({ account }) => {
|
|
@@ -86721,6 +86744,7 @@ ${list2}`, structured3);
|
|
|
86721
86744
|
}
|
|
86722
86745
|
const configs = resolveImapConfigs();
|
|
86723
86746
|
const rows = [];
|
|
86747
|
+
const failedAccounts = [];
|
|
86724
86748
|
for (const config2 of configs) {
|
|
86725
86749
|
try {
|
|
86726
86750
|
const boxes = await imapListMailboxes({ config: config2 });
|
|
@@ -86734,11 +86758,18 @@ ${list2}`, structured3);
|
|
|
86734
86758
|
}
|
|
86735
86759
|
} catch (e) {
|
|
86736
86760
|
console.error(`IMAP list-mailboxes failed for "${config2.accountLabel}": ${String(e)}`);
|
|
86761
|
+
failedAccounts.push(config2.accountLabel);
|
|
86737
86762
|
}
|
|
86738
86763
|
}
|
|
86739
86764
|
const { appleScriptOnly } = partitionAccountsForCounts(mailManager.listAccounts(), configs);
|
|
86740
86765
|
for (const acct of appleScriptOnly) {
|
|
86741
|
-
|
|
86766
|
+
const checked = mailManager.listMailboxesChecked(acct.name);
|
|
86767
|
+
if (checked.failed) {
|
|
86768
|
+
console.error(`list-mailboxes failed for "${acct.name}": ${checked.error}`);
|
|
86769
|
+
failedAccounts.push(acct.name);
|
|
86770
|
+
continue;
|
|
86771
|
+
}
|
|
86772
|
+
for (const mb of checked.mailboxes) {
|
|
86742
86773
|
rows.push({
|
|
86743
86774
|
name: `${acct.name}/${mb.name}`,
|
|
86744
86775
|
account: acct.name,
|
|
@@ -86747,13 +86778,34 @@ ${list2}`, structured3);
|
|
|
86747
86778
|
});
|
|
86748
86779
|
}
|
|
86749
86780
|
}
|
|
86750
|
-
const
|
|
86751
|
-
|
|
86781
|
+
const partial2 = failedAccounts.length > 0;
|
|
86782
|
+
const structured2 = {
|
|
86783
|
+
mailboxes: rows,
|
|
86784
|
+
count: rows.length,
|
|
86785
|
+
...partial2 ? { partial: partial2, failedAccounts } : {}
|
|
86786
|
+
};
|
|
86787
|
+
const caveat = partial2 ? `
|
|
86788
|
+
|
|
86789
|
+
PARTIAL \u2014 could not read: ${failedAccounts.join(", ")}. This list is incomplete.` : "";
|
|
86790
|
+
if (rows.length === 0) {
|
|
86791
|
+
return partial2 ? errorResponse(
|
|
86792
|
+
`Could not list mailboxes from any source. Failed: ${failedAccounts.join(", ")}.`
|
|
86793
|
+
) : successResponse("No mailboxes found", structured2);
|
|
86794
|
+
}
|
|
86752
86795
|
const list = rows.map((b) => ` - ${b.name} (${b.unreadCount} unread)`).join("\n");
|
|
86753
86796
|
return successResponse(`Found ${rows.length} mailbox(es):
|
|
86754
|
-
${list}`, structured2);
|
|
86797
|
+
${list}${caveat}`, structured2);
|
|
86798
|
+
}
|
|
86799
|
+
const { mailboxes, failed, error: error2 } = mailManager.listMailboxesChecked(account);
|
|
86800
|
+
if (failed) {
|
|
86801
|
+
return errorResponse(
|
|
86802
|
+
unlistableStoreError(
|
|
86803
|
+
account,
|
|
86804
|
+
error2,
|
|
86805
|
+
mailManager.listAccounts().map((a) => a.name)
|
|
86806
|
+
)
|
|
86807
|
+
);
|
|
86755
86808
|
}
|
|
86756
|
-
const mailboxes = mailManager.listMailboxes(account);
|
|
86757
86809
|
const structured = { mailboxes, count: mailboxes.length };
|
|
86758
86810
|
if (mailboxes.length === 0) {
|
|
86759
86811
|
return successResponse("No mailboxes found", structured);
|
package/package.json
CHANGED