macos-mcp操作程序v1.1
适用于macOS 14+桌面自动化的本地MCP(模型上下文协议)服务器,针对单用户自主机工作流进行了优化。
v1.1中发生了什么变化
- 批准/令牌流已禁用(
risk_class和confirmation_token为了兼容性而忽略)。 - AppleScript的执行现在通过本地代理主机进程进行(
macos-mcp-operator-host)通过Unix套接字。 - 添加了权限工具:
- permissions_status - permissions_probe_automation - permissions_open_settings
set_safety_mode和update_app_whitelist作为已弃用的no-op工具保持可用。
构建
swift build -c release二进制路径:
.build/release/macos-mcp-operator
.build/release/macos-mcp-operator-host权限
向主机应用程序/进程授予权限:
- 可访问性(鼠标/键盘控制)
- 屏幕录制(
screen_capture) - 自动化(苹果活动,特定于目标应用程序)
如果缺少权限,工具调用将返回显式错误代码/消息,例如:
ACCESSIBILITY_MISSINGSCREEN_RECORDING_MISSINGAUTOMATION_NOT_ALLOWEDBROKER_UNAVAILABLE
配置
路径:
~/.config/macos-mcp-operator/config.json
v1.1默认形状:
{
"default_mode": "restricted",
"app_whitelist": [
"com.apple.Notes"
],
"sensitive_bundle_ids": [
"com.apple.systempreferences"
],
"dangerous_key_chords": [
["cmd", "q"],
["cmd", "w"],
["cmd", "delete"]
],
"audit_enabled": true,
"kill_switch_hotkey": "ctrl+opt+cmd+.",
"approval_enabled": false,
"execution_backend": "broker",
"broker": {
"bundle_id": "com.jianruicheng.macos-mcp-operator.host",
"app_path": "~/Applications/macos-mcp-operator-host.app",
"socket_path": "~/.local/share/macos-mcp-operator/broker.sock",
"launch_agent_label": "com.jianruicheng.macos-mcp-operator.host"
}
}审核日志路径:
~/Library/Logs/macos-mcp-operator/audit.jsonl
工具
set_safety_mode(不推荐使用op)update_app_whitelist(不推荐使用op)list_windowsfocus_windowmouse_movemouse_clickmouse_dragmouse_scrolltext_inputkey_chordscreen_captureapp_launchapp_open_urlapp_open_pathapp_quitapplescript_run(经纪人支持)applescript_app_command(经纪人支持)permissions_statuspermissions_probe_automationpermissions_open_settingsautomation_stop
聚焦行为和目标控制
输入工具现在可以针对特定的应用程序/窗口,而无需始终强制前台切换。
focus_window
- 新的可选标志: activate_all_windows (默认值: false) - 集 true 使用激活目标应用程序所有窗口的传统行为。
mouse_click,mouse_drag,mouse_scroll,text_input,key_chord
- 新的可选字段: - bundle_id - window_id - auto_focus (默认值: false) - launch_if_needed (默认值: false) - 行为: - 如果没有提供目标,则命令将应用于当前最前端的应用程序(传统行为)。 - 如果提供了目标,但不是最前面的: - auto_focus=false ->退货 TARGET_NOT_FRONTMOST. - auto_focus=true ->先聚焦目标,然后执行。
例子:
{
"name": "text_input",
"arguments": {
"text": "hello",
"bundle_id": "com.apple.Notes",
"auto_focus": true
}
}脚本
scripts/package-host-app.sh
- 构建和打包 ~/Applications/macos-mcp-operator-host.app - 安装/启动LaunchAgent: com.jianruicheng.macos-mcp-operator.host
scripts/sign-host-app.sh
- 签署主机应用程序 - 自动检测团队ID(MW4GWYGX56)并尽可能匹配身份
scripts/install-claude-mcp.sh
- 更新: - ~/Library/Application Support/Claude/claude_desktop_config.json - ~/.claude.json - 与验证 claude mcp get macos-mcp-operator
建议的安装顺序
./scripts/package-host-app.sh
./scripts/sign-host-app.sh
./scripts/install-claude-mcp.sh权限恢复手册
快速打开设置页面:
- 可访问性:
- open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"
- 屏幕录制:
- open "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"
- 自动化:
- open "x-apple.systempreferences:com.apple.preference.security?Privacy_Automation"
如果需要,重置TCC条目(您需要重新授予):
tccutil reset Accessibility com.jianruicheng.macos-mcp-operator.host
tccutil reset ScreenCapture com.jianruicheng.macos-mcp-operator.host
tccutil reset AppleEvents com.jianruicheng.macos-mcp-operator.hostMCP协议版本
支持的协议版本(从最新到最旧):
2025-11-252025-06-182025-03-26
