Skip to main content
Glama

run_applescript

Execute AppleScript commands within macOS applications to automate tasks and control app functionality programmatically.

Instructions

Выполняет AppleScript команду в указанном приложении. Полезно для автоматизации действий в приложениях

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNameYesИмя приложения (например, 'Safari', 'Finder')
scriptYesAppleScript команда для выполнения

Implementation Reference

  • Python handler function that executes the provided AppleScript in the context of the specified macOS application using osascript.
    def run_applescript(app_name: str, script: str) -> str: """Executes AppleScript command""" apple_script = f'tell application "{app_name}"\n{script}\nend tell' # Escape single quotes apple_script_escaped = apple_script.replace("'", "'\\''") stdout, stderr = exec_command(f"osascript -e '{apple_script_escaped}'") return stdout or stderr or "Command executed successfully"
  • TypeScript handler method that executes the provided AppleScript in the context of the specified macOS application using osascript.
    private async runAppleScript(appName: string, script: string) { try { // Выполняем AppleScript в контексте указанного приложения const appleScript = ` tell application "${appName}" ${script} end tell `; const { stdout, stderr } = await execAsync( `osascript -e '${appleScript.replace(/'/g, "'\\''")}'` ); return { content: [ { type: "text", text: stdout || stderr || "Команда выполнена успешно", }, ], }; } catch (error) { throw new Error( `Ошибка выполнения AppleScript: ${error instanceof Error ? error.message : String(error)}` ); }
  • Input schema for the run_applescript tool in the Python MCP server.
    "name": "run_applescript", "description": "Executes AppleScript command in specified application. Useful for automating actions in applications", "inputSchema": { "type": "object", "properties": { "appName": { "type": "string", "description": "Application name (e.g., 'Safari', 'Finder')", }, "script": { "type": "string", "description": "AppleScript command to execute", }, }, "required": ["appName", "script"], }, },
  • Input schema for the run_applescript tool in the TypeScript MCP server.
    name: "run_applescript", description: "Выполняет AppleScript команду в указанном приложении. Полезно для автоматизации действий в приложениях", inputSchema: { type: "object", properties: { appName: { type: "string", description: "Имя приложения (например, 'Safari', 'Finder')", }, script: { type: "string", description: "AppleScript команда для выполнения", }, }, required: ["appName", "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/TrueOleg/MCP-expirements'

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