Skip to main content
Glama

run_applescript

Execute AppleScript commands on macOS to automate tasks or control applications through the Coyote MCP Server.

Instructions

Executes an AppleScript command using osascript on macOS.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptYesAppleScript code to execute.

Implementation Reference

  • The handler function for the 'run_applescript' tool. It spawns an 'osascript' process with the provided script, captures stdout and stderr, and returns the result or error message.
    async ({ script }) => { return new Promise((resolve) => { const proc = spawn("osascript", ["-e", script]); let output = ""; let error = ""; proc.stdout.on("data", (data) => { output += data.toString(); }); proc.stderr.on("data", (data) => { error += data.toString(); }); proc.on("close", (code) => { const result = code === 0 ? (output.trim() || "Command executed successfully") : `Error: ${error.trim() || "Unknown error"}`; resolve({ content: [{ type: "text", text: result }] }); }); }); }
  • Input schema for the 'run_applescript' tool, defining a required 'script' string parameter.
    inputSchema: { script: z.string().describe("AppleScript code to execute.") }
  • src/index.ts:25-62 (registration)
    Registration of the 'run_applescript' tool using server.registerTool, including name, schema, and handler.
    server.registerTool( "run_applescript", { title: "Run AppleScript", description: "Executes an AppleScript command using osascript on macOS.", inputSchema: { script: z.string().describe("AppleScript code to execute.") } }, async ({ script }) => { return new Promise((resolve) => { const proc = spawn("osascript", ["-e", script]); let output = ""; let error = ""; proc.stdout.on("data", (data) => { output += data.toString(); }); proc.stderr.on("data", (data) => { error += data.toString(); }); proc.on("close", (code) => { const result = code === 0 ? (output.trim() || "Command executed successfully") : `Error: ${error.trim() || "Unknown error"}`; resolve({ content: [{ type: "text", text: result }] }); }); }); } );

Other Tools

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/Sai-Adarsh/coyote-mcp-server'

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