Skip to main content
Glama
Szowesgad

automator-mcp

by Szowesgad

quick_action

Execute predefined file automation tasks like compressing images, converting to PDF, resizing images, extracting text, combining PDFs, or converting video files on macOS.

Instructions

Run a predefined quick action

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesQuick action to perform
filesYesFile paths to process
optionsNoAction-specific options

Implementation Reference

  • The primary handler for the 'quick_action' tool. It destructures the input arguments, defines a mapping of quick actions to their implementations (which use AppleScript), and executes the specified action on the provided files.
    async runQuickAction(args) {
      const { action, files, options = {} } = args;
      
      const quickActions = {
        compress_images: async () => {
          const script = `
            tell application "Finder"
              set theFiles to {${files.map(f => `POSIX file "${f}"`).join(', ')}}
            end tell
            
            repeat with theFile in theFiles
              do shell script "sips -Z 1024 " & quoted form of POSIX path of theFile
            end repeat
          `;
          return this.runAppleScript(script);
        },
        
        convert_to_pdf: async () => {
          const outputPath = options.outputPath || files[0].replace(/\.[^.]+$/, '.pdf');
          const script = `
            do shell script "convert ${files.map(f => `'${f}'`).join(' ')} '${outputPath}'"
          `;
          return this.runAppleScript(script);
        },
        
        resize_images: async () => {
          const size = options.size || '800x600';
          const script = `
            repeat with filePath in {${files.map(f => `"${f}"`).join(', ')}}
              do shell script "sips -z ${size.split('x')[1]} ${size.split('x')[0]} " & filePath
            end repeat
          `;
          return this.runAppleScript(script);
        },
      };
      
      if (quickActions[action]) {
        return await quickActions[action]();
      }
      
      throw new Error(`Unknown quick action: ${action}`);
    }
  • Input schema for the 'quick_action' tool, defining the expected parameters: 'action' (enum of available quick actions), 'files' (array of file paths, required), and optional 'options'.
    inputSchema: {
      type: 'object',
      properties: {
        action: {
          type: 'string',
          enum: [
            'compress_images',
            'convert_to_pdf',
            'resize_images',
            'extract_text_from_pdf',
            'combine_pdfs',
            'convert_video',
          ],
          description: 'Quick action to perform',
        },
        files: {
          type: 'array',
          items: { type: 'string' },
          description: 'File paths to process',
        },
        options: {
          type: 'object',
          description: 'Action-specific options',
        },
      },
      required: ['action', 'files'],
    },
  • src/index.js:108-138 (registration)
    Registration of the 'quick_action' tool in the listTools handler response, including name, description, and full input schema.
    {
      name: 'quick_action',
      description: 'Run a predefined quick action',
      inputSchema: {
        type: 'object',
        properties: {
          action: {
            type: 'string',
            enum: [
              'compress_images',
              'convert_to_pdf',
              'resize_images',
              'extract_text_from_pdf',
              'combine_pdfs',
              'convert_video',
            ],
            description: 'Quick action to perform',
          },
          files: {
            type: 'array',
            items: { type: 'string' },
            description: 'File paths to process',
          },
          options: {
            type: 'object',
            description: 'Action-specific options',
          },
        },
        required: ['action', 'files'],
      },
    },
  • src/index.js:187-188 (registration)
    Handler dispatch registration in the CallToolRequestHandler switch statement, routing 'quick_action' calls to the runQuickAction method.
    case 'quick_action':
      return await this.runQuickAction(args);
  • Helper mapping object within the handler that defines implementations for specific quick actions like compress_images, convert_to_pdf, and resize_images using AppleScript.
    const quickActions = {
      compress_images: async () => {
        const script = `
          tell application "Finder"
            set theFiles to {${files.map(f => `POSIX file "${f}"`).join(', ')}}
          end tell
          
          repeat with theFile in theFiles
            do shell script "sips -Z 1024 " & quoted form of POSIX path of theFile
          end repeat
        `;
        return this.runAppleScript(script);
      },
      
      convert_to_pdf: async () => {
        const outputPath = options.outputPath || files[0].replace(/\.[^.]+$/, '.pdf');
        const script = `
          do shell script "convert ${files.map(f => `'${f}'`).join(' ')} '${outputPath}'"
        `;
        return this.runAppleScript(script);
      },
      
      resize_images: async () => {
        const size = options.size || '800x600';
        const script = `
          repeat with filePath in {${files.map(f => `"${f}"`).join(', ')}}
            do shell script "sips -z ${size.split('x')[1]} ${size.split('x')[0]} " & filePath
          end repeat
        `;
        return this.runAppleScript(script);
      },
    };

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/Szowesgad/automator-mcp'

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