apple-tools-mcp 3.3.1 → 3.3.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 +2 -0
- package/lib/noDashes.js +108 -0
- package/lib/writeTools.js +18 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -340,6 +340,8 @@ A dry run or a call that still needs confirm does not deliver anything. The resu
|
|
|
340
340
|
|
|
341
341
|
Responses name the action, ids, and recipients. They do not echo message bodies.
|
|
342
342
|
|
|
343
|
+
No dashes go out under your name. `mail_send`, `mail_draft`, `mail_reply`, `mail_forward` and `messages_send` rewrite dashes used as punctuation before Mail or Messages sees the text: an em dash or en dash becomes a comma ("to" between two numbers, nothing at the start or end of a line), and a hyphen with a space on each side becomes a comma. Hyphens inside names, identifiers, dates and URLs stay, and so does a hyphen that starts a line (a list bullet or the `-- ` signature line). The rewrite runs before the send claim and the Sent check, so both see the text that went out, and the result says how many it rewrote. A dry run reports it too.
|
|
344
|
+
|
|
343
345
|
A missing or malformed id or recipient is refused. Calendar times are local datetimes, `YYYY-MM-DD HH:MM`. Phrases like "next Tuesday" are rejected on writes.
|
|
344
346
|
|
|
345
347
|
### Mail
|
package/lib/noDashes.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No dashes in anything sent or drafted as the account owner.
|
|
3
|
+
*
|
|
4
|
+
* Mail and messages written for a person read as machine-written when they
|
|
5
|
+
* carry dashes used as punctuation, so every mail and Messages write rewrites
|
|
6
|
+
* them before anything reaches Mail or Messages:
|
|
7
|
+
* - an em dash, en dash or similar dash character becomes a comma (or nothing
|
|
8
|
+
* at the start or end of a line, and "to" between two numbers);
|
|
9
|
+
* - a hyphen (or two or three) with a space on each side becomes a comma.
|
|
10
|
+
* Hyphens inside names, identifiers, paths, URLs and dates are not punctuation
|
|
11
|
+
* and stay: Alexa-Echo-MCP, v1.1.0, 2026-11-10. A hyphen at the start of a line
|
|
12
|
+
* (a list bullet, or the "-- " signature line) also stays.
|
|
13
|
+
*
|
|
14
|
+
* Linear-time patterns only: these run on tool input.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const DASH_CHARS = "‒–—―⸺⸻︱︲﹘";
|
|
18
|
+
const DASH_RUN = new RegExp(`[ \\t]*[${DASH_CHARS}]+[ \\t]*`, "g");
|
|
19
|
+
const NUMBER_RANGE = /(\d)[‒–—](?=\d)/g;
|
|
20
|
+
const SPACED_HYPHEN = /(\S)[ \t]+(?:-{1,3}|[‐‑−])[ \t]+(?=\S)/g;
|
|
21
|
+
const TRAILING_HYPHEN = /(\S)[ \t]+(?:-{1,3}|[‐‑−])[ \t]*$/;
|
|
22
|
+
const HTML_DASH_ENTITY = /&(?:mdash|ndash|horbar);|&#(?:8210|8211|8212|8213|x201[2345]);/gi;
|
|
23
|
+
|
|
24
|
+
function rewriteLine(line) {
|
|
25
|
+
let count = 0;
|
|
26
|
+
let text = line.replace(NUMBER_RANGE, (_, digit) => {
|
|
27
|
+
count += 1;
|
|
28
|
+
return `${digit} to `;
|
|
29
|
+
});
|
|
30
|
+
text = text.replace(DASH_RUN, (match, offset, whole) => {
|
|
31
|
+
count += 1;
|
|
32
|
+
if (!whole.slice(0, offset).trim()) return match.match(/^[ \t]*/)[0];
|
|
33
|
+
if (!whole.slice(offset + match.length).trim()) return "";
|
|
34
|
+
return ", ";
|
|
35
|
+
});
|
|
36
|
+
text = text.replace(SPACED_HYPHEN, (_, before) => {
|
|
37
|
+
count += 1;
|
|
38
|
+
return `${before}, `;
|
|
39
|
+
});
|
|
40
|
+
text = text.replace(TRAILING_HYPHEN, (_, before) => {
|
|
41
|
+
count += 1;
|
|
42
|
+
return before;
|
|
43
|
+
});
|
|
44
|
+
if (count > 0) {
|
|
45
|
+
text = text.replace(/,[ \t]*,/g, ",").replace(/,[ \t]*([.;:!?)\]])/g, "$1").replace(/([(\[])[ \t]*,[ \t]*/g, "$1");
|
|
46
|
+
}
|
|
47
|
+
return { text, count };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {string} value
|
|
52
|
+
* @param {{ html?: boolean }} [opts] - html: also rewrite — style entities
|
|
53
|
+
* @returns {{ text: string, count: number }}
|
|
54
|
+
*/
|
|
55
|
+
export function rewriteDashes(value, { html = false } = {}) {
|
|
56
|
+
if (typeof value !== "string" || value === "") return { text: value ?? "", count: 0 };
|
|
57
|
+
const source = html ? value.replace(HTML_DASH_ENTITY, "—") : value;
|
|
58
|
+
let count = 0;
|
|
59
|
+
const lines = source.split("\n").map((line) => {
|
|
60
|
+
const out = rewriteLine(line);
|
|
61
|
+
count += out.count;
|
|
62
|
+
return out.text;
|
|
63
|
+
});
|
|
64
|
+
return count > 0 ? { text: lines.join("\n"), count } : { text: value, count: 0 };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The lines that would change, for callers that refuse instead of rewriting.
|
|
69
|
+
* @returns {string[]}
|
|
70
|
+
*/
|
|
71
|
+
export function findDashes(value, opts = {}) {
|
|
72
|
+
if (typeof value !== "string" || value === "") return [];
|
|
73
|
+
const source = opts.html ? value.replace(HTML_DASH_ENTITY, "—") : value;
|
|
74
|
+
return source.split("\n").filter((line) => rewriteLine(line).count > 0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Text fields of each write that goes out under the owner's name.
|
|
78
|
+
export const DASH_FIELDS = {
|
|
79
|
+
mail_send: ["subject", "body"],
|
|
80
|
+
mail_draft: ["subject", "body"],
|
|
81
|
+
mail_reply: ["body"],
|
|
82
|
+
mail_forward: ["body"],
|
|
83
|
+
messages_send: ["text"]
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {string} tool
|
|
88
|
+
* @param {object} args
|
|
89
|
+
* @returns {{ args: object, count: number }}
|
|
90
|
+
*/
|
|
91
|
+
export function withoutDashes(tool, args) {
|
|
92
|
+
const fields = DASH_FIELDS[tool];
|
|
93
|
+
if (!fields || !args || typeof args !== "object") return { args, count: 0 };
|
|
94
|
+
const html = String(args.body_format || "").toLowerCase() === "html";
|
|
95
|
+
const out = { ...args };
|
|
96
|
+
let count = 0;
|
|
97
|
+
for (const field of fields) {
|
|
98
|
+
if (typeof out[field] !== "string") continue;
|
|
99
|
+
const rewritten = rewriteDashes(out[field], { html: html && field === "body" });
|
|
100
|
+
out[field] = rewritten.text;
|
|
101
|
+
count += rewritten.count;
|
|
102
|
+
}
|
|
103
|
+
return { args: count > 0 ? out : args, count };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function dashNote(count) {
|
|
107
|
+
return ` Rewrote ${count} ${count === 1 ? "dash" : "dashes"} (em dash, en dash or spaced hyphen) as commas or words before writing; nothing goes out with dashes.`;
|
|
108
|
+
}
|
package/lib/writeTools.js
CHANGED
|
@@ -35,6 +35,7 @@ import { requestWriteViaBridge, probeSocket, defaultSocketPath } from "./writeBr
|
|
|
35
35
|
import { needsHostTccAdvice } from "./appleScript.js";
|
|
36
36
|
import { idempotentMailSend } from "./mailIdempotency.js";
|
|
37
37
|
import { mailSendReconcile, mailOutcome, fencedMailWrite } from "./mailReconciliation.js";
|
|
38
|
+
import { withoutDashes, dashNote } from "./noDashes.js";
|
|
38
39
|
|
|
39
40
|
const CONFIRM_PROPS = {
|
|
40
41
|
dry_run: { type: "boolean", description: "Preview only: report what would happen and change nothing (default false)" },
|
|
@@ -50,7 +51,7 @@ export const WRITE_TOOL_DEFINITIONS = [
|
|
|
50
51
|
// ============ MAIL WRITES ============
|
|
51
52
|
{
|
|
52
53
|
name: "mail_send",
|
|
53
|
-
description: "Send an email through Mail.app. Success requires Sent/Outbox verification, not merely an AppleScript return. Multiple recipients require confirm=true. Durable claims never expire uncertainty or automatically retry; changing/removing a key cannot bypass pending or terminal not_sent lineage. Read structuredContent.mail_send: suppression/replay is not a new delivery and cannot advance a page ledger. Legacy pending claims cannot be reconciled. A later retry after terminal not_sent needs separate protected single-use authorization, not confirm or a new key.",
|
|
54
|
+
description: "Send an email through Mail.app. Success requires Sent/Outbox verification, not merely an AppleScript return. Multiple recipients require confirm=true. Durable claims never expire uncertainty or automatically retry; changing/removing a key cannot bypass pending or terminal not_sent lineage. Read structuredContent.mail_send: suppression/replay is not a new delivery and cannot advance a page ledger. Legacy pending claims cannot be reconciled. A later retry after terminal not_sent needs separate protected single-use authorization, not confirm or a new key. Dashes used as punctuation (em dash, en dash, a spaced hyphen) are rewritten as commas or words before anything is written; hyphens inside names and identifiers stay.",
|
|
54
55
|
inputSchema: {
|
|
55
56
|
type: "object",
|
|
56
57
|
properties: {
|
|
@@ -94,7 +95,7 @@ export const WRITE_TOOL_DEFINITIONS = [
|
|
|
94
95
|
},
|
|
95
96
|
{
|
|
96
97
|
name: "mail_draft",
|
|
97
|
-
description: "Save an email to Drafts without sending it. Drafts are never delivered, so no recipient confirmation is required.",
|
|
98
|
+
description: "Save an email to Drafts without sending it. Drafts are never delivered, so no recipient confirmation is required. Dashes used as punctuation (em dash, en dash, a spaced hyphen) are rewritten as commas or words before anything is written; hyphens inside names and identifiers stay.",
|
|
98
99
|
inputSchema: {
|
|
99
100
|
type: "object",
|
|
100
101
|
properties: {
|
|
@@ -111,7 +112,7 @@ export const WRITE_TOOL_DEFINITIONS = [
|
|
|
111
112
|
},
|
|
112
113
|
{
|
|
113
114
|
name: "mail_reply",
|
|
114
|
-
description: "Reply to an existing email. The reply text is pasted above the quoted original in a visible Mail window (System Events focus on the message body, then Command-Up and clipboard paste — not Cmd-A, which would replace the quote; AppleScript content is not set because Mail 16 leaves it empty). reply_all=true fans out to every original recipient and requires confirm=true. A real send is verified in Sent/Outbox before success. A send hang is a timeout, not TCC, unless Mail reports -1743/-10004; hang recover uses In-Reply-To. Clients must Sent-check before retrying a timed-out send.",
|
|
115
|
+
description: "Reply to an existing email. The reply text is pasted above the quoted original in a visible Mail window (System Events focus on the message body, then Command-Up and clipboard paste — not Cmd-A, which would replace the quote; AppleScript content is not set because Mail 16 leaves it empty). reply_all=true fans out to every original recipient and requires confirm=true. A real send is verified in Sent/Outbox before success. A send hang is a timeout, not TCC, unless Mail reports -1743/-10004; hang recover uses In-Reply-To. Clients must Sent-check before retrying a timed-out send. Dashes used as punctuation (em dash, en dash, a spaced hyphen) are rewritten as commas or words before anything is written; hyphens inside names and identifiers stay.",
|
|
115
116
|
inputSchema: {
|
|
116
117
|
type: "object",
|
|
117
118
|
properties: {
|
|
@@ -126,7 +127,7 @@ export const WRITE_TOOL_DEFINITIONS = [
|
|
|
126
127
|
},
|
|
127
128
|
{
|
|
128
129
|
name: "mail_forward",
|
|
129
|
-
description: "Forward an existing email to new recipients. An optional note is pasted above the forwarded original in a visible Mail window (same System Events prepend as mail_reply; AppleScript content is not set). More than one recipient requires confirm=true. A real send is verified in Sent/Outbox before success. A send hang is a timeout, not TCC, unless Mail reports -1743/-10004; hang recover matches intended To plus Fwd: subject or original Message-ID. Clients must Sent-check before retrying a timed-out send.",
|
|
130
|
+
description: "Forward an existing email to new recipients. An optional note is pasted above the forwarded original in a visible Mail window (same System Events prepend as mail_reply; AppleScript content is not set). More than one recipient requires confirm=true. A real send is verified in Sent/Outbox before success. A send hang is a timeout, not TCC, unless Mail reports -1743/-10004; hang recover matches intended To plus Fwd: subject or original Message-ID. Clients must Sent-check before retrying a timed-out send. Dashes used as punctuation (em dash, en dash, a spaced hyphen) are rewritten as commas or words before anything is written; hyphens inside names and identifiers stay.",
|
|
130
131
|
inputSchema: {
|
|
131
132
|
type: "object",
|
|
132
133
|
properties: {
|
|
@@ -181,7 +182,7 @@ export const WRITE_TOOL_DEFINITIONS = [
|
|
|
181
182
|
// ============ MESSAGES WRITES ============
|
|
182
183
|
{
|
|
183
184
|
name: "messages_send",
|
|
184
|
-
description: "Send an iMessage or SMS. Address it with 'to' (E.164 phone numbers like +15551234567, or Apple ID emails) or with 'chat_id' (a chat GUID from chat.db, e.g. 'iMessage;-;+15551234567' or 'iMessage;+;chat123456'). Group chats and multiple recipients require confirm=true.",
|
|
185
|
+
description: "Send an iMessage or SMS. Address it with 'to' (E.164 phone numbers like +15551234567, or Apple ID emails) or with 'chat_id' (a chat GUID from chat.db, e.g. 'iMessage;-;+15551234567' or 'iMessage;+;chat123456'). Group chats and multiple recipients require confirm=true. Dashes used as punctuation (em dash, en dash, a spaced hyphen) are rewritten as commas or words before anything is written; hyphens inside names and identifiers stay.",
|
|
185
186
|
inputSchema: {
|
|
186
187
|
type: "object",
|
|
187
188
|
properties: {
|
|
@@ -402,9 +403,18 @@ export function executeWriteToolLocally(name, args = {}) {
|
|
|
402
403
|
return { ok: false, message: `Unknown write tool: ${name}`, unsupported: true };
|
|
403
404
|
}
|
|
404
405
|
try {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
// Every send and draft path (stdio, HTTP, the indexer's write bridge) ends here, so the
|
|
407
|
+
// dash rewrite runs once before claims, Sent checks and Mail or Messages see the text.
|
|
408
|
+
const { args: clean, count } = withoutDashes(name, args || {});
|
|
409
|
+
const run = () => {
|
|
410
|
+
if (name === "mail_send") return idempotentMailSend(clean, () => handler(clean));
|
|
411
|
+
if (name.startsWith("mail_") && name !== "mail_send_reconcile") return fencedMailWrite(() => handler(clean));
|
|
412
|
+
return handler(clean);
|
|
413
|
+
};
|
|
414
|
+
const result = run();
|
|
415
|
+
return count > 0 && result && typeof result.message === "string"
|
|
416
|
+
? { ...result, message: result.message + dashNote(count) }
|
|
417
|
+
: result;
|
|
408
418
|
} catch (e) {
|
|
409
419
|
return { ok: false, message: `${name} failed: ${e.message}` };
|
|
410
420
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apple-tools-mcp",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"description": "MCP server for semantic search and write actions across Apple Mail, Messages, Calendar, and Contacts. Speaks stdio (local) or bearer-token-authenticated Streamable HTTP (LAN / Tailscale).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|