shortcuts_run_shortcut
Execute macOS Shortcuts in the background without opening the app by providing the shortcut name and optional input via AppleScript integration.
Instructions
[Shortcuts operations] Run a shortcut with optional input. Uses Shortcuts Events to run in background without opening the app.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | No | Optional input to provide to the shortcut | |
| name | Yes | Name of the shortcut to run |
Implementation Reference
- src/categories/shortcuts.ts:12-42 (handler)Core definition of the 'run_shortcut' script in shortcuts category, which implements the 'shortcuts_run_shortcut' MCP tool. Includes input schema and dynamic AppleScript handler template.{ name: "run_shortcut", description: "Run a shortcut with optional input. Uses Shortcuts Events to run in background without opening the app.", schema: { type: "object", properties: { name: { type: "string", description: "Name of the shortcut to run", }, input: { type: "string", description: "Optional input to provide to the shortcut", }, }, required: ["name"], }, script: (args) => ` try tell application "Shortcuts Events" ${args.input ? `run shortcut "${args.name}" with input "${args.input}"` : `run shortcut "${args.name}"` } end tell return "Shortcut '${args.name}' executed successfully" on error errMsg return "Failed to run shortcut: " & errMsg end try `, },
- src/categories/shortcuts.ts:15-28 (schema)Input schema validation for shortcuts_run_shortcut toolschema: { type: "object", properties: { name: { type: "string", description: "Name of the shortcut to run", }, input: { type: "string", description: "Optional input to provide to the shortcut", }, }, required: ["name"], },
- src/index.ts:33-33 (registration)Registers the shortcuts category (containing run_shortcut) with the MCP serverserver.addCategory(shortcutsCategory);
- src/framework.ts:224-230 (registration)Dynamically constructs MCP tool names as 'category_script' (e.g., shortcuts_run_shortcut) and registers schema for listTools endpointname: `${category.name}_${script.name}`, // Changed from dot to underscore description: `[${category.description}] ${script.description}`, inputSchema: script.schema || { type: "object", properties: {}, }, })),
- src/framework.ts:236-281 (handler)MCP CallTool handler: parses tool name 'shortcuts_run_shortcut', locates script, generates AppleScript, and executes it via osascriptconst toolName = request.params.name; this.log("info", "Tool execution requested", { tool: toolName, hasArguments: !!request.params.arguments }); try { // Split on underscore instead of dot const [categoryName, ...scriptNameParts] = toolName.split("_"); const scriptName = scriptNameParts.join("_"); // Rejoin in case script name has underscores const category = this.categories.find((c) => c.name === categoryName); if (!category) { this.log("warning", "Category not found", { categoryName }); throw new McpError( ErrorCode.MethodNotFound, `Category not found: ${categoryName}`, ); } const script = category.scripts.find((s) => s.name === scriptName); if (!script) { this.log("warning", "Script not found", { categoryName, scriptName }); throw new McpError( ErrorCode.MethodNotFound, `Script not found: ${scriptName}`, ); } this.log("debug", "Generating script content", { categoryName, scriptName, isFunction: typeof script.script === "function" }); const scriptContent = typeof script.script === "function" ? script.script(request.params.arguments) : script.script; const result = await this.executeScript(scriptContent);