Skip to main content
Glama
macos-computer-use

macos-computer-use

by johnexzy

macOS Computer Use

License: MIT Platform Model Context Protocol

A native Model Context Protocol (MCP) server for macOS inspection and desktop automation.

The Rust + Swift rebuild runs alongside the existing Node/Swift server. It now supports semantic observations and a narrow background action path. The native installation and migration guide covers the standalone universal archive, client configuration, compatibility gaps, rollback and release checks; its end-user binaries require no Node or local compiler.

For a drag-and-drop local install, see the native disk image and setup instructions. The brand kit contains the logo and usage guide.

Rust runtime tool

Implemented scope

capabilities

Permission preflight and supported action kinds without permission prompts.

targets

Exact process/window keys for visible application windows.

observe

Bounded AX controls with retained refs, optional selected scope and bounded selected-state history; on-demand window capture/OCR. AX values are private by default.

act

Up to 16 semantic actions or waits per request with separate delivery and verification receipts. An explicitly authorized foreground sequence can use keys or clicks with waits.

waitFor

Wait for presence, absence, enabled state, exact value, or exact window-key absence; closed-window proof needs no new observation.

The runtime associates CG and AX windows through a unique PID, exact logical bounds, and available titles. Each action revalidates the retained AX object, owning window, observed role and subrole, and raw AX identifier. On macOS 14+, opt-in screenshots and Vision OCR return mapped visual evidence. macOS 13 supports the semantic route. Foreground keys and clicks require an operator grant and explicit per-sequence selection.

Sequences use one target, one original observation, and one whole-request deadline. Settled progress is written before the next input step. References keep their original 60-second expiry. Optional feedback reports bounded changes to requested public projections using the same refs; feedback: null means unavailable, not unchanged. Values require explicit inclusion. Read-only waits never claim input dispatch.

npm run build:runtime
npm run start:rust

Set CUA_VISUAL_FEEDBACK=1 to show a window marker, agent pointer, and writing cues while the native server works. Set CUA_LIVE_PREVIEW=1 to watch the selected window and its attached sheet in a local floating panel. See on-screen feedback and live preview for MCP setup.

For automated checks, run npm run test:runtime. To exercise the installed pair against only the disposable fixture:

sh test/fixtures/macos/build.sh
node test/runtime/semantic-live.mjs --repetitions 3
node test/runtime/composition-live.mjs --repetitions 3

The live runners record setup separately from graded scenario latency. The composition campaign covers bounded sequences and fault handling; evaluation.md describes the separate matched scripted/model comparison. See runtime.md for execution, privacy, locking, and evidence boundaries. npm run test:foundations and the baseline:* commands remain available for the legacy comparison.

Existing Node/Swift server

The npm entry point (server.mjs, including npx macos-computer-use-mcp) still starts the existing server described below. The new Rust pair is launched explicitly with npm run start:rust or its installed executable.

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.


Related MCP server: ScreenHand

⚡ 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.

  • 🔐 Safe by Default: Global pointer/keyboard input, foreground app activation, and custom AppleScript are disabled unless the MCP process starts with MACOS_COMPUTER_USE_UNSAFE=1.

  • 🩺 Permission Preflight: get_capabilities reports Accessibility, Screen Recording, and event-synthesis readiness without calling macOS permission request APIs.

  • ♿ Background Accessibility Actions: Inspect controls, set values, press semantic actions, and target editable controls without activating their application.

  • ⏱️ Semantic Background Waiting: Waits for Accessibility controls to appear without taking a screenshot or requiring Screen Recording.

  • 🖱️ 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})

get_capabilities

Reports permission readiness, platform details, and the active safe/unsafe policy without requesting access.

None

list_windows

Lists open application windows, process IDs (pid), titles, and coordinate bounds in front-to-back Z-order.

appName (optional filter)

inspect_accessibility

Reads semantic controls from an exact background window. Values are private by default and require includeValues: true.

appName or windowId, selector, roles, maxResults

wait_for_accessibility

Waits for one or more semantic controls in an exact background window.

appName or windowId, selector, minCount, timeoutMs

set_accessibility_value

Sets a semantic control value while checking that the target stayed in the background.

