agentleFS
peakmojopeakmojo/applescript-mcp/CLAUDE.md

applescript-mcp

CLAUDE.md465 starsChanged 9 months agoMITView on GitHub

This is the AppleScript MCP (Model Context Protocol) Server - a dual-implementation MCP server that allows AI assistants to execute AppleScript on macOS systems. The server is available in both Node.js and Python implementations. Key Capabilities: - Execute AppleScript to interact with macOS applications (Notes, Calendar, Contacts, Messages, Mail, etc.) - Search files using Spotlight/Finder - Read/write file contents and execute shell commands - Remote execution via SSH - Docker support with host.docker.internal for Mac host access Both implementations provide…

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

13 rules. About 0 are common, 9 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Search files using Spotlight/Finder

    line 9
  2. Distinctive:

    Read/write file contents and execute shell commands

    line 10
  3. Distinctive:

    Keep implementations simple and minimal (currently <100 LOC for core logic)

    line 42
  4. Distinctive:

    Use proper error handling - return error messages rather than throwing

    line 43
  5. Distinctive:

    Always clean up temporary files

    line 44
  6. Very specific:

    Maintain Dual Implementation Parity: If you modify the Node.js version, apply equivalent changes to the Python version and vice versa.

    line 49
  7. Very specific:

    Test Both Implementations: Ensure changes work in both Node.js and Python versions.

    line 51
  8. Very specific:

    Version Synchronization: Keep versions consistent in package.json and pyproject.toml.

    line 53
  9. Distinctive:

    Update tool description in both implementations

    line 69
  10. Very specific:

    Add new parameters to the schema (use zod in Node.js)

    line 70
  11. Distinctive:

    Update README.md with examples

    line 72
  12. Distinctive:

    Test on both local and remote configurations

    line 73
  13. Distinctive:

    No sandboxing of AppleScript code

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

Project Overview

This is the AppleScript MCP (Model Context Protocol) Server - a dual-implementation MCP server that allows AI assistants to execute AppleScript on macOS systems. The server is available in both Node.js and Python implementations.

Key Capabilities:

  • Execute AppleScript to interact with macOS applications (Notes, Calendar, Contacts, Messages, Mail, etc.)
  • Search files using Spotlight/Finder
  • Read/write file contents and execute shell commands
  • Remote execution via SSH
  • Docker support with host.docker.internal for Mac host access

Architecture

Dual Implementation

The project provides two parallel implementations:

  1. Node.js (server.js): Primary implementation using @modelcontextprotocol/sdk
  2. Python (src/applescript_mcp/server.py): Alternative implementation using Python MCP SDK

Both implementations provide identical functionality and should be kept in sync.

Core Components

server.js (Node.js)

  • Main entry point: Implements MCP tool applescript_execute
  • Execution modes:
    • Local: Uses /usr/bin/osascript to run AppleScript files
    • Remote: Uses SSH (node-ssh) to execute on remote Mac hosts
  • Configuration via CLI args: --remoteHost, --remoteUser, --remotePassword
  • Logging via custom Logger class (levels: ERROR, WARN, INFO, DEBUG)

Key Functions:

  • executeAppleScript(code, timeout): Determines local vs remote execution
  • executeLocalAppleScript(code, timeout): Executes on local machine
  • executeRemoteAppleScript(code, timeout): Executes via SSH connection

Development Guidelines

Code Style

  • Keep implementations simple and minimal (currently <100 LOC for core logic)
  • Use proper error handling - return error messages rather than throwing
  • Always clean up temporary files
  • Log important operations at appropriate levels

When Making Changes

  1. Maintain Dual Implementation Parity: If you modify the Node.js version, apply equivalent changes to the Python version and vice versa.
  2. Test Both Implementations: Ensure changes work in both Node.js and Python versions.
  3. Version Synchronization: Keep versions consistent in package.json and pyproject.toml.
  4. Backward Compatibility: This is a published npm package, so maintain backward compatibility when possible.

Testing Considerations

  • macOS Required: AppleScript only works on macOS systems
  • Permissions: May require accessibility permissions for certain operations
  • Remote Testing: SSH testing requires:
    • macOS with Remote Login enabled
    • Valid SSH credentials
    • Network connectivity

Common Tasks

Adding New Features:

  1. Update tool description in both implementations
  2. Add new parameters to the schema (use zod in Node.js)
  3. Implement the feature in both execution paths (local + remote)
  4. Update README.md with examples
  5. Test on both local and remote configurations

Updating Dependencies:

  • Node.js: Update package.json and run npm install
  • Python: Update pyproject.toml and run uv lock

Publishing:

  • Node.js: npm publish (requires npm credentials)
  • Python: Follow Python packaging guidelines

Important Constraints

  1. Security:
    • AppleScript execution is inherently privileged
    • Remote execution stores credentials in config (consider security implications)
    • No sandboxing of AppleScript code
  2. Platform:
    • macOS only for local execution
    • Remote execution requires macOS target with SSH
  3. Timeout Handling:
    • Default: 60 seconds
    • Configurable via tool parameter
    • Timeout does not kill the process, just returns a timeout message
  4. Error Handling:
    • Errors are returned as text strings (not exceptions)
    • Both stdout and stderr are captured

File Structure

applescript-mcp/
├── server.js              # Node.js implementation (main entry)
├── src/
│   └── applescript_mcp/
│       ├── server.py      # Python implementation
│       └── __init__.py
├── package.json           # Node.js package config
├── pyproject.toml         # Python package config
├── README.md              # User documentation
└── LICENSE                # MIT License

MCP Tool Specification

Tool Name: applescript_execute

Parameters:

  • code_snippet (required): Multi-line AppleScript code to execute
  • timeout (optional): Execution timeout in seconds (default: 60)

Returns: Text output from AppleScript execution or error message

Template Variables (in code_snippet):

  • {{REMOTE_HOST}}: Replaced with configured remote host
  • {{REMOTE_USER}}: Replaced with configured remote user
  • {{REMOTE_PASSWORD}}: Replaced with configured remote password

Docker Support

The server detects Docker environments and supports host.docker.internal as a special hostname to access the Mac host from within a container. This requires:

  • SSH enabled on Mac host
  • Proper credentials configured
  • --remoteHost host.docker.internal argument

Logging

Set LOG_LEVEL environment variable to control verbosity:

  • ERROR: Only errors
  • WARN: Warnings and errors
  • INFO: General information (default)
  • DEBUG: Detailed debugging information

Logs are written to stderr to avoid interfering with MCP protocol communication on stdout.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.