Skip to main content
Glama
@open-computer-use/mcp-server

@open-computer-use/mcp-server

by dmarcin1
README.md
<p align="center">
  <img src="./assets/app-icon.png" width="120" height="120" alt="Open Computer Use Icon" />
</p>

# Open Computer Use

**Zero-install, open-source, model-agnostic macOS Computer Use engine, CLI & MCP server.**

No `/Applications/*.app` installation, no ChatGPT/Codex host lock-in, no MCP Elicitation requirement—build once in place and use from **Antigravity, Claude Code, Cursor, Codex, Windsurf, Gemini CLI, OpenAI Agents SDK, LangGraph, or any local LLM**.

## Key Capabilities

- **Zero-Conflict Background Mode + Verify-and-Escalate Ladder (`background: true` by default)**:
  - Combines AX-first semantic actions (`AXPress` / `AXValue` / `AXSelectedText`), window-targeted `CGEvent.postToPid(pid)` (with out-of-process XPC PID lookup), synthetic AppKit activation (`SyntheticAppFocusEnforcer`), and instant notification-driven focus-steal restoration (`FocusRestoreGuard`).
  - **Structured Action Verification**: Every interaction returns `{ ok, deliveryMode, effect: "confirmed" | "unverifiable" | "suspected_noop", detail }` via pre/post AX element & window-scoped tree diffs, plus one-step `deliveryMode: "foreground_transient"` escalation that flash-activates the target window and restores both your previous foreground window and hardware mouse cursor.
  - **Snapshot-Locked `elementToken` (`"s<gen>:<idx>"`)**: `getState()` tags snapshots with `[s1]`, `[s2]`, ... and `cuaExt.findToken(ax, matcher)` binds targets to that exact generation—rejecting shifted indices with `[STALE_ELEMENT_TOKEN]` before clicking.
- **Native Apple Events Browser Tab Engine (`cua.listTabs` / `cua.getTab`)**: Zero-conflict background automation across Chrome, Safari, Edge, Brave, and Arc (including Incognito & background tabs) via native Apple Events DOM/JS injection—auto-filtering hidden/`pointer-events:none` layers, supporting React/Vue-safe `tab.fill()`, `tab.click()`, `tab.hover()`, `tab.waitFor()`, `tab.eval()`, and CLI `open-computer-use tabs [browser]`.
- **Multi-Window Hard Pinning (`CGWindowID`)**: `app.listWindows()`, `app.window(windowIdOrTitle)`, `cua.getApp(query, { windowId, windowTitle })`, and `open-computer-use windows <app>` pin all AX queries, captures, and input to a specific window—refusing to drift across sibling windows (`[WINDOW_NOT_FOUND]`).
- **Codex-Style Live PiP Preview + Curved Virtual Cursor**: Zero-copy `ScreenCaptureKit` (`SCStream` + `IOSurface`) floating preview window with embedded Bézier-gliding frosted-outline virtual cursor, click ripple, magnetic corner snapping, hover-reveal controls (`×` stop / `⤢` bring-to-front), 12s idle auto-hide, and `IOKit` display-sleep assertion while active.
- **Zero-Install Native Swift 6 Daemon (`bin/open-computer-use-daemon`)**: Spawns on demand directly from the host process, automatically inheriting your terminal/IDE/Antigravity macOS Accessibility & Screen Recording TCC permissions without installing or re-signing any `.app` bundle.
- **Persistent JS REPL (`cua_js`) + Built-in `cuaExt`**: Batch multi-step UI flows into a single call with top-level `await`, cross-turn persistent bindings, `cuaExt.queryAX` (ancestor-preserving AX filter), `cuaExt.findToken`, `cuaExt.findIndex`, `cuaExt.waitFor`, `cuaExt.typeSafe`, and `cuaExt.ocrFind`.
- **AX-First + Cross-Locale `AXIdentifier` + Local Apple `Vision` OCR + Set-of-Mark**: Compact accessibility trees with `id="AXIdentifier"`, automatic diff compression, built-in `VNRecognizeTextRequest` (`zh-Hans`, `en-US`, `zh-Hant`) via `app.ocr()` / `cua_ocr`, and optional `[index]` Set-of-Mark screenshots.
- **Safety Gates, Context Guardrails & Dual CLI/MCP**: Action-level `[CONFIRMATION_REQUIRED]` confirmation gate for irreversible payment/transfer/delete controls (overridable with `{ confirmDangerous: true }` after user consent), Touch ID hardened hot-reload `~/.open-computer-use/policy.json`, `Esc` emergency stop HUD, `save_images_only` & `>32 KB` disk spill, fast CLI (`js`, `tabs`, `windows`, `ocr`, `status`, `doctor`, `allow`), and Stdio / Streamable HTTP MCP.

