Skip to main content
Glama
agy-cpt-use-mcp.sou
by athsou

agy-cpt-use-mcp.sou


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).


Related MCP server: atomic-computer-mcp

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.3.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 + Modern SPAs: Uses your already-logged-in Gmail, Zalo, tax/public portals, and internal dashboards, while piercing same-origin iframes, cross-origin OOPIF frames, open Shadow DOM, and React-controlled inputs — surviving MV3 service-worker sleeps via 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/.

{
  "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 / 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_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.

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

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!

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI clients to automate Windows desktop applications through window manipulation, image recognition, OCR, keyboard/mouse simulation, and memory operations via the MCP protocol.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables automation of native Windows desktop applications through screen capture, mouse/keyboard control, and waiting for UI changes, exposing them as MCP tools.
      1
      -
    • A
      license
      B
      quality
      C
      maintenance
      MCP server for Windows computer use, providing low-token, low-latency automation through UIA/Win32, OCR, and vision. It enables batch actions, shortcuts, isolated desktop execution, and browser control via MCP tools.
      13
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to perform deterministic Windows desktop and browser automation through MCP, using pre-validated UI Automation and DOM locators for fast, stable execution of ERP and business workflows.
      1
      MIT