Skip to main content
Glama

shortcuts_list_shortcuts

Retrieve available macOS shortcuts through AppleScript integration, optionally limiting results for focused access.

Instructions

[Shortcuts operations] List all available shortcuts with optional limit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoOptional limit on the number of shortcuts to return

Implementation Reference

  • Generates AppleScript to list all shortcuts (with optional limit), formats names as JSON array.
    script: (args) => `
      try
        tell application "Shortcuts"
          set shortcutNames to name of every shortcut
          
          ${args.limit ? `
          -- Apply limit if specified
          if (count of shortcutNames) > ${args.limit} then
            set shortcutNames to items 1 through ${args.limit} of shortcutNames
          end if
          ` : ``}
        end tell
        
        -- Convert to JSON string manually
        set jsonOutput to "{"
        set jsonOutput to jsonOutput & "\\"status\\": \\"success\\","
        set jsonOutput to jsonOutput & "\\"shortcuts\\": ["
        
        repeat with i from 1 to count of shortcutNames
          set currentName to item i of shortcutNames
          set jsonOutput to jsonOutput & "{\\"name\\": \\"" & currentName & "\\"}"
          if i < count of shortcutNames then
            set jsonOutput to jsonOutput & ", "
          end if
        end repeat
        
        set jsonOutput to jsonOutput & "]}"
        return jsonOutput
        
      on error errMsg
        return "{\\"status\\": \\"error\\", \\"message\\": \\"" & errMsg & "\\"}"
      end try
    `,
  • Defines input schema for the tool, accepting optional 'limit' parameter of type number.
    schema: {
      type: "object",
      properties: {
        limit: {
          type: "number",
          description: "Optional limit on the number of shortcuts to return",
        },
      },
    },
  • src/index.ts:33-33 (registration)
    Registers the 'shortcuts' category containing the 'list_shortcuts' script, enabling the tool 'shortcuts_list_shortcuts'.
    server.addCategory(shortcutsCategory);
  • Dynamically generates MCP tool list entries, constructing tool name as '{category}_{script}' e.g. 'shortcuts_list_shortcuts'.
    category.scripts.map((script) => ({
      name: `${category.name}_${script.name}`, // Changed from dot to underscore
      description: `[${category.description}] ${script.description}`,
      inputSchema: script.schema || {
        type: "object",
        properties: {},
      },
    })),
  • Executes the tool by invoking the script generator function with arguments and running the resulting AppleScript via osascript.
    const scriptContent =
      typeof script.script === "function"
        ? script.script(request.params.arguments)
        : script.script;
    
    const result = await this.executeScript(scriptContent);
    
    this.log("info", "Tool execution completed successfully", { 
      tool: toolName,
      resultLength: result.length
    });
    
    return {
      content: [
        {
          type: "text",
          text: result,
        },
      ],
    };

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/joshrutkowski/applescript-mcp'

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