@heznpc/imcp 1.0.0 → 1.2.0
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 +179 -212
- package/dist/calendar/scripts.js +11 -8
- package/dist/calendar/scripts.js.map +1 -1
- package/dist/cli/doctor.d.ts +7 -0
- package/dist/cli/doctor.js +135 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/init.d.ts +8 -0
- package/dist/cli/init.js +145 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cross/tools.d.ts +7 -0
- package/dist/cross/tools.js +81 -0
- package/dist/cross/tools.js.map +1 -0
- package/dist/finder/scripts.js +3 -3
- package/dist/finder/tools.js +1 -1
- package/dist/finder/tools.js.map +1 -1
- package/dist/index.js +105 -22
- package/dist/index.js.map +1 -1
- package/dist/mail/scripts.d.ts +2 -0
- package/dist/mail/scripts.js +42 -0
- package/dist/mail/scripts.js.map +1 -1
- package/dist/mail/tools.d.ts +1 -1
- package/dist/mail/tools.js +45 -2
- package/dist/mail/tools.js.map +1 -1
- package/dist/messages/scripts.js +56 -19
- package/dist/messages/scripts.js.map +1 -1
- package/dist/messages/tools.d.ts +1 -1
- package/dist/messages/tools.js +6 -1
- package/dist/messages/tools.js.map +1 -1
- package/dist/shared/config.d.ts +23 -0
- package/dist/shared/config.js +112 -1
- package/dist/shared/config.js.map +1 -1
- package/dist/shared/hitl-guard.d.ts +8 -0
- package/dist/shared/hitl-guard.js +39 -0
- package/dist/shared/hitl-guard.js.map +1 -0
- package/dist/shared/hitl.d.ts +16 -0
- package/dist/shared/hitl.js +131 -0
- package/dist/shared/hitl.js.map +1 -0
- package/dist/shared/resources.d.ts +10 -1
- package/dist/shared/resources.js +199 -45
- package/dist/shared/resources.js.map +1 -1
- package/dist/shared/setup.d.ts +2 -1
- package/dist/shared/setup.js +23 -14
- package/dist/shared/setup.js.map +1 -1
- package/dist/shortcuts/prompts.d.ts +2 -0
- package/dist/shortcuts/prompts.js +148 -0
- package/dist/shortcuts/prompts.js.map +1 -0
- package/dist/system/scripts.js +4 -2
- package/dist/system/scripts.js.map +1 -1
- package/dist/system/tools.js +2 -2
- package/dist/system/tools.js.map +1 -1
- package/dist/tv/scripts.d.ts +6 -0
- package/dist/tv/scripts.js +121 -0
- package/dist/tv/scripts.js.map +1 -0
- package/dist/tv/tools.d.ts +3 -0
- package/dist/tv/tools.js +95 -0
- package/dist/tv/tools.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitl.js","sourceRoot":"","sources":["../../src/shared/hitl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAU,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmBzC,MAAM,OAAO,UAAU;IAOD;IANZ,MAAM,GAAkB,IAAI,CAAC;IAC7B,OAAO,GAAG,IAAI,GAAG,EAAoD,CAAC;IACtE,MAAM,GAAG,EAAE,CAAC;IACZ,UAAU,GAAG,KAAK,CAAC;IACnB,cAAc,GAAyB,IAAI,CAAC;IAEpD,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C,KAAK,CAAC,eAAe,CACnB,IAAY,EACZ,IAA6B,EAC7B,WAAoB,EACpB,SAAkB;QAElB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,KAAK,CAAC,gCAAgC,IAAI,CAAC,MAAM,CAAC,UAAU,eAAe,IAAI,GAAG,CAAC,CAAC;YAC5F,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;QACxB,MAAM,OAAO,GAAgB;YAC3B,EAAE;YACF,IAAI,EAAE,cAAc;YACpB,IAAI;YACJ,IAAI;YACJ,WAAW;YACX,SAAS;SACV,CAAC;QAEF,OAA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,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { ImcpConfig } from "./config.js";
|
|
3
|
+
interface DepthConfig {
|
|
4
|
+
notes: number;
|
|
5
|
+
events: number;
|
|
6
|
+
reminders: number;
|
|
7
|
+
previewLen: number;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Register MCP resources that expose live Apple data for direct client reads.
|
|
4
11
|
*/
|
|
5
|
-
export declare function registerResources(server: McpServer): void;
|
|
12
|
+
export declare function registerResources(server: McpServer, config?: ImcpConfig): void;
|
|
13
|
+
export declare function buildSnapshot(enabled: (mod: string) => boolean, depth: DepthConfig | string): Promise<string>;
|
|
14
|
+
export {};
|
package/dist/shared/resources.js
CHANGED
|
@@ -1,61 +1,215 @@
|
|
|
1
1
|
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { runJxa } from "./jxa.js";
|
|
3
|
-
import { listEventsScript } from "../calendar/scripts.js";
|
|
3
|
+
import { listEventsScript, getUpcomingEventsScript } from "../calendar/scripts.js";
|
|
4
4
|
import { listRemindersScript } from "../reminders/scripts.js";
|
|
5
|
+
import { nowPlayingScript } from "../music/scripts.js";
|
|
6
|
+
import { getClipboardScript, getFrontmostAppScript } from "../system/scripts.js";
|
|
7
|
+
import { getUnreadCountScript } from "../mail/scripts.js";
|
|
8
|
+
import { isModuleEnabled } from "./config.js";
|
|
9
|
+
const DEPTH = {
|
|
10
|
+
brief: { notes: 3, events: 5, reminders: 3, previewLen: 80 },
|
|
11
|
+
standard: { notes: 5, events: 10, reminders: 5, previewLen: 200 },
|
|
12
|
+
full: { notes: 15, events: 30, reminders: 15, previewLen: 500 },
|
|
13
|
+
};
|
|
5
14
|
/**
|
|
6
15
|
* Register MCP resources that expose live Apple data for direct client reads.
|
|
7
16
|
*/
|
|
8
|
-
export function registerResources(server) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
export function registerResources(server, config) {
|
|
18
|
+
const enabled = (mod) => !config || isModuleEnabled(config, mod);
|
|
19
|
+
// ── Notes ──
|
|
20
|
+
if (enabled("notes")) {
|
|
21
|
+
server.registerResource("recent-notes", "notes://recent", { description: "10 most recently modified Apple Notes", mimeType: "application/json" }, async (uri) => ({
|
|
22
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(await fetchRecentNotes(10), null, 2) }],
|
|
23
|
+
}));
|
|
24
|
+
server.registerResource("recent-notes-count", new ResourceTemplate("notes://recent/{count}", { list: undefined }), { description: "Recently modified Apple Notes (max 50)", mimeType: "application/json" }, async (uri, variables) => {
|
|
25
|
+
const raw = Array.isArray(variables.count) ? variables.count[0] : variables.count;
|
|
26
|
+
const count = Math.max(1, Math.min(Number(raw) || 10, 50));
|
|
27
|
+
return {
|
|
28
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(await fetchRecentNotes(count), null, 2) }],
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// ── Calendar ──
|
|
33
|
+
if (enabled("calendar")) {
|
|
34
|
+
server.registerResource("today-events", "calendar://today", { description: "Today's Apple Calendar events, sorted by start time", mimeType: "application/json" }, async (uri) => {
|
|
35
|
+
const today = new Date();
|
|
36
|
+
const start = new Date(today.getFullYear(), today.getMonth(), today.getDate()).toISOString();
|
|
37
|
+
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1).toISOString();
|
|
38
|
+
const result = await runJxa(listEventsScript(start, end, 999, 0));
|
|
39
|
+
return {
|
|
40
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(result.events, null, 2) }],
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
server.registerResource("upcoming-events", "calendar://upcoming", { description: "Upcoming Apple Calendar events for the next 7 days", mimeType: "application/json" }, async (uri) => {
|
|
44
|
+
const result = await runJxa(getUpcomingEventsScript(50));
|
|
45
|
+
return {
|
|
46
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(result.events, null, 2) }],
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// ── Reminders ──
|
|
51
|
+
if (enabled("reminders")) {
|
|
52
|
+
server.registerResource("due-reminders", "reminders://due", { description: "Apple Reminders that are currently due or overdue", mimeType: "application/json" }, async (uri) => {
|
|
53
|
+
const all = await runJxa(listRemindersScript(undefined, false));
|
|
54
|
+
const now = new Date();
|
|
55
|
+
const due = all
|
|
56
|
+
.filter((r) => r.dueDate && new Date(r.dueDate) <= now)
|
|
57
|
+
.sort((a, b) => new Date(a.dueDate).getTime() - new Date(b.dueDate).getTime());
|
|
58
|
+
return {
|
|
59
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(due, null, 2) }],
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
server.registerResource("today-reminders", "reminders://today", { description: "Apple Reminders due today (incomplete only)", mimeType: "application/json" }, async (uri) => {
|
|
63
|
+
const all = await runJxa(listRemindersScript(undefined, false));
|
|
64
|
+
const today = new Date();
|
|
65
|
+
const startOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();
|
|
66
|
+
const endOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1).getTime();
|
|
67
|
+
const todayItems = all.filter((r) => {
|
|
68
|
+
if (!r.dueDate)
|
|
69
|
+
return false;
|
|
70
|
+
const t = new Date(r.dueDate).getTime();
|
|
71
|
+
return t >= startOfDay && t < endOfDay;
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(todayItems, null, 2) }],
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// ── Music ──
|
|
79
|
+
if (enabled("music")) {
|
|
80
|
+
server.registerResource("now-playing", "music://now-playing", { description: "Currently playing track in Apple Music", mimeType: "application/json" }, async (uri) => {
|
|
81
|
+
const result = await runJxa(nowPlayingScript());
|
|
82
|
+
return {
|
|
83
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(result, null, 2) }],
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// ── System ──
|
|
88
|
+
if (enabled("system")) {
|
|
89
|
+
server.registerResource("clipboard", "system://clipboard", { description: "Current macOS clipboard contents", mimeType: "application/json" }, async (uri) => {
|
|
90
|
+
const result = await runJxa(getClipboardScript());
|
|
91
|
+
return {
|
|
92
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(result, null, 2) }],
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// ── Mail ──
|
|
97
|
+
if (enabled("mail")) {
|
|
98
|
+
server.registerResource("unread-mail", "mail://unread", { description: "Unread email count across all mailboxes", mimeType: "application/json" }, async (uri) => {
|
|
99
|
+
const result = await runJxa(getUnreadCountScript());
|
|
100
|
+
return {
|
|
101
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(result, null, 2) }],
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// ── Context Snapshot ──
|
|
106
|
+
server.registerResource("context-snapshot", "context://snapshot", {
|
|
107
|
+
description: "Unified context from all enabled Apple apps — calendar, reminders, notes, mail, music, system — in a single read. Default depth: standard.",
|
|
12
108
|
mimeType: "application/json",
|
|
13
|
-
}, async (uri) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
// ── notes://recent/{count} — template: configurable count ──
|
|
20
|
-
server.registerResource("recent-notes-count", new ResourceTemplate("notes://recent/{count}", { list: undefined }), {
|
|
21
|
-
description: "List of recently modified Apple Notes. Use {count} to control how many are returned (max 50).",
|
|
109
|
+
}, async (uri) => ({
|
|
110
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: await buildSnapshot(enabled, DEPTH.standard) }],
|
|
111
|
+
}));
|
|
112
|
+
server.registerResource("context-snapshot-depth", new ResourceTemplate("context://snapshot/{depth}", { list: undefined }), {
|
|
113
|
+
description: "Unified context snapshot with configurable depth: brief (~500 tokens), standard (~2-4k), full (~5k+).",
|
|
22
114
|
mimeType: "application/json",
|
|
23
115
|
}, async (uri, variables) => {
|
|
24
|
-
const raw = Array.isArray(variables.
|
|
25
|
-
const
|
|
26
|
-
const notes = await fetchRecentNotes(count);
|
|
27
|
-
return {
|
|
28
|
-
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(notes, null, 2) }],
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
// ── calendar://today — today's calendar events (reuses listEventsScript) ──
|
|
32
|
-
server.registerResource("today-events", "calendar://today", {
|
|
33
|
-
description: "Today's Apple Calendar events, sorted by start time",
|
|
34
|
-
mimeType: "application/json",
|
|
35
|
-
}, async (uri) => {
|
|
36
|
-
const today = new Date();
|
|
37
|
-
const start = new Date(today.getFullYear(), today.getMonth(), today.getDate()).toISOString();
|
|
38
|
-
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1).toISOString();
|
|
39
|
-
const result = await runJxa(listEventsScript(start, end, 999, 0));
|
|
40
|
-
return {
|
|
41
|
-
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(result.events, null, 2) }],
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
// ── reminders://due — currently due or overdue reminders (reuses listRemindersScript) ──
|
|
45
|
-
server.registerResource("due-reminders", "reminders://due", {
|
|
46
|
-
description: "Apple Reminders that are currently due or overdue",
|
|
47
|
-
mimeType: "application/json",
|
|
48
|
-
}, async (uri) => {
|
|
49
|
-
const all = await runJxa(listRemindersScript(undefined, false));
|
|
50
|
-
const now = new Date();
|
|
51
|
-
const due = all
|
|
52
|
-
.filter((r) => r.dueDate && new Date(r.dueDate) <= now)
|
|
53
|
-
.sort((a, b) => new Date(a.dueDate).getTime() - new Date(b.dueDate).getTime());
|
|
116
|
+
const raw = (Array.isArray(variables.depth) ? variables.depth[0] : variables.depth);
|
|
117
|
+
const dc = DEPTH[raw] ?? DEPTH.standard;
|
|
54
118
|
return {
|
|
55
|
-
contents: [{ uri: uri.href, mimeType: "application/json", text:
|
|
119
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: await buildSnapshot(enabled, dc) }],
|
|
56
120
|
};
|
|
57
121
|
});
|
|
58
122
|
}
|
|
123
|
+
export async function buildSnapshot(enabled, depth) {
|
|
124
|
+
const dc = typeof depth === "string" ? (DEPTH[depth] ?? DEPTH.standard) : depth;
|
|
125
|
+
const depthName = dc === DEPTH.brief ? "brief" : dc === DEPTH.full ? "full" : "standard";
|
|
126
|
+
// Build parallel fetchers for each enabled module
|
|
127
|
+
const tasks = [];
|
|
128
|
+
if (enabled("calendar")) {
|
|
129
|
+
tasks.push({
|
|
130
|
+
key: "calendar",
|
|
131
|
+
promise: (async () => {
|
|
132
|
+
const today = new Date();
|
|
133
|
+
const start = new Date(today.getFullYear(), today.getMonth(), today.getDate()).toISOString();
|
|
134
|
+
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1).toISOString();
|
|
135
|
+
const result = await runJxa(listEventsScript(start, end, dc.events, 0));
|
|
136
|
+
return { todayCount: result.events.length, events: result.events.slice(0, dc.events) };
|
|
137
|
+
})(),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (enabled("reminders")) {
|
|
141
|
+
tasks.push({
|
|
142
|
+
key: "reminders",
|
|
143
|
+
promise: (async () => {
|
|
144
|
+
const all = await runJxa(listRemindersScript(undefined, false));
|
|
145
|
+
const now = new Date();
|
|
146
|
+
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
147
|
+
const tomorrow = new Date(today.getTime() + 86400000);
|
|
148
|
+
const overdue = all.filter((r) => r.dueDate && new Date(r.dueDate) < today);
|
|
149
|
+
const dueToday = all.filter((r) => {
|
|
150
|
+
if (!r.dueDate)
|
|
151
|
+
return false;
|
|
152
|
+
const t = new Date(r.dueDate).getTime();
|
|
153
|
+
return t >= today.getTime() && t < tomorrow.getTime();
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
overdueCount: overdue.length,
|
|
157
|
+
dueTodayCount: dueToday.length,
|
|
158
|
+
totalIncomplete: all.length,
|
|
159
|
+
overdue: overdue.slice(0, dc.reminders),
|
|
160
|
+
dueToday: dueToday.slice(0, dc.reminders),
|
|
161
|
+
};
|
|
162
|
+
})(),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (enabled("notes")) {
|
|
166
|
+
tasks.push({
|
|
167
|
+
key: "notes",
|
|
168
|
+
promise: (async () => {
|
|
169
|
+
const notes = await fetchRecentNotes(dc.notes);
|
|
170
|
+
return {
|
|
171
|
+
recentCount: notes.length,
|
|
172
|
+
notes: notes.map((n) => ({ ...n, preview: n.preview.substring(0, dc.previewLen) })),
|
|
173
|
+
};
|
|
174
|
+
})(),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (enabled("mail")) {
|
|
178
|
+
tasks.push({
|
|
179
|
+
key: "mail",
|
|
180
|
+
promise: runJxa(getUnreadCountScript()),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (enabled("music")) {
|
|
184
|
+
tasks.push({
|
|
185
|
+
key: "music",
|
|
186
|
+
promise: runJxa(nowPlayingScript()).catch(() => ({ playerState: "unavailable" })),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
if (enabled("system")) {
|
|
190
|
+
tasks.push({
|
|
191
|
+
key: "system",
|
|
192
|
+
promise: (async () => {
|
|
193
|
+
const [clipboard, frontApp] = await Promise.all([
|
|
194
|
+
runJxa(getClipboardScript()).catch(() => null),
|
|
195
|
+
runJxa(getFrontmostAppScript()).catch(() => null),
|
|
196
|
+
]);
|
|
197
|
+
return { clipboard, frontmostApp: frontApp };
|
|
198
|
+
})(),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
// Execute all in parallel
|
|
202
|
+
const results = await Promise.allSettled(tasks.map((t) => t.promise));
|
|
203
|
+
const snapshot = {
|
|
204
|
+
timestamp: new Date().toISOString(),
|
|
205
|
+
depth: depthName,
|
|
206
|
+
};
|
|
207
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
208
|
+
const r = results[i];
|
|
209
|
+
snapshot[tasks[i].key] = r.status === "fulfilled" ? r.value : { error: "unavailable" };
|
|
210
|
+
}
|
|
211
|
+
return JSON.stringify(snapshot, null, 2);
|
|
212
|
+
}
|
|
59
213
|
async function fetchRecentNotes(count) {
|
|
60
214
|
return runJxa(`
|
|
61
215
|
const Notes = Application('Notes');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/shared/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IACjD,yEAAyE;IACzE,MAAM,CAAC,gBAAgB,CACrB,cAAc,EACd,gBAAgB,EAChB;QACE,WAAW,EAAE,mDAAmD;QAChE,QAAQ,EAAE,kBAAkB;KAC7B,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;QACZ,MAAM,K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,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtE,MAAM,QAAQ,GAAoB;QAChC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,KAAK,EAAE,SAAS;KACjB,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACrB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IACzF,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,KAAa;IAC3C,OAAO,MAAM,CAAe;;;;;;;mCAOK,KAAK;;;;;;;;;;;;GAYrC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/shared/setup.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
|
|
2
|
+
import { ImcpConfig } from "./config.js";
|
|
3
|
+
export declare function registerSetupTools(server: McpServer, config?: ImcpConfig): void;
|
package/dist/shared/setup.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { runJxa } from "./jxa.js";
|
|
2
2
|
import { ok } from "./result.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
{ name: "
|
|
7
|
-
{ name: "
|
|
8
|
-
{ name: "
|
|
9
|
-
{ name: "
|
|
10
|
-
{ name: "
|
|
11
|
-
{ name: "
|
|
12
|
-
{
|
|
13
|
-
{ name: "
|
|
3
|
+
import { isModuleEnabled } from "./config.js";
|
|
4
|
+
/** Map: module name → macOS app name + permission-probe script */
|
|
5
|
+
const MODULE_APP_MAP = [
|
|
6
|
+
{ module: "notes", name: "Notes", script: "const Notes = Application('Notes'); JSON.stringify({app: 'Notes', accessible: true});" },
|
|
7
|
+
{ module: "reminders", name: "Reminders", script: "const Reminders = Application('Reminders'); JSON.stringify({app: 'Reminders', accessible: true});" },
|
|
8
|
+
{ module: "calendar", name: "Calendar", script: "const Calendar = Application('Calendar'); JSON.stringify({app: 'Calendar', accessible: true});" },
|
|
9
|
+
{ module: "contacts", name: "Contacts", script: "const Contacts = Application('Contacts'); JSON.stringify({app: 'Contacts', accessible: true});" },
|
|
10
|
+
{ module: "mail", name: "Mail", script: "const Mail = Application('Mail'); JSON.stringify({app: 'Mail', accessible: true});" },
|
|
11
|
+
{ module: "music", name: "Music", script: "const Music = Application('Music'); JSON.stringify({app: 'Music', accessible: true});" },
|
|
12
|
+
{ module: "finder", name: "Finder", script: "const Finder = Application('Finder'); JSON.stringify({app: 'Finder', accessible: true});" },
|
|
13
|
+
{ module: "safari", name: "Safari", script: "const Safari = Application('Safari'); JSON.stringify({app: 'Safari', accessible: true});" },
|
|
14
|
+
{ module: "system", name: "System Events", script: "const SE = Application('System Events'); JSON.stringify({app: 'System Events', accessible: true});" },
|
|
15
|
+
{ module: "photos", name: "Photos", script: "const Photos = Application('Photos'); JSON.stringify({app: 'Photos', accessible: true});" },
|
|
16
|
+
{ module: "messages", name: "Messages", script: "const Messages = Application('Messages'); JSON.stringify({app: 'Messages', accessible: true});" },
|
|
17
|
+
{ module: "tv", name: "TV", script: "const TV = Application('TV'); JSON.stringify({app: 'TV', accessible: true});" },
|
|
14
18
|
];
|
|
15
|
-
export function registerSetupTools(server) {
|
|
19
|
+
export function registerSetupTools(server, config) {
|
|
16
20
|
server.registerTool("setup_permissions", {
|
|
17
21
|
title: "Setup Permissions",
|
|
18
22
|
description: "Trigger macOS permission prompts for all Apple apps used by iMcp. Run this once after installation to grant all permissions at once. Each app will show a one-time macOS permission dialog.",
|
|
@@ -24,8 +28,12 @@ export function registerSetupTools(server) {
|
|
|
24
28
|
openWorldHint: false,
|
|
25
29
|
},
|
|
26
30
|
}, async () => {
|
|
31
|
+
// Only probe apps for enabled modules
|
|
32
|
+
const apps = config
|
|
33
|
+
? MODULE_APP_MAP.filter((a) => isModuleEnabled(config, a.module))
|
|
34
|
+
: MODULE_APP_MAP;
|
|
27
35
|
const results = [];
|
|
28
|
-
for (const app of
|
|
36
|
+
for (const app of apps) {
|
|
29
37
|
try {
|
|
30
38
|
await runJxa(app.script);
|
|
31
39
|
results.push({ app: app.name, status: "granted" });
|
|
@@ -38,7 +46,8 @@ export function registerSetupTools(server) {
|
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
const granted = results.filter((r) => r.status === "granted").length;
|
|
41
|
-
|
|
49
|
+
const skipped = MODULE_APP_MAP.length - apps.length;
|
|
50
|
+
return ok({ total: apps.length, granted, skipped, results });
|
|
42
51
|
});
|
|
43
52
|
}
|
|
44
53
|
//# sourceMappingURL=setup.js.map
|
package/dist/shared/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/shared/setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/shared/setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,kEAAkE;AAClE,MAAM,cAAc,GAA4D;IAC9E,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAA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
+
import { z } from "zod";
|
|
2
|
+
import { userPrompt } from "../shared/prompt.js";
|
|
3
|
+
export function registerShortcutPrompts(server) {
|
|
4
|
+
server.prompt("shortcut-automation", {
|
|
5
|
+
goal: z.string().describe("The automation goal or workflow you want to achieve"),
|
|
6
|
+
input: z.string().optional().describe("Optional initial input data for the workflow"),
|
|
7
|
+
}, ({ goal, input }) => {
|
|
8
|
+
const inputCtx = input ? `\nInitial input data: "${input}"` : "";
|
|
9
|
+
return userPrompt("Guide for creating complex automation workflows by chaining multiple shortcuts.", `Build an automation workflow to achieve: "${goal}"${inputCtx}
|
|
10
|
+
|
|
11
|
+
Execute the following steps using iMcp tools:
|
|
12
|
+
|
|
13
|
+
1. **Discover available shortcuts**:
|
|
14
|
+
- list_shortcuts to get all available Siri Shortcuts on this Mac
|
|
15
|
+
- search_shortcuts with keywords related to "${goal}" to find relevant shortcuts
|
|
16
|
+
- For each promising match, use get_shortcut_detail to understand what it does and what actions it contains
|
|
17
|
+
|
|
18
|
+
2. **Analyze and plan the workflow**:
|
|
19
|
+
- Identify which shortcuts can be chained together to accomplish the goal
|
|
20
|
+
- Determine the execution order based on input/output dependencies
|
|
21
|
+
- Note which shortcuts accept text input and which produce output
|
|
22
|
+
- Identify any gaps where no existing shortcut covers a needed step
|
|
23
|
+
- Present the proposed workflow plan to me for confirmation
|
|
24
|
+
|
|
25
|
+
3. **Execute the workflow**:
|
|
26
|
+
- Run each shortcut in sequence using run_shortcut with the appropriate name and input
|
|
27
|
+
- Pass the output of one shortcut as the input to the next when chaining
|
|
28
|
+
- If a shortcut fails, report the error and suggest alternatives
|
|
29
|
+
- Track the output at each step for the final summary
|
|
30
|
+
|
|
31
|
+
4. **Report results**:
|
|
32
|
+
- Show the output from each step in the chain
|
|
33
|
+
- Highlight any steps that produced unexpected results
|
|
34
|
+
- Suggest improvements or additional shortcuts that could enhance the workflow
|
|
35
|
+
- If a step failed, explain what went wrong and possible fixes
|
|
36
|
+
|
|
37
|
+
Important:
|
|
38
|
+
- Always use exact shortcut names from list_shortcuts or search_shortcuts — names must match exactly
|
|
39
|
+
- Some shortcuts may trigger UI prompts or require user interaction — warn me before running those
|
|
40
|
+
- Never assume a shortcut exists; always verify with search_shortcuts first
|
|
41
|
+
- Ask for confirmation before running shortcuts that perform destructive or irreversible actions`);
|
|
42
|
+
});
|
|
43
|
+
server.prompt("shortcut-discovery", {
|
|
44
|
+
category: z.string().optional().describe("Optional category or keyword to focus the discovery (e.g. 'productivity', 'media', 'text')"),
|
|
45
|
+
}, ({ category }) => {
|
|
46
|
+
const filterCtx = category
|
|
47
|
+
? `Focus on shortcuts related to "${category}".`
|
|
48
|
+
: "Cover all available shortcuts.";
|
|
49
|
+
return userPrompt("Help users find, understand, and explore their available Siri Shortcuts.", `Help me discover and understand my available Siri Shortcuts. ${filterCtx}
|
|
50
|
+
|
|
51
|
+
Execute the following steps using iMcp tools:
|
|
52
|
+
|
|
53
|
+
1. **List all shortcuts**:
|
|
54
|
+
- list_shortcuts to get the complete list of Siri Shortcuts on this Mac
|
|
55
|
+
- Report the total count${category ? `\n - search_shortcuts(query: "${category}") to filter for the relevant category` : ""}
|
|
56
|
+
|
|
57
|
+
2. **Categorize shortcuts**:
|
|
58
|
+
- Group shortcuts by inferred purpose based on their names:
|
|
59
|
+
* Productivity (text processing, file operations, data conversion)
|
|
60
|
+
* Communication (messaging, email, sharing)
|
|
61
|
+
* Media (photos, music, video)
|
|
62
|
+
* System (settings, device control, automation)
|
|
63
|
+
* Developer (build, deploy, git, code)
|
|
64
|
+
* Custom/Other
|
|
65
|
+
- Present the categorized list clearly
|
|
66
|
+
|
|
67
|
+
3. **Deep-dive into interesting shortcuts**:
|
|
68
|
+
- For shortcuts with unclear names, use get_shortcut_detail to inspect their actions
|
|
69
|
+
- Identify which shortcuts accept input and what type
|
|
70
|
+
- Identify which shortcuts produce output
|
|
71
|
+
- Flag shortcuts that might interact with external services or perform system changes
|
|
72
|
+
|
|
73
|
+
4. **Provide recommendations**:
|
|
74
|
+
- Suggest useful shortcuts the user might not know they have
|
|
75
|
+
- Identify shortcuts that could be combined for powerful workflows
|
|
76
|
+
- Point out shortcuts that overlap in functionality
|
|
77
|
+
- Suggest common tasks that could be automated with the existing shortcuts
|
|
78
|
+
|
|
79
|
+
5. **Summary report**:
|
|
80
|
+
- Total shortcuts available
|
|
81
|
+
- Breakdown by category
|
|
82
|
+
- Top recommendations for daily use
|
|
83
|
+
- Potential workflow combinations
|
|
84
|
+
|
|
85
|
+
Important:
|
|
86
|
+
- Use get_shortcut_detail on shortcuts with ambiguous names to provide accurate descriptions
|
|
87
|
+
- Do not run any shortcuts during discovery — this is a read-only exploration
|
|
88
|
+
- If the list is very large, focus on the most useful categories first`);
|
|
89
|
+
});
|
|
90
|
+
server.prompt("shortcut-troubleshooting", {
|
|
91
|
+
shortcutName: z.string().describe("Name of the shortcut that is having issues"),
|
|
92
|
+
errorDescription: z.string().optional().describe("Description of the error or unexpected behavior"),
|
|
93
|
+
}, ({ shortcutName, errorDescription }) => {
|
|
94
|
+
const errorCtx = errorDescription
|
|
95
|
+
? `\nReported issue: "${errorDescription}"`
|
|
96
|
+
: "";
|
|
97
|
+
return userPrompt("Diagnose and fix shortcut execution issues.", `Troubleshoot the Siri Shortcut "${shortcutName}".${errorCtx}
|
|
98
|
+
|
|
99
|
+
Execute the following steps using iMcp tools:
|
|
100
|
+
|
|
101
|
+
1. **Verify the shortcut exists**:
|
|
102
|
+
- search_shortcuts(query: "${shortcutName}") to find the shortcut
|
|
103
|
+
- If not found, list_shortcuts to show all available shortcuts and suggest the closest match
|
|
104
|
+
- Confirm the exact name (names are case-sensitive and must match exactly)
|
|
105
|
+
|
|
106
|
+
2. **Inspect the shortcut**:
|
|
107
|
+
- get_shortcut_detail(name: "${shortcutName}") to examine its actions and structure
|
|
108
|
+
- Identify what the shortcut is designed to do
|
|
109
|
+
- Check what input it expects (if any)
|
|
110
|
+
- Identify actions that depend on external services, apps, or permissions
|
|
111
|
+
|
|
112
|
+
3. **Test execution**:
|
|
113
|
+
- run_shortcut(name: "${shortcutName}") with no input to test basic execution
|
|
114
|
+
- If the shortcut expects input, run_shortcut with a simple test input
|
|
115
|
+
- Capture and analyze any error messages from the output
|
|
116
|
+
|
|
117
|
+
4. **Diagnose the issue**:
|
|
118
|
+
Based on the inspection and test results, check for these common problems:
|
|
119
|
+
- **Name mismatch**: The name used doesn't exactly match the shortcut name
|
|
120
|
+
- **Missing input**: The shortcut requires input but none was provided
|
|
121
|
+
- **Wrong input type**: The shortcut expects a specific input format
|
|
122
|
+
- **Permission issues**: The shortcut needs permissions that haven't been granted
|
|
123
|
+
- **App dependency**: The shortcut relies on an app that isn't installed or available
|
|
124
|
+
- **Network dependency**: The shortcut needs internet access for an API or web request
|
|
125
|
+
- **UI interaction required**: The shortcut triggers a dialog that blocks automation
|
|
126
|
+
- **Timeout**: The shortcut takes too long to complete via CLI
|
|
127
|
+
|
|
128
|
+
5. **Provide solutions**:
|
|
129
|
+
- Explain the diagnosed root cause clearly
|
|
130
|
+
- Suggest specific fixes:
|
|
131
|
+
* Correct name to use with run_shortcut
|
|
132
|
+
* Required input format and example
|
|
133
|
+
* Permission steps to resolve access issues
|
|
134
|
+
* Alternative shortcuts that accomplish the same goal
|
|
135
|
+
- If the shortcut cannot be fixed via MCP, explain what manual steps are needed in the Shortcuts app
|
|
136
|
+
|
|
137
|
+
6. **Verification**:
|
|
138
|
+
- After applying fixes, re-run the shortcut to confirm it works
|
|
139
|
+
- Show the successful output
|
|
140
|
+
|
|
141
|
+
Important:
|
|
142
|
+
- Some shortcuts will trigger UI prompts — warn me before running them
|
|
143
|
+
- If a shortcut consistently fails, it may need to be edited in the Shortcuts app directly
|
|
144
|
+
- Report the exact error output for accurate diagnosis
|
|
145
|
+
- Do not modify or delete any shortcuts — only inspect and run them`);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.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AAC;IAEF,MAAM,CAAC,MAAM,CACX,0BAA0B,EAC1B;QACE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;QAC/E,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;KACpG,EACD,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,gBAAgB;YAC/B,CAAC,CAAC,sBAAsB,gBAAgB,GAAG;YAC3C,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,UAAU,CACf,6CAA6C,EAC7C,mCAAmC,YAAY,KAAK,QAAQ;;;;;gCAKpC,YAAY;;;;;kCAKV,YAAY;;;;;;2BAMnB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEAgC6B,CAC7D,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/system/scripts.js
CHANGED
|
@@ -4,8 +4,10 @@ export function getClipboardScript() {
|
|
|
4
4
|
return `
|
|
5
5
|
const app = Application.currentApplication();
|
|
6
6
|
app.includeStandardAdditions = true;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
let text;
|
|
8
|
+
try { text = app.theClipboard(); } catch(e) { text = ''; }
|
|
9
|
+
const content = (typeof text === 'object') ? JSON.stringify(text) : String(text);
|
|
10
|
+
JSON.stringify({content: content});
|
|
9
11
|
`;
|
|
10
12
|
}
|
|
11
13
|
export function setClipboardScript(text) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/system/scripts.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAE3C,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,UAAU,kBAAkB;IAChC,OAAO
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":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,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACrF,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO;;;yCAGgC,UAAU,KAAK,QAAQ;oDACZ,QAAQ;6CACf,GAAG,CAAC,IAAI,CAAC;GACnD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAe,EAAE,KAAc,EAAE,QAAiB,EAAE,KAAc;IACvG,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnD,IAAI,QAAQ;QAAE,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnD,OAAO;;;+BAGsB,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;4CACrB,GAAG,CAAC,OAAO,CAAC;GACrD,CAAC;AACJ,CAAC"}
|
package/dist/system/tools.js
CHANGED
|
@@ -87,7 +87,7 @@ export function registerSystemTools(server, _config) {
|
|
|
87
87
|
annotations: {
|
|
88
88
|
readOnlyHint: false,
|
|
89
89
|
destructiveHint: false,
|
|
90
|
-
idempotentHint:
|
|
90
|
+
idempotentHint: true,
|
|
91
91
|
openWorldHint: false,
|
|
92
92
|
},
|
|
93
93
|
}, async () => {
|
|
@@ -183,7 +183,7 @@ export function registerSystemTools(server, _config) {
|
|
|
183
183
|
region: z.enum(["fullscreen", "window", "selection"]).optional().default("fullscreen").describe("Capture region: fullscreen (default), window, or selection"),
|
|
184
184
|
},
|
|
185
185
|
annotations: {
|
|
186
|
-
readOnlyHint:
|
|
186
|
+
readOnlyHint: true,
|
|
187
187
|
destructiveHint: false,
|
|
188
188
|
idempotentHint: false,
|
|
189
189
|
openWorldHint: false,
|