windows-gui
by ruol1
README.md
<div align="center">
<img src="assets/logo.png" alt="Windows GUI Automation Plugin Logo" width="108" />
<h1>Windows GUI Automation (MCP Plugin)</h1>
<p>
<strong>27-Tool Hybrid Windows Desktop Automation Engine for Antigravity & MCP Clients</strong><br />
Codex-Style Capture-Excluded HUD & Esc Takeover · Smooth Cursor & Focus Restore · Minimal System Tray · 4-Tier Perception · Warm Worker (6–45×) · Pure-PIL Icon Match · Opt. Zero-Dep CDP
</p>
<p>
<strong>English</strong> | <a href="README_zh.md">简体中文</a>
</p>
<p>
<a href="https://github.com/ruol1/windows-gui-mcp/actions/workflows/ci.yml"><img src="https://github.com/ruol1/windows-gui-mcp/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
<a href="https://github.com/ruol1/windows-gui-mcp/releases"><img src="https://img.shields.io/badge/version-2.2.0-2563EB?style=flat-square" alt="Version 2.2.0" /></a>
<img src="https://img.shields.io/badge/MCP%20Tools-27-059669?style=flat-square" alt="27 MCP Tools" />
<img src="https://img.shields.io/badge/platform-Windows%2010%2F11-0078D6?style=flat-square" alt="Windows 10/11" />
<img src="https://img.shields.io/badge/deps-Python%203.10%2B%20%7C%20Pillow%20%7C%20mcp%3C2-4F46E5?style=flat-square" alt="Minimal Dependencies" />
<img src="https://img.shields.io/badge/license-MIT-64748B?style=flat-square" alt="MIT License" />
</p>
</div>
---
**`windows-gui`** is a production-grade [Antigravity](https://antigravity.google) plugin and standalone MCP server that gives AI agents fast, reliable, semantic-first control over **the entire Windows desktop** — from standard WinUI/UWP/Tauri/Electron apps and normal logged-in browsers, to zero-UIA self-drawn apps (e.g. WeChat 4.x Qt5, HTML5 `<canvas>`), Windows 11 OS controls, rich clipboards, and (optionally) elevated Administrator windows.
All **27 MCP tools** run with **zero GPU, zero OpenCV, zero NumPy, and zero Playwright dependencies** — only Python stdlib, `Pillow`, `mcp<2`, native Win32/WinRT APIs, and the upstream Rust CLI [`vercel-labs/agent-desktop`](https://github.com/vercel-labs/agent-desktop) (downloaded and SHA-256 verified automatically by `scripts/setup.ps1`).

---
## Why `windows-gui`?
| Dimension | Pure-VLM Computer Use | OmniParser + SoM | Playwright / Browserbase | Raw Desktop Drivers / RPA | **`windows-gui` v2.2 (27 Tools)** |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **Control Scope** | Full desktop (pixel-only) | Full desktop | Browser tabs only | Full desktop (standard integrity) | **Full OS + Optional Admin UIPI + Win11 Shell + Rich Clipboard + Opt. CDP** |
| **Perception Routing** | 100% raw pixel guessing | Extra GPU YOLO + Caption models | DOM / CDP | UIA tree only (breaks on Qt/Canvas) | **4-Tier Routing**: Opt. stdlib CDP → UIA/`TextPattern` → Warm Dual-Pass OCR → Pure-PIL NCC Icon Match & Pixel Probe |
| **Execution Latency** | 1 step = 1 LLM turn + blind sleep | 1 step = 1 LLM turn + vision pass | Fast inside browser | Cold subprocess per call (500–2000 ms) | **In-Process + Warm PS Worker (6–45× faster) + 1-Turn `gui_batch` (up to 25 steps)** |
| **CJK IME & Clipboard** | Keystrokes break on CJK IME | Same | Native DOM fill | Overwrites user clipboard | **UIA `set-value` → Lossless multi-format paste (`CF_DIB`/`HTML`/`RTF`) → Auto-paced `KEYEVENTF_UNICODE`** |
| **Privilege Isolation** | Blocked by UIPI | Blocked by UIPI | N/A | Blocked by UIPI or leaks admin token | **Elevated control plane + Win32 Shell Token Drop (normal apps launch at Medium Integrity)** |

---
## Quick Start
### Prerequisites
- **Windows 10 / 11** (x64 or ARM64)
- **Python 3.10+** available in `PATH` (`python --version`)
- PowerShell 5.1+ (built into Windows)
### 1. Install the Plugin or Standalone MCP Server
**Option A — Antigravity CLI (Recommended for Antigravity):**
```powershell
agy plugin install https://github.com/ruol1/windows-gui-mcp
```
**Option B — Manual Clone (Antigravity App / IDE / Any MCP Client):**
```powershell
git clone https://github.com/ruol1/windows-gui-mcp.git "$env:USERPROFILE\.gemini\config\plugins\windows-gui"
```
### 2. Run One-Command Setup (Persistent Mode A Default: Deps + `agent-desktop.exe` + Tray Daemon)
> For repository cleanliness and security, the upstream third-party binary `agent-desktop.exe` is **not** committed to Git. `scripts/setup.ps1` installs `mcp<2` + `Pillow`, downloads `v1.3.1` directly from official `vercel-labs/agent-desktop` GitHub Releases with SHA-256 verification, and configures the persistent local Streamable HTTP daemon (**Mode A**, recommended) with auto-start at logon, zero battery/timeout throttling, automatic crash recovery, a Start Menu relaunch shortcut, and the minimal system tray icon.
```powershell
cd "$env:USERPROFILE\.gemini\config\plugins\windows-gui"
# Default (Recommended): Elevated Mode A persistent daemon (one UAC prompt; supports Admin windows + Tray icon)
powershell -ExecutionPolicy Bypass -File .\scripts\setup.ps1
# Optional: Non-UAC persistent Mode A (no UAC prompt; still gets Tray icon & auto-start, skips Admin windows)
powershell -ExecutionPolicy Bypass -File .\scripts\setup.ps1 -Standard
# Optional: Stdio-only Mode B (no background daemon or tray icon)
powershell -ExecutionPolicy Bypass -File .\scripts\setup.ps1 -StdioOnly
```
- Listens **strictly on `127.0.0.1:18765/mcp`** with a 48-character random Bearer token (NTFS ACL-locked to your user + `Administrators` + `SYSTEM`) and rejects browser `Origin` headers to prevent CSRF.
- Runs as a native interactive `AtLogOn` Windows Scheduled Task with 4 reliability safeguards (`AtLogOn`, `ExecutionTimeLimit=0`, `DontStopIfGoingOnBatteries`, `RestartCount=3`) and a minimal pure-Win32 **system tray icon** (one-click disable/enable AI control, Esc/mouse-override toggles, redacted audit log viewer, clean exit + Start Menu relaunch).
- Even when elevated, auto-launching everyday apps (Chrome, WeChat, Office, UWP) uses Win32 **`CreateProcessWithTokenW`** with the desktop shell token so apps start cleanly at **Medium Integrity** with zero admin quirks.
- Restart or enable **Windows GUI Automation** in Antigravity (**Customizations → Installed → MCP Servers**). Revert to Stdio mode at any time via `.\scripts\uninstall_elevated_service.ps1`.
### Using with Any MCP Client (Claude Desktop, Claude Code, Cursor, Codex, Windsurf)
`windows-gui-mcp` is a **100% standard MCP server** — not locked to Antigravity. Connect any MCP client either to the persistent local Streamable HTTP endpoint generated in `mcp_config.json` (`http://127.0.0.1:18765/mcp` + `Authorization: Bearer <token>`), or directly via Stdio:
```json
{
"mcpServers": {
"windows-gui": {
"command": "python",
"args": [
"-X",
"utf8",
"C:/path/to/windows-gui-mcp/skills/windows-gui/scripts/mcp_server.py",
"--transport",
"stdio"
]
}
}
}
```
> Tip: Copy `skills/windows-gui/SKILL.md` into your client's skills/instructions folder so the agent automatically uses the 4-tier routing strategy, macro HUD `task` labels, and app playbooks.
---
## Key Capabilities & Performance Benchmarks
### Measured v1.0 Cold vs v2.0 Warm Latency (Windows 11, 2560×1600 @ 150% DPI)
v2.0 executes `gui_assist` commands **in-process** (eliminating ~250–350 ms `python.exe` cold starts), shares a self-healing **persistent warm PowerShell JSON-RPC worker** (`win_worker.ps1` / `ps_worker.py`), and captures screen regions directly via **Win32 GDI `BitBlt`**:
| Operation | v1.0 Cold Subprocess | v2.0 Warm / In-Process | Speedup |
| :--- | :---: | :---: | :---: |
| **Dual-Pass WinRT OCR** (47 Chinese lines, normal + white-text mask) | ~1,500–2,000 ms | **`152.3 ms`** | **6.1× – 10×** |
| **Core Audio Master Volume** (`get_volume`) | ~800–1,200 ms | **`20.1 ms`** | **~45×** |
| **Process Snapshot** (`list_processes`) | ~550 ms | **`24.8 ms`** | **~22×** |
| **WMI Display Brightness** (`get_brightness`) | ~650 ms | **`93.9 ms`** | **~7×** |
| **Full-Screen 2560×1600 → 1280px JPEG** (`screen=True`) | ~450–600 ms | **`86.3 ms`** (GDI `BitBlt`) | **~6×** |
| **Cropped Region Capture** (popups / input boxes) | ~400 ms | **`6.8 – 16.1 ms`** | **~30×** |
| **UIA Document Text Extraction** (Calculator) | `723.5 ms` | **`288.3 ms`** | **2.5×** |
| **Worker Crash Auto-Respawn** (`taskkill /F` → transparent recovery) | N/A | **`493.1 ms`** | **Zero error** |
### All 27 MCP Tools (`windows-gui_desktop`)
| Category | Tools | Highlights |
| :--- | :--- | :--- |
| **Safety HUD, Tray & Audit** | `gui_control` | Codex-style capture-excluded (`WDA_EXCLUDEFROMCAPTURE`) matte obsidian macro-task pill (`set_task` / friendly app fallback), diffused screen edge aura, smooth ease-out cursor glide & auto focus restore (both ON by default), minimal system tray daemon, hardware `Esc`/`double_esc`/`mouse_override` stop (6 s auto-reset), persisted preferences & redacted `audit_log` |
| **Diagnostics & Recovery** | `gui_doctor`, `gui_recover` | Verifies `WinSta0\Default`, elevation, DPI, `SnapshotOK`, `PowerShellWorker`, & `SafetyOverlay`; kills stuck helpers, recycles worker, hardens `AGENT_DESKTOP_HOME` DACL, hot-reloads modules |
| **Window & App Lifecycle** | `gui_list_windows`, `gui_window_action` | EN/ZH app discovery via Registry `App Paths`, Start Menu `.lnk` (uninstaller/CMD-filtered), Store UWP (`Get-StartApps`), & URI schemes (`ms-settings:*`); DWM-aware `snap_left`/`snap_right`/`center`/`move_to_monitor`/`set_topmost` |
| **4-Tier Perception** | `gui_browser_cdp`, `gui_extract_text`, `gui_snapshot`, `gui_find`, `gui_get`, `gui_annotate`, `gui_ocr_find`, `gui_screenshot`, `gui_find_image`, `gui_inspect_point` | Optional stdlib RFC 6455 CDP (Shadow DOM); UIA `TextPattern` + `WM_GETOBJECT` wake + Document-cropped dedup OCR; 8-snapshot LRU ref cache; pure-PIL 3-stage NCC icon matcher (alpha-mask aware); RGB/cursor/caret probe; 4-edge coordinate ruler |
| **Full Win32 Input** | `gui_click`, `gui_check`, `gui_interact`, `gui_press`, `gui_mouse_click`, `gui_scroll`, `gui_drag`, `gui_smart_input` | 40B x64 `SendInput` ABI: `middle`/`x1`/`x2` + modifier clicks, horizontal `HWHEEL`, `Ctrl+wheel`, multi-point `path` drag, UIA `set-value`, lossless clipboard paste, and auto-paced CJK `KEYEVENTF_UNICODE` |
| **Waits & 1-Turn Macros** | `gui_wait`, `gui_batch` | Smart waits (`title_changed` in `0.3 ms`, `dialog_appear`, `element_appear`/`gone`, `ocr_appear`/`gone`, `visual_changed`/`stable`); chain 1–25 steps with merged clipboard backup & inline screenshots |
| **OS Controls & Clipboard** | `gui_system`, `gui_clipboard` | Localized Win11 shell surfaces, headless WinRT notifications, Core Audio volume, WMI brightness, virtual desktops, keep-awake, processes, multi-monitor; rich clipboard (`text`, `PNG`/`CF_DIB`, `CF_HDROP` files, `CF_HTML`, `CF_RTF`) |
---
## Verification, Stress Testing & Automated Regression Suite
Every capability in v2.0 has been stress-tested across a **zero-UIA / zero-text / paste-blocked HTML5 `<canvas>` adversarial bench (`CanvasLab`)** and **6 heterogeneous Windows UI stacks** (WeChat 4.x Qt 5.15, Codex MSIX/UWP, Clash Verge Tauri/WebView2, Antigravity heavy Electron with 5,000+ nodes, Chrome 158 CDP, and elevated WinUI/Admin apps). See the full report in [docs/TEST_REPORT_v2.md](docs/TEST_REPORT_v2.md).

Run the zero-dependency `unittest` regression suite anytime (**33/33 tests pass in ~13s**, including `WDA_EXCLUDEFROMCAPTURE` continuous multi-turn Task Session HUD & watchdog, smooth cursor glide + pre-click pause, auto focus restore, OS-language localized Win32 tray icon, privacy-redacted audit log rotation, physical vs injected `Esc`/`double_esc`/`mouse_override` hooks, CJK pacing, worker `taskkill` recovery, and a built-in mock RFC 6455 CDP server):
```powershell
# Offline unit + integration + worker crash-recovery + mock RFC 6455 CDP tests
python -X utf8 tests/run_tests.py
# Also run live headless Chrome/Edge CDP E2E (open Shadow DOM + CJK Input.insertText)
python -X utf8 tests/run_tests.py --live-cdp
```
---
## Security & Human-in-the-Loop (HITL) Boundaries
- **Loopback-Only & Token-Locked**: Both the optional Streamable HTTP daemon (`127.0.0.1:18765`) and `gui_browser_cdp` strictly enforce loopback hosts (`127.0.0.1` / `localhost` / `::1`) and reject cross-origin browser requests.
- **No Privilege Leakage**: Elevated mode launches normal user apps via Win32 Shell Token Drop (`Medium Integrity`) and applies 2-step NTFS DACL hardening on `AGENT_DESKTOP_HOME`.
- **Strict HITL Walls**: Bundled agent instructions (`skills/windows-gui/SKILL.md`) explicitly prohibit bypassing Windows UAC Secure Desktop prompts, CAPTCHAs, account login/2FA, or payment confirmations — handing control back to the human whenever those walls appear.
---
## License & Acknowledgments
- **License**: [MIT License](LICENSE) — Copyright (c) 2026 [Ye Qiu (`ruol1`)](https://github.com/ruol1).
- **Upstream Driver**: Built on top of [`vercel-labs/agent-desktop`](https://github.com/vercel-labs/agent-desktop) (licensed under **Apache-2.0**), downloaded directly from official releases via `scripts/setup.ps1`.
- See [CHANGELOG.md](CHANGELOG.md) for the full v2.0.0 release history.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues