Computer Control
by wyf93
README.md
# Computer Control (`computer-control-mcp`)
Best-practice Windows desktop control MCP (Model Context Protocol) server and Live Monitor MCP App, packaged as a self-contained Antigravity plugin alongside operational skill guidance and safety rules.
## Requirements
* **OS**: Windows 10 or Windows 11 (unlocked interactive desktop session)
* **Python**: `>= 3.11`
* **Runner**: [`uv`](https://docs.astral.sh/uv/) on `PATH` (used by `mcp_config.json` via `uv run --directory "${PLUGIN_ROOT}"`)
* **UI Build (development only)**: Node.js / npm (pre-built single-file bundle is already shipped at `src/computer_control_mcp/assets/monitor.html`)
## Installation
### Method 1: Install as an Antigravity Plugin (Recommended)
1. **Install `uv`** (if not already installed on Windows):
```powershell
winget install astral-sh.uv
```
2. **Install the plugin** using any of the following options:
* **From Git repository** (global install):
```powershell
git clone https://github.com/wyf93/computer-control-mcp.git "$env:USERPROFILE\.gemini\config\plugins\computer-control"
```
* **From release ZIP archive**: Extract the archive directly into `%USERPROFILE%\.gemini\config\plugins\computer-control` so that `plugin.json` is located at `%USERPROFILE%\.gemini\config\plugins\computer-control\plugin.json` (not nested inside an extra subfolder).
* **Via Antigravity CLI** (if `agy` is installed):
```powershell
agy plugin install https://github.com/wyf93/computer-control-mcp
```
* **Team / project-scoped sharing**: Place the plugin directory at `<your-repo>\.agents\plugins\computer-control\` and commit it to your project repository.
3. **Optional pre-warm** (pre-creates the isolated `.venv` and downloads Python dependencies before first agent use):
```powershell
uv sync --directory "$env:USERPROFILE\.gemini\config\plugins\computer-control" --no-dev
```
4. **Verify in Antigravity**: Open **Customizations > Plugins** (or run `/plugin`) and confirm **Computer Control** is enabled. The bundled `mcp_config.json` uses `${PLUGIN_ROOT}` and `uv run --quiet --directory "${PLUGIN_ROOT}" --no-dev computer-control-mcp`, so it works portably across machines without hardcoded paths.
### Standalone MCP Server (PyPI / `uvx`)
Once published to PyPI, the server can also be invoked directly via `uvx`:
```json
{
"mcpServers": {
"computer-control": {
"command": "uvx",
"args": ["computer-control-mcp"],
"env": { "PYTHONUTF8": "1" }
}
}
}
```
## Components
* **`plugin.json` / `mcp_config.json` / `assets/logo.svg`**: Antigravity plugin manifest, portable stdio MCP configuration, and high-contrast icon.
* **`skills/computer-control/SKILL.md`**: Progressive-disclosure workflow teaching UIA-first targeting, coordinate-space discipline, and visual verification loops.
* **`rules/AGENTS.md`**: Always-on safety guardrails while the plugin is enabled.
* **MCP Tools**:
* `computer_monitor`: Live Monitor MCP App (`aux_pane` & `global`) showing real-time screen previews, click/drag overlays, historical step replay, pause/resume takeover controls, and visual toggles.
* `computer_control_state`: Inspect, pause, or resume desktop control after user interruption (physical mouse move, `Esc`/`Pause` key, click during typing/wait, or UI pause), invalidating cached screenshot coordinates on pause.
* `computer_visual_settings`: Runtime presets (`standard`, `demo`, `fast`, `off`) and individual toggles for smooth cursor glide, click ripples, element highlights, keystroke previews, interruption guard, and the floating desktop HUD.
* `computer_get_screen_info`: Multi-monitor geometry, DPI scale factors, virtual desktop bounds, cursor position, and active foreground window.
* `computer_screenshot`: Fast capture (`mss` + `Pillow`) across primary display, all monitors, specific monitor, foreground/target window, or region, with cursor reticle and optional coordinate grid.
* `computer_list_windows` / `computer_window_action`: Enumerate, focus, restore, minimize, maximize, move/resize, and close windows.
* `computer_get_ui_tree`: Windows UI Automation inspection with `IsPassword` redaction (`***`) and physical `[cx, cy]` center coordinates.
* `computer_mouse` / `computer_keyboard`: DPI-aware `SendInput` with ease-out smooth cursor glide, click ripples, Unicode typing (`KEYEVENTF_UNICODE`), clipboard paste mode, and `redact=True` masking for sensitive text.
* `computer_clipboard` / `computer_wait` / `computer_launch_app`: Unicode clipboard read/write (pause-gated), interruptible wait, and detached app/URI launching.
## Safety & Environment Limits
* **User Interruption Guard**: Physical mouse movement (`>26px` during glide/drag), `Esc`/`Pause`, or mouse clicks during typing/wait pause automation (`AUTOMATION_PAUSED_BY_USER`) and block mutating tools (`computer_mouse`, `computer_keyboard`, `computer_window_action`, `computer_launch_app`, `computer_clipboard`, `computer_wait`) until resumed.
* **Secret Redaction**: UIA password fields are redacted as `***`, and `computer_keyboard(action="type", redact=True)` masks typed text from both the desktop HUD and monitor timeline.
* **Windows UIPI**: Non-elevated MCP processes cannot synthesize `SendInput` events into Administrator-elevated windows (e.g., Task Manager or elevated terminals).
## Architecture
* `src/computer_control_mcp/dpi.py`: `PerMonitorV2` DPI awareness, monitor enumeration, and `screen`/`image`/`window` coordinate resolution.
* `src/computer_control_mcp/control_guard.py`: Thread-safe pause/resume controller and Win32 user-interruption watcher.
* `src/computer_control_mcp/visual_config.py`: Thread-safe visual presets and adaptive timing rules.
* `src/computer_control_mcp/overlay.py`: Click-through, non-activating Win32 layered overlay (`WDA_EXCLUDEFROMCAPTURE`) rendering the floating HUD, click ripples, scroll indicators, drag vectors, and UI element highlights.
* `src/computer_control_mcp/recorder.py`: Thread-safe timeline recorder, UIA bounding-box cache, and ring-buffered preview frames.
* `src/computer_control_mcp/screen.py`: Multi-monitor/window capture and Live Monitor JPEG preview capture.
* `src/computer_control_mcp/windows_mgmt.py`: Window enumeration, DWM extended bounds, reliable focus restoration, and async app launching.
* `src/computer_control_mcp/uia.py`: Thread-safe UI Automation traversal.
* `src/computer_control_mcp/win32_input.py`: 64-bit safe `SendInput` wrapper with reverse-ordered hotkey chord release.
* `src/computer_control_mcp/clipboard.py`: Win32 `CF_UNICODETEXT` clipboard helpers with lock-retry handling.
* `ui/` → `src/computer_control_mcp/assets/monitor.html`: TypeScript + `@modelcontextprotocol/ext-apps` single-file MCP App UI.
## Development & Testing
```powershell
# Run automated unit and MCP stdio protocol tests
uv run pytest -v
# Optional: run interactive-desktop smoke script
uv run python scripts/smoke_live_desktop.py
# Typecheck and rebuild the Live Monitor single-file HTML bundle
cd ui
npm install
npm run typecheck
npm run build
cd ..
# Build wheel and source distribution
uv build
```
### Environment Variables
* `COMPUTER_CONTROL_NO_OVERLAY=1`: Disable the native Win32 desktop overlay thread (useful in headless CI/tests).
* `COMPUTER_CONTROL_NO_INTERRUPT_POLL=1`: Disable `GetAsyncKeyState` / cursor-deviation interruption polling during synthetic unit tests.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues