MCP HubMCP Hub
joshrutkowski

applescript-mcp

by: joshrutkowski

A macOS AppleScript MCP server

135created 01/12/2024
Visit
macOS
AppleScript

📌Overview

Purpose: To provide a Model Context Protocol server enabling LLM applications to interact with macOS functionalities through AppleScript.

Overview: The applescript-mcp MCP Server streamlines communication between AI applications and macOS, allowing for control over various system functions, file management, notifications, and more via a standardized interface.

Key Features:

  • Calendar Management: Facilitates event and reminder handling, enabling users to manage their schedules efficiently.

  • Clipboard Operations: Allows copying, retrieving, and clearing of clipboard contents, enhancing information management capabilities.

  • Finder Integration: Users can quickly access files through commands for searching and selecting, improving productivity.

  • System Notifications: Enables sending notifications and toggling Do Not Disturb mode, keeping users informed without interruptions.

  • System Controls: Provides commands to control system settings like volume and dark mode, offering seamless user experience customization.

  • iTerm Integration: Supports executing commands and pasting content in iTerm, making terminal operations more accessible.


applescript-mcp MCP Server

A Model Context Protocol server that enables LLM applications to interact with macOS through AppleScript. This server provides a standardized interface for AI applications to control system functions, manage files, handle notifications, and more.

Features

  • Calendar management (events, reminders)
  • Clipboard operations
  • Finder integration
  • System notifications
  • System controls (volume, dark mode, apps)
  • iTerm terminal integration

Planned Features

  • Mail (list emails, save attachments, summarize, send)
  • Safari (open in Safari, save page content, get selected page/tab)
  • Messages (send, get, list)
  • Reminders (create, get)
  • Notes (create, get, list)

Prerequisites

  • macOS 10.15 or later
  • Node.js 18 or later

Available Categories

Calendar

CommandDescriptionParameters
addCreate calendar eventtitle, startDate, endDate
listList today's eventsNone

Clipboard

CommandDescriptionParameters
set_clipboardCopy to clipboardcontent
get_clipboardGet clipboard contentsNone
clear_clipboardClear clipboardNone

Finder

CommandDescriptionParameters
get_selected_filesGet selected filesNone
search_filesSearch for filesquery, location
quick_lookPreview filepath

Notifications

CommandDescriptionParameters
send_notificationShow notificationtitle, message, sound
toggle_do_not_disturbToggle DND modeNone

System

CommandDescriptionParameters
volumeSet system volumelevel (0-100)
get_frontmost_appGet active appNone
launch_appOpen applicationname
quit_appClose applicationname, force
toggle_dark_modeToggle dark modeNone

iTerm

CommandDescriptionParameters
paste_clipboardPaste to iTermNone
runExecute commandcommand, newWindow

Development

Setup

npm install
npm run build
npx @modelcontextprotocol/inspector node path/to/server/index.js args...

Adding New Functionality

  1. Create Category File

    import { ScriptCategory } from "../types/index.js";
    
    export const newCategory: ScriptCategory = {
      name: "category_name",
      description: "Category description",
      scripts: []
    };
    
  2. Add Scripts

    {
      name: "script_name",
      description: "What the script does",
      schema: {
        type: "object",
        properties: {
          paramName: {
            type: "string",
            description: "Parameter description"
          }
        },
        required: ["paramName"]
      },
      script: (args) => `
        tell application "App"
          // AppleScript code using ${args.paramName}
        end tell
      `
    }
    
  3. Register Category

    import { newCategory } from "./categories/newcategory.js";
    server.addCategory(newCategory);
    

Debugging

Using MCP Inspector

npm run inspector

Logging

Enable debug logging:

DEBUG=applescript-mcp* npm start

Common Issues

  • Permission Errors: Check System Preferences > Security & Privacy
  • Script Failures: Test scripts in Script Editor.app
  • Communication Issues: Check stdio streams aren't redirected

Resources

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT License - see LICENSE for details