Repository avatar
Browser Automation
v6.4.0
active

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

agy-cpt-use-mcp.sou

Native Windows Desktop, Canvas/Game & Logged-In Chrome Automation MCP Server

English  |  Tiếng Việt

Version v6.4.0 Windows 10/11 Python 3.10+ 32 MCP Tools MIT License Crafted by Sou Windows CI Glama MCP Server Score

Architecture · Chrome Bridge Extension · Quick Start · Safety Guardrails · 32 Tools · Glama & Registry · Launch Kit

agy-cpt-use-mcp.sou live showcase — Chrome Bridge v1.1.0, WinRT OCR & ESC Guard


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.1x Faster Browser Batching (1620.9ms -> 84.9ms for 8 steps): New cdp_batch protocol in chrome-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.8x Faster SoM Screenshots (125.8ms -> 11.6ms) & 5.6x Faster Clicks (1461ms -> 262ms): Single-pass SOM_SNAPSHOT_AND_MARK_JS + rAF paint settle and streamlined target polling.
  • Stable tab_id= Addressing, wait(ms=...), Expanded batch, & Auto-Restore [AGENT_WIN]: Prefer durable tab_id= across tab opens/closes; batch now supports eval, activate, dialog, and multi-screenshot image blocks; minimized [AGENT_WIN] windows auto-restore via restore_window (focused: false).
  • 3.3–7.3x Faster 1440p Lossless PNG Saves (save_png_fast): p95 screenshot encode dropped from 1083.4ms to 148.6ms with 100% pixel-identical lossless output.
  • 3.3–11.8x Faster Cold WinRT OCR & 2.8–3.1x Faster Overlay Startup: Direct BMP worker handoff + background warm_ocr_worker(), and instant Win32 cyan overlay (· .sou) window reveal before lazy spinner frame baking (start_overlay p50 523.6ms -> 188.0ms).

Why agy-cpt-use-mcp.sou?

Most computer-use agents break down in real Windows workflows for six concrete reasons:

  1. 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.
  2. They lose your browser logins — spawning an empty Playwright Chromium instance with zero cookies, failing on Gmail, internal portals, e-tax, or SaaS dashboards.
  3. They mangle Vietnamese & IME input — typing through UniKey/EVKey Telex hooks turns oo into ô and w into ư inside DirectX/game search boxes or custom inputs.
  4. They click shifted pixels on scaled displays — PrintWindow DPI padding on 125%/150% laptops and window movement cause coordinate drift after every screenshot.
  5. 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.
  6. 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

Capabilityagy-cpt-use-mcp.souScreenshot-Only Computer UsePlaywright-Only Browser MCPBasic UIA Wrappers
Windows UIA + CacheRequest speedSingle-IPC IUIAutomation CacheRequest tree + #N refsNone (blind pixel clicking)Browser DOM onlyPer-property IPC (~7x calls)
Logged-in Chrome/Edge (no mouse hijack)MV3 Chrome Bridge (chrome_browser) + OOPIF + session recoverySteals physical mouse/keyboardIsolated fresh profile (logged out)Foreground UIA only
Privacy & call protectionAuto-tags [CALLING], [BANKING], [PRIVATE_CHAT], [USER_BUSY]Clicks anything on screenN/ANone
Hardware panic abort<50ms physical ESC abort + click-through cyan borderWait for model timeoutN/ANone
IME / UniKey / DirectX typingAuto clipboard-restore + KEYEVENTF_UNICODE modeMangled Telex keysBrowser onlyStandard SendInput
DPI & Canvas / Game VisionAuto-fixes PrintWindow DPI pad, 3-tier grid, 1:1 zoom, ~20ms WinRT OCRFull-screen re-screenshotsN/ANone
Repetitive & Zero-Token Replaydesktop_batch, local BatchSession, record-once JSON/Python macroFull LLM loop every runScripted tests onlyManual 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 local 127.0.0.1 token-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 (or new_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 F12 DevTools & User Layout: Refuses to steal tabs where you already attached F12 DevTools, blocks viewport/device emulation on non-[AGENT_WIN] user tabs unless force=true, and cleanly removes Chrome's debug bar on action="done" (plus 120s idle auto-detach).
  • Works With Your Real Logins + v1.1.0 Pipelining: 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, with cdp_batch pipelining (19.1x faster batch), 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 use cdp_action / cdp_list_tabs against a separate --remote-debugging-port Chrome 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:


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:

  1. Open chrome://extensions (or edge://extensions)
  2. Enable Developer mode
  3. Click Load unpacked and select <repo>\chrome-bridge\extension

Tip: If you update background.js later, click Reload once on the extension card in chrome://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 / MechanismWhat It ProtectsRuntime Behavior
[CALLING]Active Google Meet, Zoom, Teams, Messenger/Zalo/Discord callsBlocks clicks, typing, focus steals, and tab attachment
[BANKING]Banking & payment portals / desktop finance appsBlocks interaction by default unless user explicitly passes force=true
[PRIVATE_CHAT]Messenger, Zalo, Telegram, WhatsApp, Discord chatsRefuses to interrupt foreground chat or attach without explicit override
[AUDIBLE]Tabs playing audio or videoAuto-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 GetLastInputInfoRefuses to yank focus while you are actively typing/moving the mouse
Click-Through Overlay + <50ms ESCPhysical emergency stopstart_overlay draws a cyan border + banner on the active monitor; pressing ESC halts immediately and releases held keys
Scoped Call ExceptionRunning a separate app while on a callstart_overlay(hwnd=X, allow_while_calling=true) grants focus strictly to window X while keeping call/bank/chat windows 100% locked
Host & Hotkey LocksAccidental typing in your IDE/terminal or dangerous combosRefuses 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_id Tracking: capture_window(hwnd, include_som=true) automatically draws a labeled 100px / 50px / 25px ruler when UIA finds 0 controls. Passing shot_id to click_screen, drag, or scroll maps image pixels to live post-focus HWND bounds automatically — no scale math for the LLM.
  • PrintWindow DPI-Pad Auto-Fix: Automatically detects and crops DPI-unaware black borders on 125%/150% scaled monitors so captured surfaces align 1:1 with physical clicks.
  • Zero-Extra-Turn Local WinRT OCR (~20ms): Pass ocr=true, ocr_region=[x1, y1, x2, y2], or ocr_query="Confirm" to capture_window, take_screenshot, or desktop_batch (ocr_after=true). A persistent local Windows.Media.Ocr worker returns "Label" @(cx, cy) click coordinates directly in TextContent — 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) with ref_size=[w, h] auto-scaling and method="unicode" + clear_backspaces + focus_delay_ms for IME/DirectX-resistant inputs.
  • Local cu_batch_runner.BatchSession: For >= 5 repetitive canvas/game items, run a local Python script (see examples/batch_runner_example.py) with target-window lock and <50ms hardware ESC abort:
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:

  1. Record: macro(action="start", name="monthly_export") — records desktop UIA + browser input actions (resolving transient #N refs into durable selectors/automation IDs).
  2. 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).
  3. Replay or Export:
    • macro(action="play", name="monthly_export", params={"client": "Globex"}) (supports dry_run=true, from_step, to_step)
    • macro(action="export_python", name="monthly_export") — emits an editable standalone Python script calling cu.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 via DevToolsActivePort and is safely isolated if you use another host.

Click to expand all 32 MCP tools across 6 categories

1. Window Management & Safety Overlay (7)

ToolDescription
start_overlayShow click-through cyan border & banner on the target monitor, arm hardware ESC abort, and optionally scope allow_while_calling=true to one hwnd.
stop_overlayHide the screen overlay indicator.
list_windowsList visible top-level windows with HWND, title, process, size, and [CALLING]/[PRIVATE_CHAT]/[BANKING]/[ADMIN]/[USER_ACTIVE] tags.
launch_appOpen 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_windowInspect active HWND, title, class, rect, process, user_idle_ms, user_busy, and sensitivity category.
focus_windowFocus a window by HWND or title substring and optionally set state (normal/maximized/minimized) or rect=[x, y, w, h].
waitSleep up to 30 seconds with interruptible ESC abort checks.

