MCP AppleScript
Enables Large Language Models to automate macOS applications and execute AppleScript commands through natural language. It features built-in security protections including application allowlists and dangerous pattern detection to prevent unauthorized or risky system operations.
README
MCP AppleScript
An MCP (Model Context Protocol) server that enables Large Language Models to execute AppleScript commands on macOS. This allows LLMs to interact with and automate macOS applications through natural language requests.
Features
- Execute AppleScript commands from LLM applications
- Application allowlist for controlled access to specific apps
- Dangerous pattern detection to block risky operations
- Configurable timeout protection
- Built on FastMCP for easy integration
Installation
Using uv:
uv pip install mcp-applescript
Or install from source:
git clone https://github.com/pietz/mcp-applescript.git
cd mcp-applescript
uv sync
Usage
Running the Server
mcp-applescript
The server runs using stdio transport, making it compatible with any MCP client.
Available Tools
run_applescript
Execute an AppleScript command on macOS.
Parameters:
script(string): The AppleScript code to execute
Returns:
- String output from the script execution
- Raises error if script fails validation or execution
Example:
tell application "Mail"
get subject of first message of inbox
end tell
get_server_status
Get the current server configuration and security settings.
Returns:
- Server version and configuration
- Allowed applications list
- Security settings (dangerous pattern blocking, timeout)
- Environment variable documentation
Example Response:
{
"server": "MCP AppleScript",
"version": "0.1.0",
"security": {
"allowed_apps": ["Mail", "Calendar"],
"block_dangerous": true,
"timeout_seconds": 30
}
}
Configuration
MCP Client Setup
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"applescript": {
"command": "mcp-applescript",
"env": {
"ALLOWED_APPS": "mail,calendar,contacts,notes",
"BLOCK_DANGEROUS": "true"
}
}
}
}
Environment Variables
ALLOWED_APPS (optional)
- Comma-separated list of allowed applications (case-insensitive)
- Example:
"mail,calendar,contacts"(lowercase recommended) - Not set (default): Allows all applications (
"*") "*": Explicitly allows all applications""(empty string): Blocks all applications (lockdown mode)- Security Note: Set this to restrict access to specific apps only
- App names are automatically normalized to title case for AppleScript
BLOCK_DANGEROUS (optional)
- Enable/disable dangerous pattern detection
- Values:
"true"or"false" - Default:
"true" - Blocks patterns like:
do shell script, file system access, system control commands
TIMEOUT (optional)
- Script execution timeout in seconds
- Default:
"30"
Security Profiles
Default (Out of the Box)
"env": {
// ALLOWED_APPS not set = allow all apps
"BLOCK_DANGEROUS": "true" // This is the default, can be omitted
}
- ✅ Works immediately without configuration
- ✅ Dangerous operations blocked
- ⚠️ Can access any application
Strict (Recommended for Production)
"env": {
"ALLOWED_APPS": "mail,calendar,contacts",
"BLOCK_DANGEROUS": "true"
}
- ✅ Limited to specific applications
- ✅ Dangerous operations blocked
- ✅ Best security posture
Permissive (Development/Testing Only)
"env": {
"ALLOWED_APPS": "*", // or omit this line
"BLOCK_DANGEROUS": "false"
}
- ⚠️ Can access any application
- ⚠️ Dangerous operations allowed
- ⚠️ Use only in trusted environments
Lockdown (Explicit Block)
"env": {
"ALLOWED_APPS": "" // Empty string = block all
}
- 🔒 Blocks all AppleScript execution
- Useful for temporary disabling
Security
Built-in Protections
-
Application Allowlist (optional)
- Default: All applications allowed (for usability)
- Configure
ALLOWED_APPSto restrict to specific applications - Prevents unauthorized access to system apps when configured
-
Dangerous Pattern Detection
- Blocks shell command execution (
do shell script) - Prevents system control operations (shutdown, restart, logout)
- Blocks access to sensitive paths (
/System,/Library,~/.ssh) - Detects potential phishing (password dialogs)
- Prevents file deletion operations
- Blocks shell command execution (
-
Execution Timeout
- Prevents infinite loops and hanging scripts
- Configurable timeout duration
Blocked Operations Examples
-- ❌ BLOCKED: Shell command execution
do shell script "rm -rf ~/"
-- ❌ BLOCKED: System control
tell application "System Events" to shut down
-- ❌ BLOCKED: Sensitive file access
do shell script "cat ~/.ssh/id_rsa"
-- ❌ BLOCKED: Unauthorized application (if not in ALLOWED_APPS)
tell application "Terminal" to do script "echo test"
-- ✅ ALLOWED: Reading from allowed app
tell application "Mail"
get subject of first message of inbox
end tell
Best Practices
- Configure application allowlist: Set
ALLOWED_APPSto only the applications you need for production use - Keep dangerous blocking enabled: Default is on - provides essential protection
- Review server status: Use
get_server_statustool to understand current configuration - Principle of least privilege: In production, only allow the minimum necessary applications
- Start permissive, then restrict: Begin with defaults, then lock down based on actual usage
Usage Examples
Check Server Configuration
Before running scripts, check what's allowed:
User: "What can you access on my system?"
LLM uses: get_server_status()
Response: "I can currently access: Mail, Calendar, and Contacts.
Dangerous operations are blocked, and scripts timeout after 30 seconds."
Read Mail (Allowed)
tell application "Mail"
get subject of first message of inbox
end tell
Get Calendar Events (Allowed)
tell application "Calendar"
get summary of every event of calendar "Work"
end tell
System Information (Blocked - Security)
-- This will be BLOCKED if "System Events" not in ALLOWED_APPS
tell application "System Events"
name of first process whose frontmost is true
end tell
Display Notification (Safe)
-- Safe if no dangerous patterns
display notification "Hello from MCP!" with title "AppleScript"
Requirements
- Python >= 3.12
- macOS (AppleScript is macOS-only)
- mcp >= 1.13.1
License
MIT
Author
Paul-Louis Pr�ve
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。