Skip to main content
Glama
johnexzy

macos-computer-use

by johnexzy

🍏 macOS Computer Use (MCP Server)

License: MIT Platform Model Context Protocol

一个超快、原生的 模型上下文协议(MCP) 服务器,为 LLM 和自主智能体提供完整的视觉检查和桌面自动化能力,且 不会劫持你的物理硬件鼠标或键盘焦点

基于编译的 Swift 核心构建,利用 Apple 原生的 CoreGraphicsVision OCR(VNRecognizeTextRequest 以及直接的进程级事件路由(CGEvent.postToPid)。


⚡ 主要亮点

  • 🎯 低于 30ms 的 Apple Vision OCR(find_text / click_text:无需盲猜 $(x, y)$ 坐标。智能体通过名称即可找到按钮、标签和文本占位符,并借助 Apple Neural Engine 加速实现像素级精度。

  • 🛡️ 非侵入式后台执行:与全局 macOS 硬件事件监听解耦。点击、滚动和按键可以直接定向到特定应用的 PID,同时你可以继续在 IDE 或浏览器中工作。

  • 👁️ 虚拟光标叠加层(mark_cursor:智能体的目标坐标会被可视地绘制到截图帧上(青色目标环 + 洋红色脉冲点),而不会在屏幕上移动你的物理鼠标。

  • ⚡ 响应式 UI 同步(wait_for_text:用高速 OCR 轮询循环取代盲目的 sleep() 超时,一旦动态自动补全下拉框、模态框或状态变化出现,立即得到解析。

  • 🖼️ 窗口隔离截屏:在后台干净地捕获目标应用缓冲区(screencapture -l <wid> -o -x),不会把窗口带到前台,也不会捕获重叠的窗口。


🛠️ 暴露的工具

工具

描述

关键参数

click_text

通过 Apple Vision OCR 查找任意按钮、标签或 UI 文本,并平滑点击其精确中心。

text, appName(可选), windowId(可选), button, clickCount, returnScreenshot

find_text

检查屏幕或指定窗口中的文本,并返回精确的边界框和逻辑坐标。

text, appName(可选), windowId(可选)

wait_for_text

响应式轮询目标窗口/屏幕,直到预期文本出现(自动补全下拉框、提示条、弹窗等)。

text, appName(可选), timeoutSeconds(默认:5.0)

screenshot

捕获整个显示器或指定的后台应用窗口,支持可选的虚拟光标渲染。

appName, windowId, maxWidth, formatjpeg | png), cursor{x, y}

list_windows

列出打开的应用窗口、进程 ID(pid)、标题以及从前到后的 Z 顺序坐标边界。

appName(可选筛选)

mouse_click

在逻辑 (x, y) 坐标处点击(支持窗口相对定位和按 PID 定向路由)。

x, y, appName, windowId, relativeCoords, button, clickCount

mouse_move

平滑地将鼠标光标移动到 (x, y) 坐标。

x, y, appName, relativeCoords, smooth, duration

mouse_drag

平滑地将鼠标从 (startX, startY) 拖拽到 (endX, endY)

startX, startY, endX, endY, duration

type_text

将纯文本注入活动输入字段(或直接注入目标进程队列)。

text, appName(可选), windowId(可选)

press_key

按下特殊按键或带修饰键的键盘快捷键。

keyreturnspacetabescapec 等), modifierscommandshiftoptioncontrol

scroll

在垂直和水平方向上滚动鼠标滚轮。

x, y, deltaY, deltaX, appName, windowId

launch_app

启动或前置一个 macOS 应用。

appName(例如 Google ChromeSafariFinderSlackNotes

get_active_app

返回当前处于活动状态的最前端应用名称和窗口标题。

run_applescript

运行自定义 AppleScript,用于深度 macOS 辅助功能和 UI 层级检查。

script


🚀 安装与设置

1. 前提条件

  • macOS 13.0+(Apple Silicon 或 Intel)

  • Node.js 18+

  • Xcode Command Line Tools(用于编译原生 Swift 二进制文件):

    xcode-select --install

2. 克隆与构建

git clone https://github.com/johnexzy/macos-computer-use.git
cd macos-computer-use
npm install

postinstall 脚本会自动将 native_helper.swift 编译为优化的原生二进制文件)。


🔒 必需的 macOS 权限

要允许桌面捕获和输入模拟,请在 系统设置 > 隐私与安全性 中为你的宿主应用(Terminal、iTerm2、Antigravity、Cursor 或 VS Code)授予权限:

  1. 屏幕与系统音频录制screenshot 和视觉 OCR 所必需。

  2. 辅助功能mouse_clicktype_textpress_key 所必需。


🔌 MCP 配置

将此服务器添加到你的 MCP 客户端配置中:

Antigravity / Claude Desktop / Cursor / Windsurf

添加到你的 mcp_config.json / claude_desktop_config.json 中:

{
  "mcpServers": {
    "macos-computer-use": {
      "command": "node",
      "args": ["/absolute/path/to/macos-computer-use/server.mjs"]
    }
  }
}

🧪 直接测试原生 Swift 辅助程序

你可以直接从终端测试原生二进制文件:

# Display resolution and scaling
./native_helper size

# List active Chrome windows in Z-order
./native_helper list_windows "Google Chrome"

# Find a button or text on screen with Apple Vision OCR in ~30ms
./native_helper find_text "Search" "Google Chrome"

# Reactively wait for dynamic text to appear
./native_helper wait_for_text "quantum" "Google Chrome" nil 5.0

📄 许可证

MIT © John Oba

-
license - not tested
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.

  • MCP connector that lets ChatGPT list, search, and run your Apple Shortcuts via a local Mac agent

  • Let ChatGPT, Claude & Cursor use your Mac: email, calendar, iMessage, Teams, files. Local, free.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/johnexzy/macos-computer-use'

If you have feedback or need assistance with the MCP directory API, please join our Discord server