@aernoud/remindersmcp
Advanced tools
@@ -0,11 +1,63 @@ | ||
| import { execFileSync } from "node:child_process"; | ||
| export * from "./applescript-core.js"; | ||
| // Leave-as-found tracking: remember which apps we launched (vs. were | ||
| // already running), and quit only those on server shutdown. State is | ||
| // per-server-process, checked lazily on the first withLaunch() call | ||
| // for each app so the probe cost is paid once per session. | ||
| const touchedApps = new Set(); | ||
| const launchedByUs = new Set(); | ||
| let exitHandlersInstalled = false; | ||
| function isAppRunning(app) { | ||
| try { | ||
| execFileSync("pgrep", ["-x", app], { stdio: "ignore" }); | ||
| return true; | ||
| } | ||
| catch { | ||
| return false; | ||
| } | ||
| } | ||
| function quitLaunchedApps() { | ||
| for (const app of launchedByUs) { | ||
| try { | ||
| execFileSync("osascript", ["-e", `tell application "${app}" to quit`], { | ||
| timeout: 5000, | ||
| stdio: "ignore", | ||
| }); | ||
| } | ||
| catch { | ||
| // App may have been quit manually, crashed, or be unresponsive — ignore. | ||
| } | ||
| } | ||
| } | ||
| function installExitHandlers() { | ||
| if (exitHandlersInstalled) | ||
| return; | ||
| exitHandlersInstalled = true; | ||
| const onSignal = () => { | ||
| quitLaunchedApps(); | ||
| process.exit(0); | ||
| }; | ||
| process.on("SIGTERM", onSignal); | ||
| process.on("SIGINT", onSignal); | ||
| process.on("SIGHUP", onSignal); | ||
| process.on("exit", quitLaunchedApps); | ||
| } | ||
| export function withLaunch(app, body) { | ||
| return `if application "${app}" is not running then | ||
| do shell script "open -g -a ${app}" | ||
| repeat 30 times | ||
| if application "${app}" is running then exit repeat | ||
| delay 0.2 | ||
| end repeat | ||
| end if | ||
| if (!touchedApps.has(app)) { | ||
| touchedApps.add(app); | ||
| if (!isAppRunning(app)) { | ||
| launchedByUs.add(app); | ||
| } | ||
| installExitHandlers(); | ||
| } | ||
| return `do shell script "open -g -a ${app}" | ||
| repeat 50 times | ||
| try | ||
| tell application "${app}" to get name | ||
| exit repeat | ||
| on error | ||
| delay 0.1 | ||
| end try | ||
| end repeat | ||
| ${body}`; | ||
| } |
+1
-1
| { | ||
| "name": "@aernoud/remindersmcp", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "MCP server for macOS Reminders.app — list/reminder management via AppleScript", | ||
@@ -5,0 +5,0 @@ "mcpName": "io.github.aernouddekker/remindersmcp", |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
56903
2.66%1463
3.69%2
100%