appName or windowId, selector, value

perform_accessibility_action

Performs press, focus, confirm, cancel, increment/decrement, or menu actions without activating the target app.

appName or windowId, selector, action

mouse_click

Glides the live cursor to (x, y), then invokes the targeted AX control. Untargeted global clicks require unsafe mode.

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

type_text

Uses verified application-targeted delivery when a target and semantic selector are supplied. foreground_allowed requires unsafe mode.

text, appName or windowId, selector, executionMode

press_key

Posts supported keys to a semantic editable control in background_required mode. foreground_allowed requires unsafe mode.

key, appName or windowId, selector, executionMode, modifiers

scroll

Glides the live cursor to the target and adjusts an AX scrollbar. Untargeted global scrolling requires unsafe mode.

x, y, deltaY, deltaX, appName, windowId

launch_app

Launches in the background by default. activate: true also requires unsafe mode.

appName, activate

get_active_app

Returns the frontmost application from NSWorkspace without System Events/Automation access.

None

run_applescript

Runs custom AppleScript only when unsafe mode is enabled; omitted from the default tool list.

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.

The default configuration exposes semantic background automation and read-only inspection. For workflows that intentionally need global pointer/keyboard input, foreground activation, or arbitrary AppleScript, opt in explicitly:

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

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

🔒 Capability-Based macOS Permissions

Only grant the permission needed by the tools you use. macOS attributes the permission to the host application running the MCP server (Terminal, OpenCode, Cursor, VS Code, and so on):

  1. Accessibility: Required for semantic inspection and actions. It does not require Screen Recording.

  2. Screen & System Audio Recording: Required only for screenshots and Vision OCR tools such as screenshot, find_text, click_text, and wait_for_text.

  3. Event synthesis: Unsafe-mode global CoreGraphics clicks, typing, key presses, and scrolling require event-posting access. Semantic Accessibility actions do not use this global fallback.

  4. Automation: Can be requested by macOS only when unsafe mode is enabled and run_applescript sends an event to another application. Core input and background tools use the native helper instead of System Events.

Call get_capabilities before protected operations. Permission inspection uses Apple's preflight APIs and does not open a permission prompt. If access is absent, screenshot/OCR and global input paths return SCREEN_RECORDING_PERMISSION_REQUIRED or INPUT_POSTING_PERMISSION_REQUIRED before dispatch. Grant access manually in System Settings, then reconnect the MCP if the host still holds stale privacy state.

macOS can still require the host app to be restarted after a newly granted privacy permission. This is enforced by macOS; the server does not repeatedly prompt or request unrelated permissions.

Background UI automation is cooperative: macOS can address Accessibility elements in another process, but an application may ignore targeted keyboard events or change its identifiers in a later release. These tools return explicit unsupported/unconfirmed errors in those cases instead of activating the app or reporting a false success.


🔌 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

Verify semantic inspection against a background Calculator window:

npm run test:background -- Calculator

With Calculator and System Settings open, run the live native-app smoke suite. The test opts into unsafe mode because it uses AppleScript to create and clean up TextEdit fixtures:

npm run test:live

Mutating tool results include an execution object with a versioned contract, delivery method, verification level, foreground-preservation state, and target. Coordinate-based actions retain status: "delivered_unverified"; verify consequential post-state with semantic inspection, OCR, or a screenshot.

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.


📦 Publishing

Pushes to main run the npm publishing workflow. To release a new version, update the version in package.json and package-lock.json before merging. Versions that already exist on npm are tested and skipped.


📄 License

MIT © John Oba

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      F
      maintenance
      An experimental MCP server providing full control over the macOS user interface through mouse, keyboard, and window management tools. It enables AI assistants to automate desktop tasks by utilizing native accessibility APIs and OCR for real-time screen comprehension.
      7
      Creative Commons Zero v1.0 Universal
    • A
      license
      Not graded
      quality
      D
      maintenance
      An open-source MCP server for macOS and Windows that provides native desktop control via Accessibility APIs, OCR, and Chrome CDP. It enables AI agents to interact with applications, manage browser sessions, and automate workflows with high-speed native UI actions.
      49 npm
      15
      AGPL 3.0