Labsco
steipete logo

macOS Automator

โ˜… 843

from steipete

Run AppleScript and JXA scripts to automate tasks on macOS.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

macOS Automator MCP ๐Ÿค– - Your Friendly Neighborhood RoboScripterโ„ข

macOS Automator MCP Server

๐ŸŽฏ Mission Control: Teaching Robots to Click Buttons Since 2024

Welcome to the automated future where your Mac finally does what you tell it to! This Model Context Protocol (MCP) server transforms your AI assistant into a silicon-based intern who actually knows AppleScript and JavaScript for Automation (JXA).

No more copy-pasting scripts like a caveman - let the robots handle the robot work! Our knowledge base contains over 200 pre-programmed automation sequences, loaded faster than you can say "Hey Siri, why don't you work like this?"

๐Ÿš€ Why Let Robots Run Your Mac?

  • Remote Control Reality: Execute AppleScript/JXA scripts via MCP - it's like having a tiny robot inside your Mac!
  • Knowledge Base of Power: 200+ pre-built automation recipes. From "toggle dark mode" to "extract all URLs from Safari" - we've got your robot needs covered.
  • App Whisperer: Control any macOS application programmatically. Make Finder dance, Safari sing, and Terminal... well, terminate things.
  • AI Workflow Integration: Connect your Mac to the AI revolution. Your LLM can now actually DO things instead of just talking about them!

๐Ÿค– Robot Toolbox

1. execute_script - The Script Launcher 9000

Your robot's primary weapon for macOS domination. Feed it AppleScript or JXA, and watch the magic happen! Scripts can be provided as inline content (script_content), an absolute file path (script_path), or by referencing a script from the built-in knowledge base using its unique kb_script_id.

Script Sources (mutually exclusive):

  • script_content (string): Raw script code.
  • script_path (string): Absolute POSIX path to a script file (e.g., .applescript, .scpt, .js).
  • kb_script_id (string): The ID of a pre-defined script from the server's knowledge base. Use the get_scripting_tips tool to discover available script IDs and their functionalities.

Language Specification:

  • language (enum: 'applescript' | 'javascript', optional): Specify the language.
    • If using kb_script_id, the language is inferred from the knowledge base script.
    • If using script_content or script_path and language is omitted, it defaults to 'applescript'.

Passing Inputs to Scripts:

  • arguments (array of strings, optional):
    • For script_path: Passed as standard arguments to the script's on run argv (AppleScript) or run(argv) (JXA) handler.
    • For kb_script_id: Used if the pre-defined script accepts positional string arguments (e.g., ${arguments[0]} or the legacy --MCP_ARG_1). Check the script's argumentsPrompt from get_scripting_tips.
  • input_data (JSON object, optional):
    • Primarily for kb_script_id scripts designed to accept named, structured inputs.
    • Values replace placeholders in the script (e.g., ${inputData.yourKeyName} or the legacy --MCP_INPUT:yourKeyName). See argumentsPrompt from get_scripting_tips.
    • Values (strings, numbers, booleans, simple arrays/objects) are converted to their AppleScript literal equivalents.

Other Options:

  • timeout_seconds (integer, optional, default: 60): Maximum execution time.
  • output_format_mode (enum, optional, default: 'auto'): Controls osascript output formatting flags.
    • 'auto': (Default) Uses human-readable for AppleScript (-s h), and direct output (no -s flags) for JXA.
    • 'human_readable': Forces -s h (human-readable output, mainly for AppleScript).
    • 'structured_error': Forces -s s (structured error reporting, mainly for AppleScript).
    • 'structured_output_and_error': Forces -s ss (structured output for main result and errors, mainly for AppleScript).
    • 'direct': No -s flags are used (recommended for JXA, also the behavior for JXA in auto mode).
  • include_executed_script_in_output (boolean, optional, default: false): If true, the output will include the full script content (after any placeholder substitutions for knowledge base scripts) or the script path that was executed. This is appended as an additional text part in the output content array.
  • include_substitution_logs (boolean, optional, default: false): If true, detailed logs of placeholder substitutions performed on knowledge base scripts are included in the output. This is useful for debugging how input_data and arguments are processed and inserted into the script. The logs are prepended to the script output on success or appended to the error message on failure.
  • report_execution_time (boolean, optional, default: false): If true, an additional message with the formatted script execution time will be included in the response content array.

