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
- Distinctive: line 9
Search files using Spotlight/Finder
- Distinctive: line 10
Read/write file contents and execute shell commands
- Distinctive: line 42
Keep implementations simple and minimal (currently <100 LOC for core logic)
- Distinctive: line 43
Use proper error handling - return error messages rather than throwing
- Distinctive: line 44
Always clean up temporary files
- Very specific: line 49
Maintain Dual Implementation Parity: If you modify the Node.js version, apply equivalent changes to the Python version and vice versa.
- Very specific: line 51
Test Both Implementations: Ensure changes work in both Node.js and Python versions.
- Very specific: line 53
Version Synchronization: Keep versions consistent in package.json and pyproject.toml.
- Distinctive: line 69
Update tool description in both implementations
- Very specific: line 70
Add new parameters to the schema (use zod in Node.js)
- Distinctive: line 72
Update README.md with examples
- Distinctive: line 73
Test on both local and remote configurations
- Distinctive: line 88
No sandboxing of AppleScript code
≈ “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.
Files
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.internalfor Mac host access
Architecture
Dual Implementation
The project provides two parallel implementations:
- Node.js (
server.js): Primary implementation using@modelcontextprotocol/sdk - 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/osascriptto run AppleScript files - Remote: Uses SSH (node-ssh) to execute on remote Mac hosts
- Local: Uses
- 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 executionexecuteLocalAppleScript(code, timeout): Executes on local machineexecuteRemoteAppleScript(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
- Maintain Dual Implementation Parity: If you modify the Node.js version, apply equivalent changes to the Python version and vice versa.
- Test Both Implementations: Ensure changes work in both Node.js and Python versions.
- Version Synchronization: Keep versions consistent in
package.jsonandpyproject.toml. - 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:
- Update tool description in both implementations
- Add new parameters to the schema (use zod in Node.js)
- Implement the feature in both execution paths (local + remote)
- Update README.md with examples
- 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
- Security:
- AppleScript execution is inherently privileged
- Remote execution stores credentials in config (consider security implications)
- No sandboxing of AppleScript code
- Platform:
- macOS only for local execution
- Remote execution requires macOS target with SSH
- Timeout Handling:
- Default: 60 seconds
- Configurable via tool parameter
- Timeout does not kill the process, just returns a timeout message
- 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 LicenseMCP Tool Specification
Tool Name: applescript_execute
Parameters:
code_snippet(required): Multi-line AppleScript code to executetimeout(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.internalargument
Logging
Set LOG_LEVEL environment variable to control verbosity:
ERROR: Only errorsWARN: Warnings and errorsINFO: General information (default)DEBUG: Detailed debugging information
Logs are written to stderr to avoid interfering with MCP protocol communication on stdout.
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
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.

