AppleScript MCP服务器(双访问:python和node.js)
概述
一个模型上下文协议(MCP)服务器,允许您运行AppleScript代码与Mac交互。此MCP有意设计为简单、直接、直观,并且需要最少的设置。
我简直不敢相信它有多简单和强大。核心代码是<100行代码。
https://github.com/user-attachments/assets/b85e63ba-fb26-4918-8e6d-2377254ee388
特性
- 运行AppleScript以访问Mac应用程序和数据
- 与笔记、日历、通讯录、消息等进行交互
- 使用Spotlight或Finder搜索文件
- 读取/写入文件内容并执行shell命令
- 通过SSH远程执行支持
示例提示
1Create a reminder for me to call John tomorrow at 10am
1Add a new meeting to my calendar for Friday from 2-3pm titled "Team Review"
1Create a new note titled "Meeting Minutes" with today's date
1Show me all files in my Downloads folder from the past week
1What's my current battery percentage?
1Show me the most recent unread emails in my inbox
1List all the currently running applications on my Mac
1Play my "Focus" playlist in Apple Music
1Take a screenshot of my entire screen and save it to my Desktop
1Find John Smith in my contacts and show me his phone number
1Create a folder on my Desktop named "Project Files"
1Open Safari and navigate to apple.com
1Tell me how much free space I have on my main drive
1List all my upcoming calendar events for this week
使用Claude Desktop
Node.js
JSON``` 1 2 3 4 5 6 7 8 9 10{ “mcpServers”: { “applescript_execute”: { “command”: “npx”, “args”: [ “@peakmojo/applescript-mcp” ] } } }
### Python(uvx)
无需克隆——直接从git仓库运行:
JSON```
1
2
3
4
5
6
7
8
9
10
11
12{
"mcpServers": {
"applescript_execute": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/peakmojo/applescript-mcp",
"mcp-server-applescript"
]
}
}
}
Python(本地开发)
对于本地开发,克隆repo并使用 uv 从源代码运行:
1
2brew install uv
git clone https://github.com/peakmojo/applescript-mcp.git
JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13{ “mcpServers”: { “applescript_execute”: { “command”: “uv”, “args”: [ “—directory”, “/path/to/your/repo”, “run”, “mcp-server-applescript” ] } } }
## 发展
### 设置
BASH```
1
2brew install uv
uv sync --dev
运行所有检查(并行)
BASH``` 1uv run check
这将并行运行linting、格式化、类型检查和100%覆盖率的测试。
### 单个命令
BASH```
1
2
3
4uv run lint # ruff linter
uv run format # ruff auto-format
uv run typecheck # pyrefly type checker
uv run test # pytest with 100% coverage enforcement
Docker使用
在Docker容器中运行时,可以使用特殊的主机名 host.docker.internal 要连接到Mac主机:
配置
JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13{ “mcpServers”: { “applescript_execute”: { “command”: “npx”, “args”: [ “@peakmojo/applescript-mcp”, “—remoteHost”, “host.docker.internal”, “—remoteUser”, “yourusername”, “—remotePassword”, “yourpassword” ] } } }
这允许你的Docker容器在Mac主机系统上执行AppleScript。确保:
1. 您的Mac上已启用SSH(系统设置→ 共享→ 远程登录)
2. 您的用户具有适当的权限
3. 配置中提供了正确的凭据