apple-mail-mcp 2.10.0 → 2.10.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/README.md CHANGED
@@ -746,7 +746,7 @@ Flag or unflag a message. `flag-message` optionally takes a flag **color**; `unf
746
746
  | `id` | string | Yes | Message ID |
747
747
  | `color` | string | No | (`flag-message` only) Flag color: `red`, `orange`, `yellow`, `green`, `blue`, `purple`, `gray` (`grey` accepted). Omit for Mail's default flag. |
748
748
 
749
- **Flag colors** are an Apple Mail feature, applied via AppleScript as the message's `flag index` (0 red, 1 orange, 2 yellow, 3 green, 4 blue, 5 purple, 6 gray) the same property a Mail smart mailbox can match on. For an **IMAP-routed** message id (`imap:…`) the flag is still set, but the color is **not** applied, because IMAP's `\Flagged` flag is colorless. To color a flag, use the message's AppleScript (numeric) id.
749
+ **Flag colors** are an Apple Mail feature the message's `flag index` (0 red, 1 orange, 2 yellow, 3 green, 4 blue, 5 purple, 6 gray), which is the property a Mail smart mailbox can match on. **The color is applied on both routes** (since 2.10.0): AppleScript sets the flag index directly, and for an **IMAP-routed** id (`imap:…`) the color is written as Mail.app's `$MailFlagBit0/1/2` keywords a 3-bit field holding the same palette index. `\Flagged` on its own really is colorless, but those keywords ride alongside it in an ordinary `UID STORE`, so a smart mailbox keyed on flag color matches an IMAP-flagged message too. You do **not** need to resolve to a numeric id just to color a flag.
750
750
 
751
751
  ---
752
752
 
@@ -829,7 +829,7 @@ All batch operations accept an array of message IDs (max 100 per batch) and retu
829
829
  | Parameter | Type | Required | Description |
830
830
  |-----------|------|----------|-------------|
831
831
  | `ids` | string[] | Yes | Message IDs (max 100) |
832
- | `color` | string | No | (`batch-flag-messages` only) Flag color applied to AppleScript (numeric) ids — see [`flag-message`](#flag-message--unflag-message). Any `imap:` ids in the batch are flagged but not colored. |
832
+ | `color` | string | No | (`batch-flag-messages` only) Flag color — see [`flag-message`](#flag-message--unflag-message). Applied on both routes, so a mixed batch of numeric and `imap:` ids all end up colored. |
833
833
 
834
834
  ---
835
835
 
package/build/index.js CHANGED
@@ -3110,9 +3110,9 @@ var require_data = __commonJS({
3110
3110
  }
3111
3111
  });
3112
3112
 
3113
- // node_modules/.pnpm/fast-uri@3.1.4/node_modules/fast-uri/lib/utils.js
3113
+ // node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js
3114
3114
  var require_utils = __commonJS({
3115
- "node_modules/.pnpm/fast-uri@3.1.4/node_modules/fast-uri/lib/utils.js"(exports, module) {
3115
+ "node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js"(exports, module) {
3116
3116
  "use strict";
3117
3117
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3118
3118
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
@@ -3423,9 +3423,9 @@ var require_utils = __commonJS({
3423
3423
  }
3424
3424
  });
3425
3425
 
3426
- // node_modules/.pnpm/fast-uri@3.1.4/node_modules/fast-uri/lib/schemes.js
3426
+ // node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js
3427
3427
  var require_schemes = __commonJS({
3428
- "node_modules/.pnpm/fast-uri@3.1.4/node_modules/fast-uri/lib/schemes.js"(exports, module) {
3428
+ "node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js"(exports, module) {
3429
3429
  "use strict";
3430
3430
  var { isUUID } = require_utils();
3431
3431
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
@@ -3633,9 +3633,9 @@ var require_schemes = __commonJS({
3633
3633
  }
3634
3634
  });
3635
3635
 
3636
- // node_modules/.pnpm/fast-uri@3.1.4/node_modules/fast-uri/index.js
3636
+ // node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js
3637
3637
  var require_fast_uri = __commonJS({
3638
- "node_modules/.pnpm/fast-uri@3.1.4/node_modules/fast-uri/index.js"(exports, module) {
3638
+ "node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js"(exports, module) {
3639
3639
  "use strict";
3640
3640
  var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3641
3641
  var { SCHEMES, getSchemeHandler } = require_schemes();
@@ -3651,7 +3651,12 @@ var require_fast_uri = __commonJS({
3651
3651
  }
3652
3652
  function resolve2(baseURI, relativeURI, options) {
3653
3653
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3654
- const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
3654
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
3655
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
3656
+ if (baseMalformed || relativeMalformed) {
3657
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3658
+ }
3659
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
3655
3660
  schemelessOptions.skipEscape = true;
3656
3661
  return serialize(resolved, schemelessOptions);
3657
3662
  }
@@ -3777,6 +3782,7 @@ var require_fast_uri = __commonJS({
3777
3782
  }
3778
3783
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3779
3784
  var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
3785
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
3780
3786
  function getParseError(parsed, matches) {
3781
3787
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
3782
3788
  return 'URI path must start with "/" when authority is present.';
@@ -3811,6 +3817,20 @@ var require_fast_uri = __commonJS({
3811
3817
  parsed.error = "URI authority must not contain a literal backslash.";
3812
3818
  malformedAuthorityOrPort = true;
3813
3819
  }
3820
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
3821
+ if (introducerMatch !== null) {
3822
+ const region = introducerMatch[1];
3823
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
3824
+ if (normalizedRegion.length >= 2) {
3825
+ if (normalizedRegion.slice(0, 2) !== "//") {
3826
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
3827
+ malformedAuthorityOrPort = true;
3828
+ } else if (region.length !== normalizedRegion.length) {
3829
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
3830
+ malformedAuthorityOrPort = true;
3831
+ }
3832
+ }
3833
+ }
3814
3834
  const matches = uri.match(URI_PARSE);
3815
3835
  if (matches) {
3816
3836
  parsed.scheme = matches[1];
@@ -78120,9 +78140,13 @@ var AppleMailManager = class {
78120
78140
  /**
78121
78141
  * Resolve a message's numeric Mail.app id from its RFC822 Message-ID (the
78122
78142
  * backend-independent join key). This bridges an `imap:` id to the numeric id
78123
- * required to apply a flag *color* IMAP flags are colorless, so a smart
78124
- * mailbox keyed on flag color can only ever match a message flagged via the
78125
- * AppleScript numeric-id path.
78143
+ * required by the AppleScript-only tools`reply-to-message` and
78144
+ * `forward-message`.
78145
+ *
78146
+ * Note: flag *color* no longer needs this (since 2.10.0). Mail.app stores the
78147
+ * color as the `$MailFlagBit0/1/2` keywords, which ride alongside `\Flagged`
78148
+ * in an ordinary `UID STORE`, so flag-message/batch-flag-messages color an
78149
+ * `imap:` id directly and a smart mailbox keyed on flag color matches it.
78126
78150
  *
78127
78151
  * The Message-ID is matched both bracketless and `<bracketed>` (Mail returns
78128
78152
  * it bracketless; IMAP envelopes carry the brackets). When `accountName` is
@@ -81490,7 +81514,7 @@ var FLAG_COLOR_INDEX = {
81490
81514
  grey: 6
81491
81515
  };
81492
81516
  var FLAG_COLOR_SCHEMA = external_exports.enum(["red", "orange", "yellow", "green", "blue", "purple", "gray", "grey"]).optional().describe(
81493
- "Optional flag color (Apple Mail palette: red, orange, yellow, green, blue, purple, gray \u2014 'grey' accepted). Omit for Mail's default flag. Colors are applied via Mail.app (AppleScript); for an IMAP-routed message id the flag is set but the color is not applied (IMAP flags are colorless)."
81517
+ "Optional flag color (Apple Mail palette: red, orange, yellow, green, blue, purple, gray \u2014 'grey' accepted). Omit for Mail's default flag. The color is applied on both routes: AppleScript sets the flag index, and IMAP writes the equivalent $MailFlagBit0/1/2 keywords Mail.app reads \u2014 so a smart mailbox keyed on flag color matches either way."
81494
81518
  );
81495
81519
  var DATE_FILTER_SCHEMA = external_exports.string().regex(
81496
81520
  /^[a-zA-Z0-9 ,/\-:]+$/,
@@ -82315,10 +82339,11 @@ server.registerTool(
82315
82339
  id,
82316
82340
  ...color ? { color, colorApplied: true } : {}
82317
82341
  }) : errorResponse(`Failed to flag message "${id}"`),
82318
- // IMAP path: the flag is set, but flag colors are a Mail.app-only feature.
82319
- ok: color ? `Message flagged. Note: the "${color}" color was not applied \u2014 this is an IMAP-routed message and IMAP flags are colorless.` : "Message flagged",
82342
+ // IMAP path: imapFlagMessage writes the color as $MailFlagBit0/1/2 keywords,
82343
+ // so the outcome matches the AppleScript route above.
82344
+ ok: color ? `Message flagged (${color})` : "Message flagged",
82320
82345
  fail: `Failed to flag message "${id}"`,
82321
- structured: color ? { ok: true, id, color, colorApplied: false } : { ok: true, id }
82346
+ structured: color ? { ok: true, id, color, colorApplied: true } : { ok: true, id }
82322
82347
  });
82323
82348
  }, "Error flagging message")
82324
82349
  );
@@ -82514,7 +82539,7 @@ server.registerTool(
82514
82539
  server.registerTool(
82515
82540
  "batch-flag-messages",
82516
82541
  {
82517
- description: "Use when: flagging multiple messages (1\u2013100 ids) in one call, optionally with a color (red/orange/yellow/green/blue/purple/gray).\nReturns: counts of how many were flagged and how many failed.\nDo not use when: flagging just one (use flag-message) or removing flags (use batch-unflag-messages). Get the ids from search-messages or list-messages first.\nNote: flag colors are applied via Mail.app (AppleScript); any IMAP-routed ids in the batch are flagged but not colored (IMAP flags are colorless).",
82542
+ description: "Use when: flagging multiple messages (1\u2013100 ids) in one call, optionally with a color (red/orange/yellow/green/blue/purple/gray).\nReturns: counts of how many were flagged and how many failed.\nDo not use when: flagging just one (use flag-message) or removing flags (use batch-unflag-messages). Get the ids from search-messages or list-messages first.\nNote: the color is applied on both routes \u2014 AppleScript sets the flag index, IMAP writes the equivalent $MailFlagBit0/1/2 keywords Mail.app reads \u2014 so a mixed batch of numeric and `imap:` ids all end up colored.",
82518
82543
  inputSchema: {
82519
82544
  ids: BATCH_IDS_SCHEMA,
82520
82545
  color: FLAG_COLOR_SCHEMA
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apple-mail-mcp",
3
- "version": "2.10.0",
3
+ "version": "2.10.2",
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",