Skip to main content
Glama

macOS Automator MCP Server

by steipete
applescript_terminal_commands.md1.75 kB
# AppleScript: Terminal Command Execution This document demonstrates how to execute Terminal commands from AppleScript. This capability allows you to automate command-line operations and incorporate shell commands into your AppleScript workflows. ## Basic Usage ```applescript -- Run a command in a new Terminal tab tell application "Terminal" activate do script "ls -la ~/" end tell ``` ## How It Works 1. The script uses Terminal.app's AppleScript dictionary to interact with the application 2. `activate` brings Terminal to the foreground 3. `do script` tells Terminal to execute the specified shell command 4. By default, this creates a new tab (or window if none exist) and runs the command there ## Advanced Usage: Run Command in Existing Tab ```applescript tell application "Terminal" -- Run in the frontmost tab if it exists if (count of windows) > 0 then do script "echo 'Running in current tab'" in front window else -- Otherwise create a new tab do script "echo 'Created new tab'" end if end tell ``` ## Common Use Cases - Running system maintenance commands - Starting development servers - Executing scripts that require a terminal environment - Automating installation or update processes - Running network diagnostics or monitoring commands ## Notes and Limitations - Commands run asynchronously by default - the script continues without waiting for command completion - For commands that require user input, you'll need to prepare for interactive sessions - To run commands that require sudo, it's better to use the `do shell script` command with administrator privileges - The terminal window remains open after command execution - you would need additional scripting to close it automatically

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

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