run_applescript
Execute AppleScript code on macOS to automate tasks like sending emails, organizing files, and controlling system actions using the automator-mcp server.
Instructions
Execute AppleScript code on macOS
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | AppleScript code to execute |
Implementation Reference
- src/index.js:209-226 (handler)The handler function that executes the provided AppleScript using osascript and returns the result or error.async runAppleScript(script) { try { const result = execSync(`osascript -e '${script.replace(/'/g, "'\"'\"'")}'`, { encoding: 'utf8', }); return { content: [ { type: 'text', text: result.trim() || 'Script executed successfully', }, ], }; } catch (error) { throw new Error(`AppleScript error: ${error.message}`); } }
- src/index.js:175-176 (registration)Dispatch case in CallToolRequestHandler that calls the runAppleScript handler.case 'run_applescript': return await this.runAppleScript(args.script);
- src/index.js:37-50 (registration)Tool registration in the ListTools response, including name, description, and input schema.{ name: 'run_applescript', description: 'Execute AppleScript code on macOS', inputSchema: { type: 'object', properties: { script: { type: 'string', description: 'AppleScript code to execute', }, }, required: ['script'], }, },
- src/index.js:40-49 (schema)Input schema defining the 'script' parameter for the run_applescript tool.inputSchema: { type: 'object', properties: { script: { type: 'string', description: 'AppleScript code to execute', }, }, required: ['script'], },