Skip to main content
Glama

macOS Automator MCP Server

execute_script

Automate macOS tasks by executing AppleScript or JavaScript for Automation (JXA) to control applications like Terminal, Chrome, Safari, and Finder. Supports predefined scripts, raw code, or external script files with customizable inputs and execution options.

Instructions

Automate macOS tasks using AppleScript or JXA (JavaScript for Automation) to control applications like Terminal, Chrome, Safari, Finder, etc.

1. Script Source (Choose one):

  • kb_script_id (string): Preferred. Executes a pre-defined script from the knowledge base by its ID. Use get_scripting_tips to find IDs and inputs. Supports placeholder substitution via input_data or arguments. Ex: kb_script_id: "safari_get_front_tab_url".
  • script_content (string): Executes raw AppleScript/JXA code. Good for simple or dynamic scripts. Ex: script_content: "tell application \"Finder\" to empty trash".
  • script_path (string): Executes a script from an absolute POSIX path on the server. Ex: /Users/user/myscripts/myscript.applescript.

2. Script Inputs (Optional):

  • input_data (JSON object): For kb_script_id, provides named inputs (e.g., --MCP_INPUT:keyName). Values (string, number, boolean, simple array/object) are auto-converted. Ex: input_data: { "folder_name": "New Docs" }.
  • arguments (array of strings): For script_path (passes to on run argv / run(argv)). For kb_script_id, used for positional args (e.g., --MCP_ARG_1).

3. Execution Options (Optional):

  • language ('applescript' | 'javascript'): Specify for script_content/script_path (default: 'applescript'). Inferred for kb_script_id.
  • timeout_seconds (integer, optional, default: 60): Sets the maximum time (in seconds) the script is allowed to run. Increase for potentially long-running operations.
  • output_format_mode (enum, optional, default: 'auto'): Controls osascript output formatting.
    • 'auto': Smart default - resolves to 'human_readable' for AppleScript and 'direct' for JXA.
    • 'human_readable': For AppleScript, uses -s h flag.
    • 'structured_error': For AppleScript, uses -s s flag (structured errors).
    • 'structured_output_and_error': For AppleScript, uses -s ss flag (structured output & errors).
    • 'direct': No special output flags (recommended for JXA).
  • include_executed_script_in_output (boolean, optional, default: false): If true, the final script content (after any placeholder substitutions) or script path that was executed will be included in the response. This is useful for debugging and understanding exactly what was run. Defaults to false.
  • include_substitution_logs (boolean, default: false): For kb_script_id, includes detailed placeholder substitution logs.
  • report_execution_time (boolean, optional, default: false): If true, an additional message with the formatted script execution time will be included in the response. Defaults to false.

Input Schema

NameRequiredDescriptionDefault
argumentsNo
include_executed_script_in_outputNo
include_substitution_logsNo
input_dataNo
kb_script_idNo
languageNo
output_format_modeNo
report_execution_timeNo
script_contentNo
script_pathNo
timeout_secondsNo

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "arguments": { "items": { "type": "string" }, "type": "array" }, "include_executed_script_in_output": { "type": "boolean" }, "include_substitution_logs": { "type": "boolean" }, "input_data": { "additionalProperties": {}, "type": "object" }, "kb_script_id": { "type": "string" }, "language": { "enum": [ "applescript", "javascript" ], "type": "string" }, "output_format_mode": { "enum": [ "auto", "human_readable", "structured_error", "structured_output_and_error", "direct" ], "type": "string" }, "report_execution_time": { "type": "boolean" }, "script_content": { "type": "string" }, "script_path": { "type": "string" }, "timeout_seconds": { "type": "number" } }, "type": "object" }
Install Server

Other Tools from macOS Automator MCP Server

Related Tools

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/daniel-e-andersen/macos-automator-mcp'

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