Skip to main content
Glama

cua-ag-bridge

A lightweight Windows stdio MCP proxy over cua-driver built specifically to eliminate desktop-automation latency bottlenecks in Google Antigravity (and other MCP hosts with small inline payload caps or missing structuredContent rendering).


Why This Exists

Profiling real multi-step Windows desktop automation sessions (e.g., driving wxWidgets / wxWindowNR apps like Bambu Studio on high-DPI displays) revealed that >90% of wall-clock latency is not cua-driver execution—it is avoidable LLM round-trips caused by four integration gaps:

  1. Antigravity's ~10 KB MCP Inline Payload Cap: Any MCP ImageContent > 10,000 bytes is offloaded to media_0.png, forcing a mandatory second LLM turn (read_file) every time the agent looks at the screen.

  2. Stripped MCP structuredContent: cua-driver places elements[].screenshot_frame, capture_id, window_bounds, cursor state, and action metadata in MCP 2025-06-18 structuredContent, which Antigravity drops—leaving get_window_state({tree_format: "elements"}) returning only a placeholder string.

  3. Custom-Toolkit Blind Spots (wxWindowNR / Qt / CAD): Custom buttons show up as unnamed UIA nodes (Button [id=...]), silently drop background PostMessage clicks, and lose transient WS_POPUP dropdowns when click({delivery_mode: "foreground"}) immediately restores the prior foreground window (and per-HWND PrintWindow omits sibling WS_POPUP overlays).

  4. Default 600 ms Cursor Glide Floor (steady): cua-driver's default steady cursor timing adds ~750 ms per pointer move; switching to fixed 50 ms glide cuts cursor overhead 6× (~125 ms/move).


Related MCP server: Computer Use MCP

Architecture

flowchart LR
    AG["Google Antigravity (10 KB inline cap, drops structuredContent)"] <-->|stdio MCP| BR["cua-ag-bridge (bridge.py)"]
    BR <-->|single shared stdio runtime| CD["cua-driver.exe mcp --cursor-reduced-motion on"]
    BR <-->|resident ~80ms warm| OCR["Windows WinRT OCR (ocr_worker.ps1)"]
    BR <-->|Pillow <= 9.6 KB| IMG["Sub-10KB Inline JPEG Tile Encoder"]

Because cua-ag-bridge wraps a single shared cua-driver.exe mcp child process, all 60+ native cua-driver tools and the 3 bridge super-tools share the exact same sessions, snapshot_ids, element_tokens, capture_ids, and zoom contexts—with zero duplicate tools or orphan daemons.


Features & Bridge Super-Tools

Transparent Improvements on All cua-driver Tools

  • Automatic structuredContent Flattening: Renders elements[].screenshot_frame centroids @(cx,cy), capture_id, window_bounds, cursor state, and action route/effect/escalation/next_call metadata directly into plain MCP text.

  • Auto-Fast Cursor Motion: Automatically injects {timing: "fixed", glide_duration_ms: 50, dwell_after_click_ms: 0} into start_session calls when cursor_motion is omitted (disable with CUA_BRIDGE_FAST_CURSOR=0).

  • Fast Path Enabled by Default: Seeds CUA_DRIVER_FAST_PATH=on and --cursor-reduced-motion on on the child cua-driver process.

3 Added Super-Tools

Tool

Purpose

Turns / Latency

inspect_window_hybrid

Merges cua-driver UIA elements (with screenshot_frame centers) + Windows built-in WinRT OCR (Windows.Media.Ocr, zero model downloads, zero AGPL weights) into a single <9 KB inline text table. Labels unnamed wxWindowNR buttons with their visible OCR text and exact (cx, cy) coordinates.

1 turn (~220 ms total; ~80 ms warm OCR)

peek_region

Crops [x1, y1, x2, y2] from the window capture, draws crisp window-local coordinate ticks along the top/left edges, and encodes as JPEG strictly <= 9,600 bytes so Antigravity always inlines it directly as part_0.

