Skip to main content
Glama
Antigravity Desktop MCP

Antigravity Desktop MCP

by silas-ouyang

Antigravity Desktop MCP (antigravity-desktop-mcp)

A local stdio Model Context Protocol (MCP) server for Windows 10/11 general desktop automation, adapted from the MIT-licensed LJL454/dsh-computer-use project for Google Antigravity.

Built with universal desktop control (screenshots, region/window capture, mouse/keyboard input, clipboard, Win32 window enumeration/focus, COM UI Automation, multi-step batching) plus an always-on-top physical E-Stop overlay HUD, global interrupt hotkeys, anti-capture exclusion, strict HUD self-protection, monotonic window whitelist ratcheting, and event-driven ~0% idle CPU architecture.


Key Capabilities & Architecture

1. 16 Standard MCP Tools (stdio JSON-RPC 2.0)

Tool

Category

Purpose

desktop_screenshot

Vision

Full display / virtual desktop / screen region / specific window (PrintWindow) / owned popup bundle capture, returning inline base64 PNG/JPEG + physical-pixel metadata & frame_id.

desktop_actions

Batch

Up to 50 sequential steps (click, move, drag, scroll, type, paste, key, clipboard, focus, launch, wait, wait_for, screenshot, state, UIA actions) in one round trip with shared deadline and window-change stop guards.

desktop_click

Mouse

Absolute or from_frame-projected click (left/right/middle, 1–3 clicks, modifiers) with pre-landing content & occlusion verification.

desktop_move

Mouse

Absolute, from_frame-projected, or relative (dx/dy) cursor movement.

desktop_drag

Mouse

Smooth multi-point path or point-to-point drag, or from_last continuation.

desktop_scroll

Mouse

Vertical or horizontal scroll at cursor or target coordinates.

desktop_type

Keyboard

Unicode typing via SendInput (KEYEVENTF_UNICODE) with optional into_hwnd foreground guard.

desktop_key

Keyboard

Single keys, chords (ctrl+s, alt+f4), repeats, or held keys (hold_ms).

desktop_windows

Windowing

Enumerate visible/minimized top-level windows (HUD automatically filtered out) or bring focus_hwnd to foreground.

desktop_ui

Accessibility