2. Windows UI Automation & Elements (6)

ToolDescription
observeFast 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_treeDetailed text-only UIA tree walker with max_depth, max_nodes, only_named, interactive_only, and paging.
click_elementClick by #ref, accent-insensitive name, automation_id, or control_type (clicks=1|2|3, invoke_only=true for background UIA without stealing focus).
set_valueReplace field/combo contents via UIA ValuePattern or reliable keystrokes (works in Save As / Open file dialogs) with read-back verification.
wait_forPoll until an element matching query/control_type appears (or disappears with gone=true).
read_textRead full plain text of a web page, document, editor, or element (ref) with start/max_chars paging.

3. Input & Batch Desktop/Canvas Execution (8)

ToolDescription
type_textVerified-focus typing with UniKey/EVKey-safe clipboard restore (auto), KEYEVENTF_UNICODE (unicode), clear_backspaces, and focus_delay_ms.
hotkeySend key combinations (ctrl+s, alt+tab, f5) with verified hwnd focus and confirm=true protection on dangerous combos.
key_eventPress/hold/release a key (down/up, optional timed duration 0.05..5.0s).
mouse_moveMove cursor in physical screen pixels or shot_id image pixels.
click_screenClick (left/right/middle, clicks=1|2|3) using live shot_id coordinate mapping + optional capture_after.
dragSmooth mouse drag from (x1, y1) to (x2, y2) with shot_id mapping and capture_after.
scrollScroll wheel (up/down/left/right) optionally at (x, y) with shot_id mapping.
desktop_batchExecute 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)

ToolDescription
capture_windowBackground-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_screenshotFull virtual desktop capture or 1:1 zoom crop with coordinate grid and local WinRT OCR.

5. Browser Automation (8)

ToolDescription
chrome_browserDrive 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_tabRead URL and title of the active Chrome/Edge window via UIA (no screenshot).
browser_open_tabOpen a new browser tab (Ctrl+T) and optionally navigate to a URL.
browser_navigateNavigate the active browser tab via address bar (Ctrl+L) without touching the clipboard.
browser_close_tabClose the active browser tab (Ctrl+W).
cdp_list_tabsList tabs on a --remote-debugging-port Chrome instance (optional Playwright CDP route).
cdp_actionExecute DOM actions + console/network capture over Playwright CDP debug port.

6. Record & Replay Macros (1)

ToolDescription
macrostart, 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

VariableDefaultPurpose
AGY_CU_ALLOW_TITLESUnset (all allowed except guarded apps)Comma-separated window title substrings restricting all input actions
AGY_CU_PRESENCE_MS2500Human activity threshold in ms before tagging [USER_BUSY]
AGY_CU_SESSION_IDEmptyIsolate overlay lock/abort flags per agent session (max 24 chars)
AGY_CU_CDP_PORT9222Debug port used by cdp_list_tabs / cdp_action
AGY_CU_CHROME_PROFILE~/.gemini/chrome_debug_profileProfile directory when auto_launch=true on CDP tools
AGY_CU_CACHE_DIR~/.gemini/auto_cacheDirectory for Chrome Bridge discovery metadata & session files
AGY_CU_MACRO_DIR~/.gemini/macrosDirectory where recorded JSON macros are saved
AGY_CU_LOG%TEMP%\agy_computer_use.logRotating 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:

agy-cpt-use-mcp.sou MCP server on Glama


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!

MCPB
https://github.com/athsou/agy-cpt-use-mcp.sou/releases/download/v6.4.0/agy-cpt-use-mcp.mcpb
Install Command
# mcpb: https://github.com/athsou/agy-cpt-use-mcp.sou/releases/download/v6.4.0/agy-cpt-use-mcp.mcpb