Skip to main content
Glama
dvcrn

Siri Shortcuts MCP Server

by dvcrn

run_shortcut

Execute a Siri Shortcut by name or UUID using the Siri Shortcuts MCP Server, with optional input and output parameters for dynamic interaction.

Instructions

Run a shortcut by name or identifier (UUID) with optional input and output parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputNoThe input to pass to the shortcut. Can be text, or a filepath
nameYesThe name or identifier (UUID) of the shortcut to run

Implementation Reference

  • The handler function that executes the 'shortcuts run' command with the provided shortcut name and optional input (handling both text and file inputs).
    const runShortcut = async (params: RunShortcutInput): Promise<ToolResult> => {
      return new Promise((resolve, reject) => {
        let command = `shortcuts run '${params.name}'`;
    
        const args = ["run", `'${params.name}'`];
    
        const input = params.input || " ";
    
        if (input.includes("/")) {
          if (!fs.existsSync(input)) {
            throw new McpError(
              ErrorCode.InvalidParams,
              `Input file does not exist: ${input}`,
            );
          }
          args.push("--input-path");
          args.push(`'${input}'`);
        } else {
          // Create temp file with content
          const tmpPath = path.join("/tmp", `shortcut-input-${Date.now()}`);
          fs.writeFileSync(tmpPath, input);
          args.push("--input-path");
          args.push(`'${tmpPath}'`);
        }
    
        args.push("|");
        args.push("cat");
    
        console.error("Running command: shortcuts", args.join(" "));
        exec(`shortcuts ${args.join(" ")}`, (error, stdout, stderr) => {
          console.error("Run");
          console.error("Error:", error);
          console.error("Stdout:", stdout);
          console.error("Stderr:", stderr);
    
          if (error) {
            reject(
              new McpError(
                ErrorCode.InternalError,
                `Failed to run shortcut: ${error.message}`,
              ),
            );
            return;
          }
    
          // If there's output, return it
          if (stdout.trim()) {
            resolve({ success: true, output: stdout.trim() });
          } else {
            resolve({ success: true, message: `Ran shortcut: ${params.name}` });
          }
        });
      });
    };
  • Zod schema for RunShortcutInput defining parameters: name (required string), input (optional string).
    const RunShortcutSchema = z
      .object({
        name: z.string().describe("The name or identifier (UUID) of the shortcut to run"),
        input: z
          .string()
          .optional()
          .describe(
            "The input to pass to the shortcut. Can be text, or a filepath",
          ),
      })
      .strict();
  • shortcuts.ts:305-310 (registration)
    Registration of the 'run_shortcut' tool in the base tools array, linking to the handler and schema.
    {
      name: ToolName.RUN_SHORTCUT,
      description: runShortcutDescription,
      inputSchema: zodToJsonSchema(RunShortcutSchema) as ToolInput,
      run: (params: any) => runShortcut(params as RunShortcutInput),
    },
  • shortcuts.ts:46-50 (registration)
    Enum defining the tool name constant RUN_SHORTCUT = 'run_shortcut' used for registration.
    enum ToolName {
      LIST_SHORTCUTS = "list_shortcuts",
      OPEN_SHORTCUT = "open_shortcut",
      RUN_SHORTCUT = "run_shortcut",
    }
  • shortcuts.ts:394-395 (registration)
    Dispatch in the MCP CallToolRequest handler for executing run_shortcut.
    case ToolName.RUN_SHORTCUT:
      result = await runShortcut(args as RunShortcutInput);
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dvcrn/mcp-server-siri-shortcuts'

If you have feedback or need assistance with the MCP directory API, please join our Discord server