Skip to main content
Glama
TrueOleg

MCP Mac Apps Server

by TrueOleg

run_applescript

Execute AppleScript commands in macOS applications to automate tasks and control app behavior programmatically.

Instructions

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

Input Schema

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

Implementation Reference

  • TypeScript handler that constructs and executes AppleScript targeting the specified application using osascript command.
    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)}`
        );
      }
    }
  • Python handler that constructs and executes AppleScript targeting the specified application using osascript command.
    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 input schema definition for the run_applescript tool.
    name: "run_applescript",
    description:
      "Выполняет AppleScript команду в указанном приложении. Полезно для автоматизации действий в приложениях",
    inputSchema: {
      type: "object",
      properties: {
        appName: {
          type: "string",
          description: "Имя приложения (например, 'Safari', 'Finder')",
        },
        script: {
          type: "string",
          description: "AppleScript команда для выполнения",
        },
      },
      required: ["appName", "script"],
    },
  • Python input schema definition for the run_applescript tool.
    "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"],
    },
  • src/index.ts:314-318 (registration)
    TypeScript switch case dispatching to the runAppleScript handler.
    case "run_applescript":
      return await this.runAppleScript(
        args?.appName as string,
        args?.script as string
      );

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