Native COM CUIAutomation8 tree snapshot with compact [s#.#] control refs, delta diffing, and document/selection text observation.

desktop_ui_action

Accessibility

Invoke, set_value, get_value, get_text, select_text, toggle, select, expand, collapse, scroll_into_view, minimize/maximize/restore/close, click_text, locate_text.

desktop_clipboard

Clipboard

get, set, or clear Windows text clipboard.

desktop_paste

Clipboard

Reliable long/CJK text insertion via clipboard + Ctrl+V with automatic save/restore (require_restore option).

desktop_launch

Launch

Launch .exe, PATH commands, Start Menu display names, URLs, or UWP Store apps cleanly.

desktop_stop

Safety

Urgent queue-bypass abort: halts running & queued calls, terminates hung PowerShell workers via 6-step shutdown, and runs independent release-input.ps1 cleanup.

desktop_safety

Safety

Inspect E-Stop/overlay/backend health (status), or enable/tighten the window whitelist (lock_whitelist / tighten_whitelist).


2. High-Reliability E-Stop & Operational Safety

  1. Always-On-Top Floating HUD (EStopOverlay.cs):

    • Compiled to bin/EStopOverlay.exe (.NET 4 WinForms, Per-Monitor V2 DPI aware, WS_EX_NOACTIVATE + WS_EX_TOPMOST).

    • Features a draggable status badge (待机 / 护航中 / AI执行中 / 已急停), prominent red STOP 急停 button, user-only 恢复 RESUME button, right-click configuration menu (Esc mode, whitelist unlock/clear, reposition), and capture-exclusion badge.

    • Marked with WDA_EXCLUDEFROMCAPTURE (0x11) at Win32 level so hardware/DWM screen captures do not see the overlay pixels (with automatic reference-counted suspendVisual/resumeVisual fallback if unsupported).

  2. Three-Layer Instant Abort (< 1 ms wake-up + Clean Input Unwind):

    • Global Low-Level Keyboard Hook (WH_KEYBOARD_LL): Captures real hardware keystrokes while strictly ignoring synthetic AI inputs (LLKHF_INJECTED | LLKHF_LOWER_IL_INJECTED) so AI-typed Esc or hotkeys cannot self-trigger.

    • Esc Auto-Arming: In default auto mode, Esc is armed whenever AI mutating steps execute and stays armed for a brief cooldown (1800ms) afterward (configurable in UI to always or disabled).

    • Dedicated RegisterHotKey: Ctrl + Alt + Pause works globally at all times (configurable to Ctrl+Alt+Backspace or Ctrl+Shift+Esc safe alternatives).

    • Kernel Named EventWaitHandle (Local\AgyDesktopCancel_<pid>) + Cancel Flag: Immediately wakes blocked Wait-Cancellable loops inside PowerShell without waiting for poll intervals or Wait-Condition timeouts, aborts queued MCP requests cleanly ([USER_ABORTED]), and if any Win32/UIA call refuses to unwind within budget, kills the worker process and runs standalone backend/release-input.ps1 to release any held modifier/mouse keys.

  3. Un-Bypassable Safety Ratchets:

    • E-Stop Latch: Once triggered by hardware hotkey or physical STOP click, all mutating MCP tools return [ESTOP_ACTIVE] until the user physically clicks 恢复 RESUME on the floating HUD. MCP tools cannot clear an E-Stop.

    • Protected HUD Target: Coordinates inside hud.bounds, the HUD hwnd, and the overlay PID are blocked in Node and PowerShell ([PROTECTED_HUD_TARGET]).

    • Monotonic Window Whitelist: User or desktop_safety(lock_whitelist) can restrict operations to specific processes / title substrings / HWNDs (e.g., TIA Portal, Factory I/O, or Notepad). Once locked, AI can only tighten_whitelist — disabling or widening returns [WHITELIST_LOCKED]. Under whitelist mode, OS escape chords (win+*, alt+tab, alt+esc, ctrl+esc, ctrl+shift+esc, win) are rejected ([WHITELIST_OS_SHORTCUT_BLOCKED]).

  4. Near-Zero Idle CPU (Zero Busy-Polling):

    • Node MCP server awaits blocking readline/stream events.

    • EStopOverlay.exe runs a native Win32 Application.Run() message pump.

    • backend/worker.ps1 blocks on $stdin.ReadLine() between calls and uses EventWaitHandle.WaitOne(sliceMs) inside waits.


Related MCP server: desk-mcp

Project Layout

antigravity-desktop-mcp/
├── bin/
│   ├── antigravity-desktop-mcp.js   # Production stdio MCP entrypoint
│   └── EStopOverlay.exe             # Compiled Win32 floating E-Stop overlay & hotkey daemon
├── native/
│   └── EStopOverlay.cs              # C# source for physical HUD, WH_KEYBOARD_LL, RegisterHotKey, WDA_EXCLUDEFROMCAPTURE
├── backend/
│   ├── worker.ps1                   # Deterministic modular loader generated by scripts/build-worker.mjs
│   ├── release-input.ps1            # Independent held-key/mouse recovery script
│   └── parts/                       # Modular PowerShell worker slices (00-preamble .. 13-main-loop)
├── src/
│   ├── server.js                    # JSON-RPC 2.0 stdio transport + urgent bypass lane for desktop_stop / desktop_safety
│   ├── tools.js                     # 16 MCP tool schemas and execution handlers
│   ├── safety.js                    # E-Stop latch, HUD target guard, monotonic whitelist controller
│   ├── overlay-supervisor.js        # Supervises EStopOverlay.exe IPC lifecycle
│   ├── capture-service.js           # Magic-byte verified PNG/JPEG delivery, ring buffer cleanup, coordinate envelopes
│   ├── backend/                     # PowerShellBackend & 6-step Generation lifecycle supervisor
│   └── internal/                    # Core contracts ported & extended from dsh-computer-use
├── scripts/
│   ├── build-native.mjs             # Compiles native/EStopOverlay.cs via .NET 4 csc.exe
│   ├── build-worker.mjs             # Generates deterministic backend/worker.ps1 loader + SHA-256 manifest (--check supported)
│   └── doctor.mjs                   # Live environment + overlay + worker health check
└── tests/
    ├── unit-*.test.mjs              # Fast offline unit tests (protocol, safety ratchet, worker build)
    └── live-desktop.test.mjs        # Live Windows end-to-end verification tests

Commands

npm run build         # Regenerate backend/worker.ps1 + compile bin/EStopOverlay.exe if needed
npm run check:worker  # Verify backend/worker.ps1 matches backend/parts/*.ps1 hashes
npm run doctor        # Spawn overlay + worker cleanly and output JSON health report
npm test              # Run offline unit tests
npm run test:live     # Run live Windows tests (overlay, UIA, PrintWindow, whitelist, E-Stop, stdio cleanup)

Antigravity Global MCP Configuration (%USERPROFILE%\.gemini\config\mcp_config.json)

{
  "mcpServers": {
    "desktop": {
      "command": "node",
      "args": [
        "C:\\path\\to\\antigravity-desktop-mcp\\bin\\antigravity-desktop-mcp.js"
      ],
      "env": {
        "AGY_DESKTOP_UI_ENGINE": "com"
      }
    }
  }
}

Note: In production mode (bin/antigravity-desktop-mcp.js), --allow-ipc-resume is disabled by default so an E-Stop latch can only be cleared by physically clicking 恢复 RESUME on the floating overlay HUD.

Available Tools

16 tools
desktop_actionsB
Destructive

Execute a sequence of up to 50 desktop actions (click, move, drag, scroll, type, paste, key, clipboard, focus, launch, wait, wait_for, screenshot, state, or UI Automation actions like invoke/set_value/get_text) in a single round trip. Aborts immediately at <1ms latency if user E-Stop triggers.

Inputs: steps (required), clip, scale, format, +15 more.

desktop_clickB

Move to (x, y) and click. Prefer passing from_frame from desktop_screenshot so occlusion/window movement is guarded automatically.

Inputs: x (required), y (required), button, clicks, +6 more.

desktop_clipboardA

Read (get), write (set), or clear the Windows text clipboard.

Inputs: op, text.

desktop_dragB

Press left button and drag smoothly from (from_x, from_y) to (to_x, to_y), along a multi-point path, or continuing from previous drag (from_last / continue_from).

Inputs: path, to_x, to_y, from_x, +9 more.

desktop_keyB

Press or hold a key or key chord (e.g. "enter", "ctrl+s", "alt+f4", "ctrl+shift+p"). Blocked OS-escape chords are rejected under whitelist mode.

Inputs: keys (required), repeat, hold_ms, into_hwnd.

desktop_launchC

Launch a Windows application, executable path, Start Menu display name, URL, or Store app with Electron/Node-injection env vars stripped cleanly, and wait for its window.

Inputs: target (required), cwd, kind, refresh, +3 more.

desktop_moveB

Move the mouse cursor to absolute/frame-projected (x, y) or by relative delta (dx, dy) for hover tooltips or pointer-locked canvases.

Inputs: x, y, dx, dy, +4 more.

desktop_pasteB

Paste long or multi-line Unicode text reliably via clipboard + Ctrl+V, automatically saving & restoring previous clipboard contents (use require_restore: true to refuse if clipboard contains non-text data).

Inputs: text (required), verify, restore, into_hwnd, +1 more.

desktop_safetyA

Inspect physical E-Stop overlay state, hotkey config (Esc mode + combo), window whitelist rules, and backend health, OR lock/tighten the window whitelist (lock_whitelist / tighten_whitelist). AI cannot clear an E-Stop or disable/widen an active whitelist.

Inputs: hwnd, rules, action, process, +1 more.

desktop_screenshotA
Read-only

Capture the Windows screen, a specific display, a specific window (even overlapped via PrintWindow), a screen/window region, or a foreground-plus-related-windows bundle. Returns the image directly plus physical-pixel coordinate metadata and a frame_id for accurate click/drag/scroll projection.

Inputs: clip, scale, format, region, +12 more.

desktop_scrollC

Scroll vertically or horizontally at (x, y) or current cursor position.

Inputs: direction (required), x, y, clicks, +4 more.

desktop_stopA

URGENT: Immediately abort all running and queued desktop actions, kill hung workers if needed, confirm held keys/mouse buttons are released, and optionally latch the E-Stop.

Inputs: latch, reason.

desktop_typeB

Type Unicode text cleanly using SendInput KEYEVENTF_UNICODE into the active foreground window (use into_hwnd to guard against focus stealing).

Inputs: text (required), delay_ms, into_hwnd.

desktop_uiB
Read-only

Inspect a window's UI Automation accessibility tree (with compact [s#.#] control refs for desktop_ui_action, snapshot delta diffing, pattern filtering, and optional focused/selected/document text observation).

Inputs: hwnd, prune, filter, compact, +8 more.

desktop_ui_actionC

Perform a UI Automation action on a control identified by ref (from desktop_ui) or by selector (hwnd, automation_id, name, control_type, class_name, index).

Inputs: action (required), ref, hwnd, name, +13 more.

desktop_windowsB

Enumerate visible Windows application windows (and optionally minimized ones with include_minimized), or bring a window to foreground via focus_hwnd.

Inputs: filter, focus_hwnd, include_minimized.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 16 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: pointer movement, clicking, dragging, typing, window inspection, UI Automation, clipboard, launch, and safety are separable. The main overlap is desktop_actions, which can batch many of the same operations, and desktop_type versus desktop_paste, though their descriptions clarify the intended distinction.

    Naming Consistency5/5

    All tool names use a consistent snake_case convention with the shared desktop_ prefix. The verb/noun structure is predictable throughout, e.g. desktop_move, desktop_click, desktop_screenshot, desktop_ui_action.

    Tool Count4/5

    The 16 tools are justified by a broad desktop-automation domain covering input, screenshots, windows, UI Automation, clipboard, launch, and safety. The surface is slightly heavy relative to the ideal 3-15 range, but each tool maps to a meaningful capability rather than redundant variants.

    Completeness4/5

    Coverage is strong for the core desktop automation lifecycle: inspect, move, click, drag, scroll, type, key, clipboard, UI Automation, launch, stop, and safety. Minor gaps remain around direct right-click/double-click gestures and explicit window management operations like resize, move, minimize, or close, though some may be achievable through UI Automation or batch actions.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Desktop UI automation for AI agents: screenshots, window management, mouse, keyboard, UI Automation tree, OCR. Single Windows x64 binary, no dependencies.
      3
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI clients to see and control a Windows desktop through screenshots, built-in OCR, mouse and keyboard input, and accessibility trees read via UI Automation, MSAA and Chrome DevTools Protocol. It also manages windows, virtual desktops and element-level actions such as invoking controls or setting values, running on Node.js with the PowerShell that ships with Windows.
      8
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to drive native Windows apps and headed browsers inside a hidden child desktop session with its own screen, pointer and keyboard focus. Provides tools for screenshots, mouse/keyboard input, accessibility inspection, UI waits, display changes, Android emulators, application launches and cancellable command jobs, so the user's own desktop stays free.
      9
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI models to control a local Windows desktop by moving the cursor, clicking, scrolling, typing Unicode text, sending key chords, and capturing screenshots. Runs natively on Windows with minimal latency and no heavy dependencies such as Python, PyAutoGUI, or Docker.
      119 npm
      1
      MIT