Skip to main content
Glama
FutureAtoms

Agentic Control Framework (ACF)

by FutureAtoms

applescript_execute

Automate macOS tasks by executing AppleScript code to control applications and system functions.

Instructions

Run AppleScript (macOS)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
code_snippetYes
timeoutNo

Implementation Reference

  • Core handler function executeAppleScript() that writes AppleScript code to a temp file and executes it via osascript. Handles macOS check, timeout, temp file cleanup, and error cases.
    async function executeAppleScript(scriptCode, timeout = 60) {
      try {
        if (!scriptCode || typeof scriptCode !== 'string') {
          return { 
            success: false, 
            message: 'No AppleScript code provided' 
          };
        }
    
        // Check if we're on macOS
        if (os.platform() !== 'darwin') {
          return { 
            success: false, 
            message: 'AppleScript is only available on macOS' 
          };
        }
    
        logger.debug(`Executing AppleScript with timeout of ${timeout} seconds`);
    
        // Create a temporary file for the script
        const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'applescript-'));
        const scriptPath = path.join(tempDir, 'script.scpt');
        
        // Write the script to the temporary file
        await fs.writeFile(scriptPath, scriptCode, 'utf8');
    
        try {
          // Execute the AppleScript using osascript
          const { stdout, stderr } = await execAsync(
            `osascript "${scriptPath}"`,
            { 
              timeout: timeout * 1000,
              maxBuffer: 10 * 1024 * 1024 // 10MB buffer
            }
          );
    
          // Clean up the temporary file
          await fs.rm(tempDir, { recursive: true, force: true });
    
          if (stderr && stderr.trim()) {
            logger.warn(`AppleScript stderr: ${stderr}`);
          }
    
          return {
            success: true,
            output: stdout.trim(),
            error: stderr ? stderr.trim() : null,
            executionTime: new Date().toISOString()
          };
    
        } catch (error) {
          // Clean up the temporary file on error
          await fs.rm(tempDir, { recursive: true, force: true }).catch(() => {});
          
          if (error.killed && error.signal === 'SIGTERM') {
            return {
              success: false,
              message: `AppleScript execution timed out after ${timeout} seconds`,
              error: error.message
            };
          }
    
          // Parse AppleScript errors
          const errorMessage = error.message || error.toString();
          const errorOutput = error.stderr || '';
          
          return {
            success: false,
            message: 'AppleScript execution failed',
            error: errorMessage,
            details: errorOutput,
            code: error.code
          };
        }
    
      } catch (error) {
        logger.error(`Error executing AppleScript: ${error.message}`);
        return {
          success: false,
          message: `Error executing AppleScript: ${error.message}`,
          error: error.stack
        };
      }
    }
  • Registration/call dispatch: case 'applescript_execute' in the tools/call handler that invokes applescriptTools.executeAppleScript() with args.code_snippet and timeout.
    // AppleScript (macOS only)
    case 'applescript_execute': data = await applescriptTools.executeAppleScript(args.code_snippet, args.timeout || 60); break;
  • Input schema definition for 'applescript_execute' tool: requires code_snippet (string), optional timeout (number).
    { name:'applescript_execute', description:'Run AppleScript (macOS)', inputSchema:{ type:'object', properties:{ code_snippet:{type:'string'}, timeout:{type:'number'} }, required:['code_snippet'] } }
  • Module exports: executeAppleScript, executeTemplate (pre-built templates like getNotes, createNote, etc.), getAvailableTemplates, and templates object.
    module.exports = {
      executeAppleScript,
      executeTemplate,
      getAvailableTemplates,
      templates
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description does not disclose behavioral aspects such as return values, error handling, or required permissions (e.g., accessibility). With no annotations, this leaves significant gaps for an AI agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very short, which aids conciseness, but it omits crucial details, making it under-specified. Not an efficient balance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description fails to provide sufficient context about execution behavior, output, or risks associated with running arbitrary AppleScript code.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no meaning beyond the parameter names. For code_snippet, it doesn't specify format or language version; for timeout, units are missing. Schema coverage is 0%.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it runs AppleScript on macOS, which is specific and distinguishes from sibling tools like execute_command (shell) or browser tools. However, it is almost a tautology of the tool name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as execute_command or browser automation. The description lacks context on prerequisites or scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/FutureAtoms/agentic-control-framework'

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