Skip to main content
Glama

ComputerUseOptimizer (CUOP)

Computer use for AI agents that reads the macOS accessibility tree instead of screenshots — and sends only what changed.

A screenshot agent pays for a full image of the screen at every step, then guesses pixel coordinates to click. CUOP gives the agent a compact text list of the elements on screen, lets it act on an element by reference (click @s1:e14), and after each action returns only the lines that changed.

Screenshot agent vs CUOP on the same task

Same task (Calculator 7 + 5 =). Left: the screenshot agent receives a new image every step and clicks guessed coordinates. Right: CUOP sends the element list once (264 tokens), then only the changed lines — 391 tokens in total instead of 2,500.

Results

All numbers below come from real runs on one MacBook (macOS 26), with the same model and the same prompt for both agents. Tokens are counted with tiktoken (o200k); screenshots are scaled the way the API scales them.

12 real desktop tasks × 3 runs each

Totals over 72 runs

CUOP

Screenshot agent

Difference

Tasks completed

36 / 36

33 / 36

+3

Cumulative input tokens

3.44 M

4.67 M

−26.3%

Cost (API prices)

$1.95

$3.48

−43.9%

Where it saves the most

The longer the task, the larger the saving: a screenshot agent re-sends a full image at every step, while CUOP sends a small diff.

Per-task savings

Task (3 runs each)

Input tokens saved

Cost saved

Fill a multi-step web order form (Chromium)

−70% (413k → 123k)

−73%

Menu-bar battery panel¹

−67%

−68%

Copy data between two apps

−54% (363k → 167k)

−66%

Edit a document in TextEdit

−43% (240k → 136k)

−44%

Edit a file in VS Code (Electron)

−33%

−46%

Scientific calculator

−11%

−56%

¹ The screenshot agent failed this task 3/3 (another window covered the menu-bar item it tried to click), so the saving is measured against failed runs.

Cost is lower in 10 of the 12 tasks. Short tasks (2–5 steps: Calculator, Clock, Activity Monitor) use more input tokens with CUOP, because the tool definitions are re-read every turn and outweigh the small screen; the core toolset (24 tools) cuts that fixed cost from 10.4k to 3.0k tokens. A canvas page has no tree content, so CUOP falls back to a screenshot there.

One look at one window

One observation

vercel-labs/agent-desktop returns the tree as JSON. CUOP keeps the same commands and refs but renders the tree as one line per element and trims it to a token budget, so a content-heavy window like the ChatGPT app costs 189 tokens instead of 10,399.

Coverage

84 of the 102 GUI apps installed on the test Mac (82.4%) passed the coverage probe: at least five named, actionable elements reach the model, and the text is cheaper than a screenshot of the same window. The median app costs 0.32× a screenshot.

Related MCP server: mcp-macos-cua

How it works

Claude Code / Codex ──MCP──▶ cuop server ──▶ macOS Accessibility (AXUIElement) / Chrome DevTools ──▶ the app
                              │
                              ├─ text tree   one line per element:  e14 button "7"
                              ├─ refs        act by reference:       click @s1:e14
                              ├─ diff        after an action, only changed lines:  ~ e9 "7"
                              ├─ filter      a `goal` ranks elements relevant to the current step
                              └─ budget      large windows collapse to a skeleton instead of a full dump
  • agent-desktop compatible. The commands, JSON envelope (version 2.6), error codes and ref format follow agent-desktop, so --format json output looks the same. --format text is the token-cheap form.

  • Headless by default. Actions use the accessibility API without moving the user's mouse or stealing focus. --headed allows real key and mouse input for apps that ignore semantic input.

  • Progress you can watch. An optional click-through overlay shows the current step and target, and a session trace can be exported as an HTML viewer.

  • Electron / Chromium. Accessibility is switched on automatically (AXManualAccessibility, AXEnhancedUserInterface).

  • Optional Jev plugin. With a TypeSafe Jev key, a small decision model ranks elements and suggests the route (tree, keys or screenshot) for the first view. Off by default.

Quick start (macOS)

Requires macOS, Python 3.14 and uv. Grant Accessibility (and, for screenshots, Screen Recording) to the terminal that runs it.

git clone https://github.com/csk200387/ComputerUseOptimizer.git
cd ComputerUseOptimizer
uv sync
uv run cuop permissions            # check Accessibility / Screen Recording
uv run cuop snapshot --app Calculator --format text
uv run cuop click @<snapshot-id>:e14 --format text   # returns the diff

Use it from an agent as an MCP server:

# Claude Code
claude mcp add cuop -- uv run --directory /path/to/ComputerUseOptimizer cuop mcp --format text --toolset core

The agent guide lives in skills/cuop/SKILL.md (cuop skills prints it).

Limitations

  • macOS only for now. Windows (UI Automation) is planned.

  • Apps that keep their content out of the tree. Excel's cell grid, PowerPoint's slide canvas and drawing canvases are not in the accessibility tree; there a screenshot agent is still cheaper (Excel: $0.037 vs $0.122 per task).

  • Short tasks pay the fixed cost of tool definitions; use --toolset core.

  • Small samples. Each comparison ran 3 times per task; run-to-run variance can reach ±20%.

Status

A university project (2026-2). The command surface is tracked against agent-desktop in docs/parity/PARITY.md. Tests: uv run pytest -q.

License

Apache License 2.0. The command set and JSON contract follow vercel-labs/agent-desktop (Apache-2.0); see NOTICE.

Available Tools

25 tools
desktop_checkC

Turn a checkbox / switch / radio on.

