
agy-cpt-use-mcp
io.github.athsou/agy-cpt-use-mcp
Windows native desktop (Win32 UIA, ~20ms WinRT OCR) & logged-in Chrome MV3 MCP server (32 tools).
Documentation
Native Windows Desktop, Canvas/Game & Logged-In Chrome Automation MCP Server
Architecture · Chrome Bridge Extension · Quick Start · Safety Guardrails · 32 Tools · Glama & Registry · Launch Kit
What's New in v6.4.0 (Agy Chrome Bridge v1.1.0)
Measured end-to-end improvements from v6.3.0 -> v6.4.0:
19.1xFaster Browser Batching (1620.9ms -> 84.9msfor 8 steps): Newcdp_batchprotocol inchrome-bridge(v1.1.0), single-pass tab resolve & preparation, skipped unnecessary_user_presence()checks on safe[AGENT_WIN]tabs, and single end-of-batch state readout — while keeping per-step[CALLING]/[BANKING]/[PRIVATE_CHAT]/[AUTH]guards enforced before any tab prep or state mutation.10.8xFaster SoM Screenshots (125.8ms -> 11.6ms) &5.6xFaster Clicks (1461ms -> 262ms): Single-passSOM_SNAPSHOT_AND_MARK_JS+rAFpaint settle and streamlined target polling.- Stable
tab_id=Addressing,wait(ms=...), Expandedbatch, & Auto-Restore[AGENT_WIN]: Prefer durabletab_id=across tab opens/closes;batchnow supportseval,activate,dialog, and multi-screenshotimage blocks; minimized[AGENT_WIN]windows auto-restore viarestore_window(focused: false). 3.3–7.3xFaster 1440p Lossless PNG Saves (save_png_fast):p95screenshot encode dropped from1083.4msto148.6mswith 100% pixel-identical lossless output.3.3–11.8xFaster Cold WinRT OCR &2.8–3.1xFaster Overlay Startup: DirectBMPworker handoff + backgroundwarm_ocr_worker(), and instant Win32 cyan overlay (· .sou) window reveal before lazy spinner frame baking (start_overlayp50523.6ms -> 188.0ms).
Why agy-cpt-use-mcp.sou?
Most computer-use agents break down in real Windows workflows for six concrete reasons:
- They hijack your machine mid-call or mid-chat — clicking over your Google Meet/Zoom call, personal Messenger/Zalo chat, or banking tab while you're actively using your PC.
- They lose your browser logins — spawning an empty Playwright Chromium instance with zero cookies, failing on Gmail, internal portals, e-tax, or SaaS dashboards.
- They mangle Vietnamese & IME input — typing through UniKey/EVKey Telex hooks turns
oointoôandwintoưinside DirectX/game search boxes or custom inputs. - They click shifted pixels on scaled displays —
PrintWindowDPI padding on125%/150%laptops and window movement cause coordinate drift after every screenshot. - They burn turns on Canvas & Games — forcing an LLM screenshot round-trip just to read one dropdown label or click through 15–45 repetitive items.
- They repeat expensive LLM loops forever — re-running deterministic multi-step exports or forms from scratch instead of replaying a verified local macro.
agy-cpt-use-mcp.sou solves all six in a single pure-stdio JSON-RPC 2.0 MCP server (32 tools total: 31 universal tools for Claude Desktop, Cursor, Windsurf, or any stdio MCP client, plus app_browser as a built-in extension for the Antigravity IDE).
How It Compares
| Capability | agy-cpt-use-mcp.sou | Screenshot-Only Computer Use | Playwright-Only Browser MCP | Basic UIA Wrappers |
|---|---|---|---|---|
Windows UIA + CacheRequest speed | Single-IPC IUIAutomation CacheRequest tree + #N refs | None (blind pixel clicking) | Browser DOM only | Per-property IPC (~7x calls) |
| Logged-in Chrome/Edge (no mouse hijack) | MV3 Chrome Bridge (chrome_browser) + OOPIF + session recovery | Steals physical mouse/keyboard | Isolated fresh profile (logged out) | Foreground UIA only |
| Privacy & call protection | Auto-tags [CALLING], [BANKING], [PRIVATE_CHAT], [USER_BUSY] | Clicks anything on screen | N/A | None |
| Hardware panic abort | <50ms physical ESC abort + click-through cyan border | Wait for model timeout | N/A | None |
| IME / UniKey / DirectX typing | Auto clipboard-restore + KEYEVENTF_UNICODE mode | Mangled Telex keys | Browser only | Standard SendInput |
| DPI & Canvas / Game Vision | Auto-fixes PrintWindow DPI pad, 3-tier grid, 1:1 zoom, ~20ms WinRT OCR | Full-screen re-screenshots | N/A | None |
| Repetitive & Zero-Token Replay | desktop_batch, local BatchSession, record-once JSON/Python macro | Full LLM loop every run | Scripted tests only | Manual Python scripts |
Architecture
flowchart TB
Client["MCP Client (Claude Desktop / Cursor / Windsurf / Antigravity)"] <-->|"Stdio JSON-RPC 2.0"| Server["agy_computer_use_mcp.py (v6.4.0 - 32 Tools)"]
Server --> Desktop["Win32 & UIA Engine (cu_helpers.py + agy_screen_overlay.py)"]
Server --> Vision["Vision & WinRT OCR (Windows.Media.Ocr + SoM + 3-Tier Grid)"]
Server --> Bridge["Agy Chrome Bridge (MV3 Extension + Native Host)"]
Server --> Replay["Macros & Local Batch (macro JSON/Python + BatchSession)"]
Server -.->|"Antigravity IDE bonus"| AppPane["Antigravity Built-In Browser (app_browser via DevTools)"]
Desktop -->|"SendInput + UIA CacheRequest + ESC Guard"| WinApps["Desktop Apps & Canvas/Games"]
Vision -->|"Text + @(cx,cy) in TextContent"| Client
Bridge -->|"127.0.0.1 Token TCP <-> Native Messaging"| Chrome["User's Logged-In Chrome / Edge"]
Highlight: Bundled Agy Chrome Bridge Extension — Zero Mouse Hijack, Zero Tab Stealing
Most browser MCP servers force an ugly trade-off: either spawn a fresh, logged-out Playwright Chromium browser, or hijack your mouse/active window via desktop clicks. agy-cpt-use-mcp.sou bundles the full Agy Chrome Bridge MV3 extension + Native Messaging host right in the repo (extension & host docs):
- Zero Mouse & Keyboard Hijacking: Actions run completely in background tabs via
chrome.debugger+ a local127.0.0.1token-authenticated Native Messaging relay (agy_chrome_host.py). Your cursor and keyboard never get pulled away while the AI reads pages, clicks, uploads files, or inspects network/console logs. - Zero Tab & Window Stealing: Never hijacks your active
[USER_HERE]tab. Whenever[CALLING],[AUDIBLE],[PRIVATE_CHAT], or[BANKING]tabs exist (ornew_window=true),chrome_browser(action="open")automatically opens or reuses a dedicated background Chrome window ([AGENT_WIN],focused: false) and preserves your current window focus — meaning no stray tabs and no debugging banner over your main browser window. - Respects
F12DevTools & User Layout: Refuses to steal tabs where you already attachedF12DevTools, blocksviewport/deviceemulation on non-[AGENT_WIN]user tabs unlessforce=true, and cleanly removes Chrome's debug bar onaction="done"(plus 120s idle auto-detach). - Works With Your Real Logins +
v1.1.0Pipelining: Uses your already-logged-in Gmail, Zalo, tax/public portals, and internal dashboards, piercing same-origin iframes, cross-origin OOPIF frames, open Shadow DOM, and React inputs, withcdp_batchpipelining (19.1xfasterbatch), auto-restored minimized[AGENT_WIN]windows (restore_window,focused: false), and MV3 service-worker sleep recovery (syncAttachedFromTargets+chrome.storage.session).
Quick Start (60 Seconds)
1. Clone & Install Dependencies
Requires Windows 10/11 and Python 3.10+.
git clone https://github.com/athsou/agy-cpt-use-mcp.sou.git
cd agy-cpt-use-mcp.sou
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Optional: Only install Playwright (
pip install playwright+playwright install chromium) if you also plan to usecdp_action/cdp_list_tabsagainst a separate--remote-debugging-portChrome instance. Core desktop UIA, OCR, overlay, macros, and the MV3 Chrome Bridge do not require Playwright.
2. Add to Your MCP Client
Point your MCP client to your virtual environment's python.exe (recommended) and src/agy_computer_use_mcp.py. Ready-to-copy templates live in examples/.
Claude Desktop / Cursor / Windsurf / Antigravity (mcpServers JSON)
{
"mcpServers": {
"agy-computer-use": {
"command": "C:/path/to/agy-cpt-use-mcp.sou/.venv/Scripts/python.exe",
"args": [
"C:/path/to/agy-cpt-use-mcp.sou/src/agy_computer_use_mcp.py"
]
}
}
}
Config file locations:
- Claude Desktop:
%APPDATA%\Claude\claude_desktop_config.json(seeexamples/mcp_config.claude_desktop.json) - Cursor:
.cursor/mcp.jsonor%USERPROFILE%\.cursor\mcp.json(seeexamples/mcp_config.cursor.json) - Antigravity:
%USERPROFILE%\.gemini\antigravity\mcp_config.json(seeexamples/mcp_config.antigravity.json)
3. Enable Logged-In Chrome / Edge Automation (Optional, 2 Steps)
Want the agent to work in background tabs inside your real, already-logged-in Chrome or Edge without stealing your mouse or keyboard?
Step A — Register the Native Messaging Host & generate a local extension key:
.venv\Scripts\python.exe chrome-bridge\install.py
Running install.py first generates a fresh local RSA public key in chrome-bridge/extension/manifest.json (giving the unpacked extension a deterministic ID on your PC) and registers agy.chrome.bridge in HKCU\Software\Google\Chrome\NativeMessagingHosts and HKCU\Software\Microsoft\Edge\NativeMessagingHosts.
Step B — Load the unpacked extension once:
- Open
chrome://extensions(oredge://extensions) - Enable Developer mode
- Click Load unpacked and select
<repo>\chrome-bridge\extension
Tip: If you update
background.jslater, click Reload once on the extension card inchrome://extensions.
4. Optional: Agent Playbook Skill
If your agent supports SKILL.md playbooks (such as Antigravity or skill-compatible clients), copy skills/agy-computer-use/SKILL.md to teach the model the optimal observe -> act -> verify loop, WinRT OCR shortcuts, and safety rules.
Human-First Safety & Privacy Guardrails
Automation should never feel dangerous or intrusive. Every action passes through built-in runtime guards:
| Tag / Mechanism | What It Protects | Runtime Behavior |
|---|---|---|
[CALLING] | Active Google Meet, Zoom, Teams, Messenger/Zalo/Discord calls | Blocks clicks, typing, focus steals, and tab attachment |
[BANKING] | Banking & payment portals / desktop finance apps | Blocks interaction by default unless user explicitly passes force=true |
[PRIVATE_CHAT] | Messenger, Zalo, Telegram, WhatsApp, Discord chats | Refuses to interrupt foreground chat or attach without explicit override |
[AUDIBLE] | Tabs playing audio or video | Auto-isolates new agent browser tabs into [AGENT_WIN] |
[EMAIL] | Webmail & desktop mail clients (outlook.exe, olk.exe, thunderbird.exe) | Tagged clearly in window and tab listings |
[ADMIN] | Elevated UAC/administrator processes (UIPI boundary) | Warns before failing on OS UIPI instead of silently misfiring |
[USER_HERE] / [USER_ACTIVE] / [USER_BUSY] | Human presence detected via GetLastInputInfo | Refuses to yank focus while you are actively typing/moving the mouse |
Click-Through Overlay + <50ms ESC | Physical emergency stop | start_overlay draws a cyan border + banner on the active monitor; pressing ESC halts immediately and releases held keys |
| Scoped Call Exception | Running a separate app while on a call | start_overlay(hwnd=X, allow_while_calling=true) grants focus strictly to window X while keeping call/bank/chat windows 100% locked |
| Host & Hotkey Locks | Accidental typing in your IDE/terminal or dangerous combos | Refuses stray keyboard input without hwnd; requires confirm=true for win+r, alt+f4, ctrl+alt+delete, win+l, etc. |
Canvas, Games & High-Speed Vision
When Windows UI Automation returns 0 elements (DirectX/Unity/canvas apps, games, custom-drawn UIs), agy-cpt-use-mcp.sou switches seamlessly to high-precision visual tools:
- 3-Tier Pixel Coordinate Grid & Live
shot_idTracking:capture_window(hwnd, include_som=true)automatically draws a labeled100px/50px/25pxruler when UIA finds 0 controls. Passingshot_idtoclick_screen,drag, orscrollmaps image pixels to live post-focusHWNDbounds automatically — no scale math for the LLM. PrintWindowDPI-Pad Auto-Fix: Automatically detects and crops DPI-unaware black borders on125%/150%scaled monitors so captured surfaces align 1:1 with physical clicks.- Zero-Extra-Turn Local WinRT OCR (
~20ms): Passocr=true,ocr_region=[x1, y1, x2, y2], orocr_query="Confirm"tocapture_window,take_screenshot, ordesktop_batch(ocr_after=true). A persistent localWindows.Media.Ocrworker returns"Label" @(cx, cy)click coordinates directly inTextContent— eliminating extra image-read turns. - 1-Call
desktop_batch: Chain up to 25 steps (click,click_element,click_ocr,wait_ocr,set_value,type,hotkey,key_event,drag,scroll,wait,capture) withref_size=[w, h]auto-scaling andmethod="unicode"+clear_backspaces+focus_delay_msfor IME/DirectX-resistant inputs. - Local
cu_batch_runner.BatchSession: For>= 5repetitive canvas/game items, run a local Python script (seeexamples/batch_runner_example.py) with target-window lock and<50mshardwareESCabort:
from cu_batch_runner import BatchSession
with BatchSession(hwnd=target_hwnd, ref_size=(1280, 720)) as session:
session.click(220, 140, wait_ms=250)
session.scroll_until_ocr(
"Target Option",
region=[180, 160, 460, 440],
scroll_xy=(320, 300),
click_match=True,
)
session.type_text("Exact Query", method="unicode", clear_backspaces=16, focus_delay_ms=150)
Zero-Token Macros (record -> parameterize -> replay)
Automate repeatable forms, exports, and browser workflows once — then replay them deterministically without LLM tokens in the loop:
- Record:
macro(action="start", name="monthly_export")— records desktop UIA + browser input actions (resolving transient#Nrefs into durable selectors/automation IDs). - Parameterize & Protect Secrets:
macro(action="stop", params={"client": "Acme Corp"})— turns matching inputs/URLs/selectors into{{client}}, and automatically redacts password fields as{{password}}(passwords are never written to disk). - Replay or Export:
macro(action="play", name="monthly_export", params={"client": "Globex"})(supportsdry_run=true,from_step,to_step)macro(action="export_python", name="monthly_export")— emits an editable standalone Python script callingcu.handle_tool_call.
Complete 32-Tool Reference
Compatibility note: 31 tools work universally with any stdio MCP client (Claude Desktop, Cursor, Windsurf, custom agents). Tool #30 (
app_browser) targets the Antigravity IDE right-hand browser pane viaDevToolsActivePortand is safely isolated if you use another host.
Click to expand all 32 MCP tools across 6 categories
1. Window Management & Safety Overlay (7)
| Tool | Description |
|---|---|
start_overlay | Show click-through cyan border & banner on the target monitor, arm hardware ESC abort, and optionally scope allow_while_calling=true to one hwnd. |
stop_overlay | Hide the screen overlay indicator. |
list_windows | List visible top-level windows with HWND, title, process, size, and [CALLING]/[PRIVATE_CHAT]/[BANKING]/[ADMIN]/[USER_ACTIVE] tags. |
launch_app | Open an app by alias (notepad, calc, chrome, edge, word, excel...), executable, path, ms-settings: URI, or Start-menu/Store name and return its HWND. |
get_foreground_window | Inspect active HWND, title, class, rect, process, user_idle_ms, user_busy, and sensitivity category. |
focus_window | Focus a window by HWND or title substring and optionally set state (normal/maximized/minimized) or rect=[x, y, w, h]. |
wait | Sleep up to 30 seconds with interruptible ESC abort checks. |
2. Windows UI Automation & Elements (6)
| Tool | Description |
|---|---|
observe | Fast IUIAutomation CacheRequest inspection returning numbered #N elements + centers/rects/DPI; supports query, control_type, scope="window|document", interactive_only, offset, include_screenshot, include_som, include_grid. |
ui_tree | Detailed text-only UIA tree walker with max_depth, max_nodes, only_named, interactive_only, and paging. |
click_element | Click by #ref, accent-insensitive name, automation_id, or control_type (clicks=1|2|3, invoke_only=true for background UIA without stealing focus). |
set_value | Replace field/combo contents via UIA ValuePattern or reliable keystrokes (works in Save As / Open file dialogs) with read-back verification. |
wait_for | Poll until an element matching query/control_type appears (or disappears with gone=true). |
read_text | Read full plain text of a web page, document, editor, or element (ref) with start/max_chars paging. |
3. Input & Batch Desktop/Canvas Execution (8)
| Tool | Description |
|---|---|
type_text | Verified-focus typing with UniKey/EVKey-safe clipboard restore (auto), KEYEVENTF_UNICODE (unicode), clear_backspaces, and focus_delay_ms. |
hotkey | Send key combinations (ctrl+s, alt+tab, f5) with verified hwnd focus and confirm=true protection on dangerous combos. |
key_event | Press/hold/release a key (down/up, optional timed duration 0.05..5.0s). |
mouse_move | Move cursor in physical screen pixels or shot_id image pixels. |
click_screen | Click (left/right/middle, clicks=1|2|3) using live shot_id coordinate mapping + optional capture_after. |
drag | Smooth mouse drag from (x1, y1) to (x2, y2) with shot_id mapping and capture_after. |
scroll | Scroll wheel (up/down/left/right) optionally at (x, y) with shot_id mapping. |
desktop_batch | Execute 1–25 desktop/canvas steps (click, click_element, click_ocr, wait_ocr, set_value, type, hotkey, key_event, drag, scroll, wait, capture) in one call with ref_size scaling and ocr_after/ocr_region. |
4. Vision, Screenshots & Local OCR (2)
| Tool | Description |
|---|---|
capture_window | Background-safe PrintWindow capture with DPI-pad auto-fix, 1:1 zoom region/ref/preset, include_som, 3-tier include_grid, and local Windows.Media.Ocr (ocr, ocr_region, ocr_query). |
take_screenshot | Full virtual desktop capture or 1:1 zoom crop with coordinate grid and local WinRT OCR. |
5. Browser Automation (8)
| Tool | Description |
|---|---|
chrome_browser | Drive the user's logged-in Chrome/Edge in background tabs via Agy Chrome Bridge (open, tabs, activate, snapshot, read, screenshot w/ SoM & full_page, click, hover, type, select, upload, dialog, press, scroll, wait, logs w/ errors_only, downloads, viewport/device, batch, eval, done). Handles OOPIF iframes, shadow DOM, React inputs, and [AGENT_WIN] isolation. |
app_browser | (Antigravity IDE bonus) Same rich DOM/screenshot/network toolset inside Antigravity's right-hand built-in browser pane. |
browser_get_active_tab | Read URL and title of the active Chrome/Edge window via UIA (no screenshot). |
browser_open_tab | Open a new browser tab (Ctrl+T) and optionally navigate to a URL. |
browser_navigate | Navigate the active browser tab via address bar (Ctrl+L) without touching the clipboard. |
browser_close_tab | Close the active browser tab (Ctrl+W). |
cdp_list_tabs | List tabs on a --remote-debugging-port Chrome instance (optional Playwright CDP route). |
cdp_action | Execute DOM actions + console/network capture over Playwright CDP debug port. |
6. Record & Replay Macros (1)
| Tool | Description |
|---|---|
macro | start, stop, cancel, list, show, play, export_python, delete (moves to Recycle Bin). Records both desktop UIA and browser input actions with {{param}} templating and {{password}} redaction. |
Environment Variables
| Variable | Default | Purpose |
|---|---|---|
AGY_CU_ALLOW_TITLES | Unset (all allowed except guarded apps) | Comma-separated window title substrings restricting all input actions |
AGY_CU_PRESENCE_MS | 2500 | Human activity threshold in ms before tagging [USER_BUSY] |
AGY_CU_SESSION_ID | Empty | Isolate overlay lock/abort flags per agent session (max 24 chars) |
AGY_CU_CDP_PORT | 9222 | Debug port used by cdp_list_tabs / cdp_action |
AGY_CU_CHROME_PROFILE | ~/.gemini/chrome_debug_profile | Profile directory when auto_launch=true on CDP tools |
AGY_CU_CACHE_DIR | ~/.gemini/auto_cache | Directory for Chrome Bridge discovery metadata & session files |
AGY_CU_MACRO_DIR | ~/.gemini/macros | Directory where recorded JSON macros are saved |
AGY_CU_LOG | %TEMP%\agy_computer_use.log | Rotating JSONL action log path |
Running Tests
# Upgrade & macro-to-Python unit tests
python tests/test_computer_use_upgrades.py
# Deterministic CI suite (syntax, stdio MCP JSON-RPC, schema checks, unit & mock tests)
python tests/test_computer_use.py --ci
# Full local Windows desktop suite (adds Win32 Notepad tests + 1.2s overlay smoke test)
python tests/test_computer_use.py
MCP Registry & Online Inspector (Glama)
You can inspect all 32 tool schemas, review automated maintenance/quality checks, and explore this server online before installing locally:
- Glama Directory & Quality Score: glama.ai/mcp/servers/athsou/agy-cpt-use-mcp.sou — test tools directly via MCP Inspector.
- Official MCP Registry ID:
io.github.athsou/agy-cpt-use-mcp(server.json+ signed.mcpbbundle in GitHub Releases).
Contributing & Security
- Read CONTRIBUTING.md before opening a pull request.
- Read SECURITY.md for details on the built-in safety architecture and private vulnerability reporting.
License
Licensed under the MIT License — Copyright (c) 2026 Sou (@athsou).
Crafted by Sou (@athsou) · sou.io.vn
If agy-cpt-use-mcp.sou saved you hours of brittle UI scripting, consider giving the repo a ⭐ Star or citing it via CITATION.cff!
https://github.com/athsou/agy-cpt-use-mcp.sou/releases/download/v6.4.0/agy-cpt-use-mcp.mcpb# mcpb: https://github.com/athsou/agy-cpt-use-mcp.sou/releases/download/v6.4.0/agy-cpt-use-mcp.mcpb