macos-computer-use

macos-computer-use

An ultra-fast native MCP server for macOS desktop automation, enabling visual OCR, text-based clicking, window management, and keyboard/mouse control without hijacking the physical cursor.

Category
访问服务器

README

🍏 macOS Computer Use (MCP Server)

License: MIT Platform Model Context Protocol

An ultra-fast, native Model Context Protocol (MCP) server that gives LLMs and autonomous agents visual inspection and fail-closed desktop automation on macOS.

Built with a compiled Swift core leveraging Apple's native CoreGraphics, Vision OCR (VNRecognizeTextRequest), and Accessibility APIs for semantic background actions. Untargeted input remains an explicit global CoreGraphics fallback.


⚡ Key Highlights

  • 🎯 Native Apple Vision OCR (find_text / click_text): Finds visible text with explicit exact, word, prefix, or substring matching and refuses ambiguous clicks unless an occurrence is selected.
  • 🛡️ Fail-Closed Targeting: windowId is authoritative. Invalid IDs and app/window mismatches return errors instead of falling back to another window or the full display.
  • ♿ Accessibility Actions: Targeted clicks invoke AXPress, targeted scrolling adjusts AX scrollbars, and exact-window typing focuses the requested AX window before process delivery.
  • 🖱️ Live Agent Cursor: Clicks and scrolling glide a distinctive, click-through cursor overlay to the target, show success or failure feedback, and fade when idle without moving your physical pointer.
  • 👁️ Matching Screenshot Cursor (mark_cursor): Returned action screenshots render the same agent cursor at the target coordinate.
  • ⚡ Reactive UI Synchronization (wait_for_text): Replaces blind sleep() timeouts with a high-speed OCR polling loop that resolves the instant dynamic autocomplete dropdowns, modals, or state changes appear.
  • 🖼️ Window-Isolated Screen Capture: Captures target application buffers cleanly in the background (screencapture -l <wid> -o -x) without bringing the window to the front or capturing overlapping windows.

🛠️ Tools Exposed

Tool Description Key Parameters
click_text Finds OCR text, glides the live cursor to it, resolves ambiguity, and invokes the matching Accessibility control. text, matchMode, occurrence, appName, windowId, returnScreenshot
find_text Inspects on-screen or window-specific text and returns exact bounding boxes and logical coordinates. text, appName (optional), windowId (optional)
wait_for_text Reactively polls the target window/screen until expected text appears (autocomplete dropdowns, toasts, sheets). text, appName (optional), timeoutSeconds (default: 5.0)
screenshot Captures the entire display or a specific background application window with optional virtual cursor rendering. appName, windowId, maxWidth, format (jpeg | png), cursor ({x, y})
list_windows Lists open application windows, process IDs (pid), titles, and coordinate bounds in front-to-back Z-order. appName (optional filter)
mouse_click Glides the live cursor to (x, y), then invokes the targeted AX control or performs an explicit global click. x, y, appName, windowId, relativeCoords, button, clickCount
type_text Types into the active app or focuses an exact AX window before background process delivery. text, appName (optional), windowId (optional)
press_key Presses special keys or keyboard shortcuts with modifiers. key (return, space, tab, escape, c, etc.), modifiers (command, shift, option, control)
scroll Glides the live cursor to the target and adjusts an AX scrollbar; without a target, scrolls globally. x, y, deltaY, deltaX, appName, windowId
launch_app Launches or brings a macOS application to the front. appName (e.g. Google Chrome, Safari, Finder, Slack, Notes)
get_active_app Returns the currently active frontmost application name and window title. None
run_applescript Runs custom AppleScript for deep macOS Accessibility and UI hierarchy inspection. script

🚀 Installation & Setup

Run with npx

Configure an MCP client to download, build, and launch the latest public package:

{
  "mcpServers": {
    "macos-computer-use": {
      "command": "npx",
      "args": ["-y", "macos-computer-use-mcp"]
    }
  }
}

The package includes an ad-hoc-signed universal Swift helper for Apple Silicon and Intel Macs, so npx does not require a local Swift compiler or install-script approval.

1. Prerequisites

  • macOS 13.0+ (Apple Silicon or Intel)
  • Node.js 20+
  • Xcode Command Line Tools only when building from source:
    xcode-select --install
    

2. Clone & Build

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

🔒 Required macOS Permissions

To allow desktop capture and input simulation, grant your host application (Terminal, iTerm2, Antigravity, Cursor, or VS Code) permissions in System Settings > Privacy & Security:

  1. Screen & System Audio Recording: Required for screenshot and visual OCR.
  2. Accessibility: Required for mouse_click, type_text, and press_key.

🔌 MCP Configuration

Add this server to your MCP client configuration:

Antigravity / Claude Desktop / Cursor / Windsurf

Add to your mcp_config.json / claude_desktop_config.json:

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

🧪 Testing the Native Swift Helper Directly

You can test the native binary directly from your terminal:

# 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

Run the automated fail-closed and matching regressions:

npm test

With Calculator, System Settings, and two TextEdit windows open, run the live native-app smoke suite:

npm run test:live

Mutating actions return status: "delivered_unverified". Verify the expected post-state with wait_for_text, find_text, or a screenshot before continuing.

The MCP server starts one cursor overlay process lazily on the first click or scroll and stops it when the MCP connection closes. The overlay never intercepts mouse input, joins all Spaces and full-screen windows, and reports cursorOverlay.status: "unavailable" without blocking the requested action if AppKit cannot display it.


📄 License

MIT © John Oba

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选