Inputs: ref_id (required), headed, timeout_ms.

desktop_clearC

Empty a field.

Inputs: ref_id (required), headed, timeout_ms.

desktop_clickB

Click (press) a ref. Menu items run even in closed menus. Each action returns a diff of the window ((no change) = its accessibility tree did not change); take refs from the newest header — a control whose label changed (AC → C) can need its new ref. Wait for one click's result before the next dependent click.

Inputs: ref_id (required), headed, timeout_ms.

desktop_collapseC

Collapse a disclosure / tree row.

Inputs: ref_id (required), headed, timeout_ms.

desktop_double_clickC

Double-click a ref (needs headed).

Inputs: ref_id (required), headed, timeout_ms.

desktop_expandC

Expand a disclosure / tree row.

Inputs: ref_id (required), headed, timeout_ms.

desktop_findC

Find elements by role / name / text in an app (also closed menus with surface=menubar); returns refs.

Inputs: app, nth, last, name, +14 more.

desktop_focusC

Give a ref keyboard focus (e.g. a document area before pressing keys).

Inputs: ref_id (required), headed, timeout_ms.

desktop_focus_windowC

Bring a window to the front.

Inputs: app, title, window_id.

desktop_getC

Read one property of a ref (value, bounds, states, …).

Inputs: ref_id (required), property.

desktop_launchB

Open an app that is not running (background unless activate); a running app needs no launch.

Inputs: app (required), cdp, cwd, env, +4 more.

desktop_list_windowsC

List an app's windows (ids w-N for window_id).

Inputs: app, timeout_ms.

desktop_mouse_clickC

Click screen point xy=X,Y (points; headed). From a screenshot: origin + pixel / scale_factor.

Inputs: xy (required), count, button, headed, +1 more.

desktop_pressC

Send a key or shortcut (e.g. return, cmd+s) to app / window_id.

Inputs: combo (required), app, force, headed, +1 more.

desktop_right_clickC

Open a ref's context menu.

Inputs: ref_id (required), headed, timeout_ms.

desktop_screenshotC

Capture one window as an image (for canvases and visual questions).

Inputs: app, screen, window_id, output_path.

desktop_scrollC

Scroll a ref's scroll area (direction up|down|left|right, amount).

Inputs: ref_id (required), amount, headed, direction, +1 more.

desktop_selectC

Choose an option by its label in a popup, combo box or list.

Inputs: value (required), ref_id (required), headed, timeout_ms.

desktop_set_valueC

Replace a field's whole value.

Inputs: ref_id (required), value, headed, timeout_ms.

desktop_skills_getC

Read the full usage guide (name=cuop or cuop-macos).

Inputs: full, name, reference.

desktop_snapshotB

Read a window as text: one line per element eN role "name" ="value" [states]; refs are @:eN from the header. goal = words on screen to keep only related elements; root = a ref to drill into; surface = menubar | menu | menu-bar-extras | sheet | popover | alert; diff = only changes since your last view. interactive_only hides read-only text such as a result display. For a menu command use find(surface=menubar, name=…) and click it. ^(…) marks superscript text (2^(10) = 2¹⁰).

Inputs: app, diff, goal, root, +9 more.

desktop_toggleC

Flip a checkbox / switch.

Inputs: ref_id (required), headed, timeout_ms.

desktop_typeC

Insert text at the caret of a ref (headless: accessibility insert; headed: real key presses).

Inputs: ref_id (required), text, headed, timeout_ms, +1 more.

desktop_uncheckC

Turn a checkbox / switch off.

Inputs: ref_id (required), headed, timeout_ms.

desktop_waitC

Wait for ms, an element (role:text), a window, text, a menu or an event.

Inputs: ms, app, menu, text, +11 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    C2.8/5.0

    Scored across 25 tools

    Disambiguation4/5

    Most tools target clearly distinct actions (type vs. set_value vs. clear, press vs. type, snapshot vs. find vs. get). A few pairs need the descriptions to separate them: desktop_click vs. desktop_mouse_click (ref vs. screen point), desktop_focus vs. desktop_focus_window (element focus vs. window raise), and the check/uncheck/toggle trio. The descriptions do resolve these, so boundaries remain workable.

    Naming Consistency4/5

    All tools share a uniform snake_case `desktop_` prefix with verb or verb_noun forms, which is highly predictable. Minor deviations like desktop_mouse_click (extra noun) and noun-less names such as desktop_screenshot and desktop_snapshot slightly break the pattern but stay readable.

    Tool Count3/5

    25 tools sits at the heavy end for a desktop-automation surface, and several are near-redundant: check/uncheck/toggle cover the same control states, and double_click/right_click are variants of click. The breadth is justified by the domain, but some consolidation would tighten the set.

    Completeness4/5

    Coverage is strong: snapshots, find, per-ref actions, keyboard/mouse input, window management, screenshots, waiting, and a usage guide cover the core automation lifecycle. Gaps remain for drag-and-drop, clipboard read/write, and window move/resize, which agents may need in real workflows.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to control macOS applications through the Accessibility API, AppleScript, and CGEvents, providing structured text output of UI elements and actions without needing screenshots.
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to control macOS desktop apps via screenshots, mouse clicks, keyboard input, accessibility queries, and AppleScript.
      11
      11 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to inspect and control macOS apps via accessibility trees, screenshots, OCR, and input simulation, with a visible pointer.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to safely and truthfully control local desktop applications via native accessibility trees, supporting element inspection and automation without proprietary binaries or fake success responses.
      Apache 2.0