apple-mail-mcp 2.20.13 → 2.20.14

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 +48 -7
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -65211,6 +65211,30 @@ function isInlineDisposition(headers) {
65211
65211
  if (!dispHeader) return false;
65212
65212
  return dispHeader.toLowerCase().startsWith("inline");
65213
65213
  }
65214
+ function extractContentId(headers) {
65215
+ const raw = getHeader(headers, "Content-ID");
65216
+ if (!raw) return null;
65217
+ const id = raw.replace(/^<+/, "").replace(/>+$/, "").trim().toLowerCase();
65218
+ return id || null;
65219
+ }
65220
+ function isEmbeddedResource(headers, htmlBodies) {
65221
+ if (!isInlineDisposition(headers)) return false;
65222
+ const cid = extractContentId(headers);
65223
+ if (!cid) return false;
65224
+ const needle = `cid:${cid}`;
65225
+ return htmlBodies.some((html) => html.includes(needle));
65226
+ }
65227
+ function collectHtmlBodies(parts) {
65228
+ const bodies = [];
65229
+ for (const part of parts) {
65230
+ if (extractMimeType(part.headers) !== "text/html") continue;
65231
+ const encoding = getHeader(part.headers, "Content-Transfer-Encoding");
65232
+ bodies.push(
65233
+ decodePartText(decodeBody(part.body, encoding), extractCharset(part.headers)).toLowerCase()
65234
+ );
65235
+ }
65236
+ return bodies;
65237
+ }
65214
65238
  function extractSize(headers) {
65215
65239
  const dispHeader = getHeader(headers, "Content-Disposition");
65216
65240
  if (dispHeader) {
@@ -65316,11 +65340,12 @@ function parseMimeAttachments(source) {
65316
65340
  const boundary = extractBoundary(source);
65317
65341
  if (!boundary) return [];
65318
65342
  const parts = walkLeafParts(source, boundary);
65343
+ const htmlBodies = collectHtmlBodies(parts);
65319
65344
  const attachments = [];
65320
65345
  for (const part of parts) {
65321
65346
  const filename = extractFilename(part.headers);
65322
65347
  if (!filename) continue;
65323
- if (isInlineDisposition(part.headers)) continue;
65348
+ if (isEmbeddedResource(part.headers, htmlBodies)) continue;
65324
65349
  const encoding = getHeader(part.headers, "Content-Transfer-Encoding");
65325
65350
  attachments.push({
65326
65351
  name: filename,
@@ -86686,13 +86711,29 @@ ${this.errorEmit(" ")}
86686
86711
  set msg to item 1 of matchingMsgs
86687
86712
  set outputText to ""
86688
86713
  set attCount to 0
86714
+ -- Each property is read inside its own try: \`MIME type of att\` throws
86715
+ -- "AppleEvent handler failed" for attachments Apple Mail itself composed,
86716
+ -- and one unguarded throw discards the whole list, so the MIME fallback
86717
+ -- answers "no attachments". An unreadable type or size degrades to a
86718
+ -- default; only a missing name drops the entry (it cannot be addressed).
86689
86719
  repeat with att in mail attachments of msg
86690
- set attName to name of att
86691
- set attType to MIME type of att
86692
- set attSize to file size of att as string
86693
- if attCount > 0 then set outputText to outputText & "${RECORD_SEP}"
86694
- set outputText to outputText & attName & "${FIELD_SEP}" & attType & "${FIELD_SEP}" & attSize
86695
- set attCount to attCount + 1
86720
+ set attName to ""
86721
+ set attType to "application/octet-stream"
86722
+ set attSize to "0"
86723
+ try
86724
+ set attName to name of att
86725
+ end try
86726
+ try
86727
+ set attType to MIME type of att
86728
+ end try
86729
+ try
86730
+ set attSize to file size of att as string
86731
+ end try
86732
+ if attName is not "" then
86733
+ if attCount > 0 then set outputText to outputText & "${RECORD_SEP}"
86734
+ set outputText to outputText & attName & "${FIELD_SEP}" & attType & "${FIELD_SEP}" & attSize
86735
+ set attCount to attCount + 1
86736
+ end if
86696
86737
  end repeat
86697
86738
  return outputText
86698
86739
  end if
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apple-mail-mcp",
3
- "version": "2.20.13",
3
+ "version": "2.20.14",
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",