1 turn (~40 ms, zero read_file)

foreground_tx

Calls bring_to_front once (preventing WM_KILLFOCUS dropdown auto-dismissal), runs run_steps({delivery_mode: "foreground"}), and optionally returns a diff, hybrid table, or desktop_crop (<= 9.6 KB inline JPEG of the desktop composite that captures WS_POPUP dropdowns missed by PrintWindow).

1 turn atomic foreground batch


Quick Start (Windows)

Prerequisites

  • Windows 10 / 11 (uses built-in Windows.Media.Ocr via Windows PowerShell 5.1)

  • Python 3.9+ with Pillow:

    pip install -r requirements.txt
  • cua-driver installed (cua-driver.exe on PATH or in %LOCALAPPDATA%\Programs\Cua\cua-driver\bin\)

1. Clone & Verify

git clone https://github.com/saverchenkov/cua-ag-bridge.git
cd cua-ag-bridge
pip install -r requirements.txt
python test_bridge.py

2. Configure Google Antigravity (~/.gemini/config/mcp_config.json)

Replace (or add) your "cua-driver" entry:

{
  "mcpServers": {
    "cua-driver": {
      "command": "python",
      "args": [
        "C:\\path\\to\\cua-ag-bridge\\bridge.py"
      ],
      "env": {
        "PYTHONUTF8": "1",
        "CUA_DRIVER_FAST_PATH": "on",
        "CUA_DRIVER_ARGS": "mcp --cursor-reduced-motion on",
        "CUA_BRIDGE_FAST_CURSOR": "1"
      }
    }
  }
}

(Tip: Use the full path to python.exe, e.g. C:\\Python\\Python39\\python.exe, and optionally set CUA_DRIVER_EXE if cua-driver.exe is in a custom location.)

Copy rules/cua-driver-antigravity.md into ~/.agents/rules/ so your agents default to run_steps, inspect_window_hybrid, peek_region, and foreground_tx.

Also note: if cua-driver skills install created a Windows symlink at ~/.agents/skills/cua-driver, replacing that symlink with a real directory copy ensures Antigravity discovers the bundled cua-driver skill docs.


Environment Variables

Variable

Default

Description

CUA_DRIVER_EXE

Auto-discovered (PATH / %LOCALAPPDATA%)

Explicit path to cua-driver.exe

CUA_DRIVER_ARGS

mcp --cursor-reduced-motion on

Space-separated args passed to cua-driver.exe

CUA_DRIVER_FAST_PATH

on

Passed through to cua-driver.exe

CUA_BRIDGE_FAST_CURSOR

1

Set to 0 to disable automatic 50 ms start_session cursor motion injection


Rollback

To bypass cua-ag-bridge and run cua-driver.exe directly, point "cua-driver" in ~/.gemini/config/mcp_config.json back to cua-driver.exe:

"cua-driver": {
  "command": "cua-driver.exe",
  "args": ["mcp", "--cursor-reduced-motion", "on"],
  "env": { "CUA_DRIVER_FAST_PATH": "on" }
}

License

MIT

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

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP clients to observe and control Windows desktop applications by reading UIA element trees and capturing screenshots, then acting through UIA patterns or synthesized mouse and keyboard input. It runs standalone on an interactive Windows session, without requiring the original host application.
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables an AI client to inspect and control an interactive Windows desktop, including screenshots, mouse and keyboard input, Windows UI Automation, PowerShell commands with managed jobs, and authenticated file uploads/downloads. Connects over remote MCP Streamable HTTP or local stdio without a separate host-side gateway.
      1
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables an MCP host to observe and control Windows desktop applications deterministically: reading UIA control trees, OCR text and pixel diffs, clicking, typing, scrolling and window management, plus verbatim text reading/appending via ValuePattern/TextPattern. Visual judgment is delegated back to the host model's own multimodal context through annotated screenshots, numbered element cards, grid maps and crosshair zoom-ins, so no separate vision model is needed.
      1
      AGPL 3.0