SECURITY WARNING & MACOS PERMISSIONS: (Same critical warnings as before about arbitrary script execution and macOS Automation/Accessibility permissions).

Examples:

  • (Existing examples for inline/file path remain relevant)
  • Using Knowledge Base Script by ID:
    Copy & paste โ€” that's it
    {
      "toolName": "execute_script",
      "input": {
        "kb_script_id": "safari_get_active_tab_url",
        "timeout_seconds": 10
      }
    }
  • Using Knowledge Base Script by ID with input_data:
    Copy & paste โ€” that's it
    {
      "toolName": "execute_script",
      "input": {
        "kb_script_id": "finder_create_folder_at_path",
        "input_data": {
          "folder_name": "New MCP Folder",
          "parent_path": "~/Desktop"
        }
      }
    }

Response Format:

The execute_script tool returns a response in the following format:

Copy & paste โ€” that's it
{
  content: Array<{
    type: 'text';
    text: string;
  }>;
  isError?: boolean;
}
  • content: An array of text content items containing the script output
  • isError: (boolean, optional) Set to true when the script execution produced an error. This flag is set when:
    • The script output (stdout) starts with "Error" (case-insensitive)
    • This helps clients easily determine if the execution failed without parsing the output text

Example Response (Success):

Copy & paste โ€” that's it
{
  "content": [
    {
      "type": "text",
      "text": "Script executed successfully"
    }
  ]
}

Example Response (Error):

Copy & paste โ€” that's it
{
  "content": [
    {
      "type": "text",
      "text": "Error: Cannot find application 'Safari'"
    }
  ],
  "isError": true
}

2. get_scripting_tips - The Robot's Encyclopedia

Your personal automation librarian! Searches through 200+ pre-built scripts faster than you can Google "how to AppleScript". Perfect for when your robot needs inspiration.

Arguments:

  • list_categories (boolean, optional, default: false): If true, returns only the list of available knowledge base categories and their descriptions. Overrides other parameters.
  • category (string, optional): Filters tips by a specific category ID (e.g., "finder", "safari").
  • search_term (string, optional): Searches for a keyword within tip titles, descriptions, script content, keywords, or IDs.
  • refresh_database (boolean, optional, default: false): If true, forces a reload of the entire knowledge base from disk before processing the request. This is useful during development if you are actively modifying knowledge base files and want to ensure the latest versions are used without restarting the server.
  • limit (integer, optional, default: 10): Maximum number of results to return.

Output:

  • Returns a Markdown formatted string containing the requested tips, including their title, description, script content, language, runnable ID (if applicable), argument prompts, and notes.

Example Usage:

  • List all categories: { "toolName": "get_scripting_tips", "input": { "list_categories": true } }
  • Get tips for "safari" category: { "toolName": "get_scripting_tips", "input": { "category": "safari" } }
  • Search for tips related to "clipboard": { "toolName": "get_scripting_tips", "input": { "search_term": "clipboard" } }