## Architecture

```text
Any MCP Host / CLI / LLM (Antigravity, Claude Code, Cursor, Codex, HTTP Clients...)
  │  MCP (Stdio / Streamable HTTP)  OR  Fast CLI (`open-computer-use js|tabs|windows|ocr|doctor|allow`)
  ▼
@open-computer-use/mcp-server (TypeScript)
  ├── Mode: repl   (`cua_js` + `cuaExt` + `cua_reset` + `cua_stop` + `cua_doctor`)
  ├── Mode: tools  (15 structured atomic tools incl. `cua_ocr` & `cua_doctor`)
  ├── Mode: hybrid (Both REPL + atomic tools)
  ├── AppleEventsBrowserBridge (Chrome/Safari/Edge/Brave/Arc native tab DOM/JS engine)
  ├── OutputGuard  (>32KB / >800 lines auto-spill + `save_images_only` disk mode)
  └── Optional Playwright / Chrome CDP browser surface (`--enable-browser`)
        │
        │  4-byte LE JSON-RPC 2.0 over Unix Socket (~/.open-computer-use/ipc/service.sock)
        ▼
bin/open-computer-use-daemon (Zero-Install Swift 6 Native Daemon)
  ├── AXTreeEngine         — AXUIElement + Chromium AX + AXIdentifier + windowId pinning + [s<gen>] tokens + Diff
  ├── ScreenshotEngine     — ScreenCaptureKit + Set-of-Mark + Apple Vision OCR
  ├── InputEngine          — Guarded AX/CGEvent actions + ActionEffect verification + TransientForegroundGuard
  ├── ActionSettler        — Adaptive UI stability waiter
  ├── PolicyEngine         — Hot-reload policy.json + wildcards + Touch ID + dangerous-action confirmation gate
  └── SafetyMonitor & UI   — Passive CGEventTap (Esc stop) + Live PiP SCStream preview + Curved Virtual Cursor
```

## Quick Start (No `.app` Install Required)

Requirements: macOS 14+ (Apple Silicon or Intel), Xcode Command Line Tools (Swift 6+), and Node.js 20+.

```bash
git clone https://github.com/dmarcin1/OpenComputerUse.git
cd OpenComputerUse
npm --prefix packages/mcp-server install
npm run build

# Verify daemon, TCC permissions, Touch ID & client setup
npm run doctor

# Install Antigravity MCP config + SKILL.md + ~/.local/bin/open-computer-use CLI
node scripts/configure-clients.mjs --apply-antigravity --install-skill --link-cli
```

### Usage Examples

```bash
# Fast CLI against hot daemon
open-computer-use doctor
open-computer-use tabs Chrome        # List native Chrome/Safari/Edge/Brave/Arc tabs (incl. Incognito)
open-computer-use windows "Finder"   # List windows with CGWindowIDs for hard window pinning
open-computer-use js 'const apps = await cua.listApps({includeInstalled:false,emit:false}); cua.write(apps.map(a=>a.displayName));'
open-computer-use ocr "Finder"

# Policy & Touch ID hardening
open-computer-use allow list
open-computer-use allow add "com.apple.iWork.*"
open-computer-use allow mode allowlist
open-computer-use allow auth on     # Protects future allowlist edits with Touch ID

# Streamable HTTP MCP (universal for any LLM / framework)
open-computer-use mcp --mode repl --http --port 3847
```

## Verification

```bash
npm run test:unit   # IPC framing, REPL AST/persistence, cuaExt/findToken/cross-realm RegExp, output spill, saveImagesOnly
npm run test:e2e    # Live zero-install daemon + [s<gen>] token guard + windowId pinning + Apple Events tabs + Vision OCR + Policy + CLI + Stdio & HTTP MCP
```

## License

[MIT](./LICENSE)