๐ŸŽฎ Robot Playground: Cool Things Your New Robot Friend Can Do

  • Application Control (Teaching Apps Who's Boss):
    • Get the current URL from Safari: { "input": { "script_content": "tell application \"Safari\" to get URL of front document" } }
    • Get subjects of unread emails in Mail: { "input": { "script_content": "tell application \"Mail\" to get subject of messages of inbox whose read status is false" } }
  • File System Operations (Digital Housekeeping):
    • List files on the Desktop: { "input": { "script_content": "tell application \"Finder\" to get name of every item of desktop" } }
    • Create a new folder: { "input": { "script_content": "tell application \"Finder\" to make new folder at desktop with properties {name:\"Robot's Secret Stash\"}" } }
  • System Interactions (Mac Mind Control):
    • Display a system notification: { "input": { "script_content": "display notification \"๐Ÿค– Beep boop! Task complete!\" with title \"Robot Report\"" } }
    • Set system volume: { "input": { "script_content": "set volume output volume 50" } } (0-100)
    • Get current clipboard content: { "input": { "script_content": "the clipboard" } }

๐Ÿ‘จโ€๐Ÿ”ฌ Robot Scientists Welcome!

Want to upgrade your robot? Check out the development guide for the full technical manual on teaching new tricks to your automation assistant.

๐Ÿง  Teach Your Robot New Tricks (Local Knowledge Base)

Your robot can learn custom skills! Create your own automation recipes and watch your robot evolve.

By default, the application will look for this local knowledge base at ~/.macos-automator/knowledge_base. You can customize this path by setting the LOCAL_KB_PATH environment variable.

Example:

Suppose you have a local knowledge base at /Users/yourname/my-custom-kb. Set the environment variable: export LOCAL_KB_PATH=/Users/yourname/my-custom-kb

Or, if you are running the validator script, you can use the --local-kb-path argument: pnpm run validate -- --local-kb-path /Users/yourname/my-custom-kb

Structure and Overrides:

  • Your local knowledge base should mirror the category structure of the main knowledge_base (e.g., 01_applescript_core, 05_web_browsers/safari, etc.).
  • You can add new .md tip files or _shared_handlers (e.g., .applescript or .js files).
  • If a tip ID (either from frontmatter id: or generated from filename/path) in your local knowledge base matches an ID in the embedded knowledge base, your local version will override the embedded one.
  • Similarly, shared handlers with the same name and language (e.g., my_utility.applescript) in your local _shared_handlers directory will override any embedded ones with the same name and language within the same category (or globally if you place them at the root of your local KB's _shared_handlers).
  • Category descriptions from _category_info.md in your local KB can also override those from the embedded KB for the same category.

This allows for personalization and extension of the available automation scripts and tips without modifying the core application files.

๐Ÿค Join the Robot Revolution!

Found a bug? Got a cool automation idea? Your robot army needs YOU! Submit issues and pull requests to the GitHub repository.

๐Ÿ’ช Robot Superpowers Showcase

Here's what your new silicon sidekick can do out of the box:

๐Ÿ–ฅ๏ธ Terminal Tamer

  • Command Line Wizardry: Open new tabs, run commands, capture output - your robot speaks fluent bash!
    Copy & paste โ€” that's it
    { "input": { "kb_script_id": "terminal_app_run_command_new_tab", "input_data": { "command": "echo '๐Ÿค– Hello World!'" } } }

๐ŸŒ Browser Bot

  • Web Automation Master: Control Chrome and Safari like a puppet master!
    Copy & paste โ€” that's it
    { "input": { "kb_script_id": "safari_get_front_tab_url" } }
  • JavaScript Injection: Make web pages dance to your robot's tune
  • Screenshot Sniper: Capture any webpage faster than you can say "cheese"

โš™๏ธ System Sorcerer

  • Dark Mode Toggle: Because robots have sensitive optical sensors
    Copy & paste โ€” that's it
    { "input": { "kb_script_id": "systemsettings_toggle_dark_mode_ui" } }
  • Clipboard Commander: Copy, paste, and manipulate like a pro
  • Notification Ninja: Send alerts that actually get noticed

๐Ÿ“ File System Feng Shui

  • Folder Creator 3000: Organize your digital life with robotic precision
    Copy & paste โ€” that's it
    { "input": { "kb_script_id": "finder_create_new_folder_desktop", "input_data": { "folder_name": "Robot Paradise" } } }
  • Text File Telepathy: Read and write files faster than humanly possible

๐Ÿ“ฑ App Whisperer

  • Calendar Conductor: Schedule meetings while you sleep
  • Email Automator: Send emails without lifting a finger
  • Music Maestro: DJ your playlists programmatically
    Copy & paste โ€” that's it
    { "input": { "kb_script_id": "music_playback_controls", "input_data": { "action": "play" } } }

๐ŸŽฏ Pro Tip: Use get_scripting_tips to discover all 200+ automation recipes!

๐Ÿ“œ Legal Stuff (Robot Rights)

This project is licensed under the MIT License - which means your robot is free to roam! See the LICENSE file for the fine print.


๐Ÿค– Remember: With great automation power comes great responsibility. Use your robot wisely!

<a href="https://glama.ai/mcp/servers/@steipete/macos-automator-mcp"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@steipete/macos-automator-mcp/badge" alt="macOS Automator Server MCP server" /> </a>