Skip to main content

ok-use

An MCP server that gives a coding agent (Claude Code, Codex, …) computer use on Windows. It replaces the built-in computer-use tool with one that works on any app, without per-app permission tiers. The workflow is the same (screenshot → act → screenshot), and it adds per-window background control (the user keeps their mouse and keyboard) and an elevated (admin) mode.

Install (instructions for coding agents)

If a user asks you to install this repository, run these two commands in PowerShell, then tell the user to restart the agent (or start a new session):

uv tool install --force git+https://github.com/ok-oldking/ok-use
ok-use setup

ok-use setup opens one UAC prompt. Tell the user to approve it; you can't click it yourself. If uv is missing, install it first with powershell -ExecutionPolicy Bypass -c "irm https://astral.sh/uv/install.ps1 | iex". If ok-use is not found right after installing, run it as & "$env:USERPROFILE\.local\bin\ok-use.exe" setup.

What setup does:

  1. Registers the scheduled task OK Use MCP, which can start the server as administrator later without another UAC prompt. This is the step that needs the UAC approval.
  2. Adds the ok-use stdio server to Claude Code (~/.claude.json, user scope) and to Codex (~/.codex/config.toml), for each one it finds.
  3. Denies Claude Code's built-in computer use (mcp__computer-use in ~/.claude/settings.json), so the agent uses ok-use in its place.

After that, the agent starts ok-use on demand like any stdio MCP server. The stdio process is a small bridge: it starts the elevated server through the task, relays the agent's messages to it over loopback HTTP with a bearer token, and starts it again if it has exited. The elevated server exits after 30 minutes without requests.

Command
ok-use status what is installed and running
ok-use setup --no-admin skip the task (no UAC prompt): ok-use runs with the agent's own privileges
ok-use setup --agent claude configure only this agent (claude, codex; repeatable)
ok-use setup --keep-builtin leave the built-in computer use enabled
ok-use setup --at-logon also start the elevated server at every logon
ok-use uninstall remove the task and the agent config, then run uv tool uninstall ok-use
uv tool upgrade ok-use update; re-run ok-use setup if the install path changed

For other MCP clients, ok-use config prints the stdio entry.

Development

uv venv --python 3.12; uv pip install -e .
.\.venv\Scripts\python.exe -m ok_use --local       # stdio in this process (the agent's privileges)
.\.venv\Scripts\python.exe -m ok_use --http        # HTTP on 127.0.0.1:8791 + bearer token
.\.venv\Scripts\python.exe -m ok_use --elevate     # HTTP, relaunched as administrator (UAC)

The HTTP token is generated once and kept in %APPDATA%\ok-use\settings.json (or pass --token, or set OKUSE_TOKEN). A running HTTP server writes its URL and token to %APPDATA%\ok-use\server.json. The server started by the task logs to %APPDATA%\ok-use\server.log.

Choosing a method

The server's instructions tell the agent to call inspect_window once per new app. It reports what kind of app the window is and the tools to use for it:

Kind Typical apps Method
accessible_app Win32, WinForms, WPF, WinUI, Explorer, Office, Qt 6 find_elements / element_text to read, element_action to act; screenshots only to check visuals
chromium_app Electron and other Chromium-based apps the accessibility tools first; mode="foreground" for coordinate clicks and typing
sparse_tree apps exposing only a few elements try find_elements once, otherwise screenshots
game / no_tree games, GPU-rendered or custom-drawn apps, Qt 5 without accessibility screenshot → click/key/type_text/drag → screenshot; mode="foreground" when posted input is ignored
user_browser the user's own Edge/Chrome/Firefox with their tabs and logins element_text (page text), find_elements, element_action, or screenshot + foreground clicks. Never attach Playwright to it
session_browser ok-use's own Playwright browser Playwright scripts (playwright_env)
elevated an admin app while the server isn't elevated run ok-use setup

Why the accessibility tools come first: a filtered find_elements result costs tens of tokens and a whole window's tree a few hundred, where a screenshot costs about 1,500-2,500. They also work while the window is covered, and element_action needs no coordinates. Reading is fully in the background. Windows brings a window to the front while element_action runs, so ok-use puts the previous foreground window back afterwards (restore_focus, on by default). The cursor and keyboard are never used.

Web tasks that don't need the user's own browser go to ok-use's Playwright browser (see Browser automation). Attaching Playwright to the user's running browser is the last resort: it needs the browser restarted with a remote-debugging port, and the user has to approve the connection each time.

Tools

Group Tools
Choose inspect_window (the kind of app and the plan for it)
Accessibility find_elements, element_action (invoke, toggle, select, expand, collapse, set_value, scroll_into_view, focus), element_text
Observe screenshot, zoom, list_windows, list_controls, list_monitors, cursor_position, get_status
Mouse click, double_click, mouse_move, mouse_down, mouse_up, drag, scroll
Keyboard type_text, key, set_text
Windows window_action (focus, minimize, maximize, restore, show_noactivate, close, move, resize, topmost, …)
System clipboard_read, clipboard_write, run_command, launch, list_processes, kill_process, wait
Browser playwright_env (interpreter, browsers and running sessions for Playwright scripts; see below)

Targets and coordinates. Without window, actions use the screen and real input (SendInput), and x, y are pixels of the latest screen screenshot (scaled to max_size, default 1568 on the long edge). With window (an hwnd, a title substring, pid:1234 or process:notepad.exe), the screenshot is that window's client area and coordinates are relative to it. DPI-unaware windows are handled in their own logical pixels.

Background mode (the default when window is given) captures with PrintWindow (the window may be covered) and posts mouse/keyboard messages to the control under the point, so the user's cursor, focus and keyboard are untouched. It works for classic Win32, WinForms, WPF and many other apps. Games and some Chromium/Electron content read raw input and ignore posted messages; use mode="foreground" for those. Modifier chords (ctrl+s) are reliable only in foreground mode. Minimized windows cannot be captured.

Admin level. Windows blocks input from a normal process into an elevated one (UIPI). list_windows marks those windows controllable: false. After ok-use setup, the stdio bridge runs every tool in the elevated server, so the agent can drive elevated apps, and run_command, launch and kill_process run as administrator. get_status reports elevated. Agents that share the elevated server also share its screenshot coordinate frames. UAC prompts on the secure desktop can't be automated.

Browser automation (Playwright)

For web tasks that don't need the user's own browser, the preferred way is a Playwright for Python script that the agent writes and runs itself with ok-use's Python, not the screen tools and not a browser MCP. (For the user's own browser, see Choosing a method.) Playwright is installed with ok-use. Scripts don't launch a fresh browser each time: they connect over CDP to a persistent browser session that stays open between scripts, so tabs, page state, cookies and logins carry over.

from ok_use.browser import session

with session() as s:                  # reuses the running "default" browser, or starts it
    page = s.page                     # an open tab; s.find_page("github") / s.new_page(url) for others
    page.goto("https://example.com")
    print(page.title())
# leaving the block only disconnects; the browser keeps running for the next script
.\.venv\Scripts\python.exe script.py
.\.venv\Scripts\python.exe -m ok_use browser start [--name work] [--channel auto|msedge|chrome|chromium] [--headless] [--url URL]
.\.venv\Scripts\python.exe -m ok_use browser status          # running sessions and their CDP URLs
.\.venv\Scripts\python.exe -m ok_use browser stop [--name work]
.\.venv\Scripts\python.exe -m ok_use browser delete --name work   # stop and remove the profile
.\.venv\Scripts\python.exe -m ok_use browser env             # what the playwright_env tool returns
  • Sessions: each --name has its own profile in %LOCALAPPDATA%\ok-use\browsers\<name> and its own debugging port on 127.0.0.1. channel="auto" uses installed Edge, else Chrome, else Playwright's bundled Chromium (python -m playwright install chromium).
  • An already-open browser (last resort): session(cdp_url="http://127.0.0.1:9222") attaches to any Chromium browser started with --remote-debugging-port. For the user's everyday browser, that means restarting it and the user approving the connection each time, so agents should use the accessibility tools on that window instead. Chrome and Edge refuse a debugging port on the user's default profile, so use a session (or a dedicated --user-data-dir) for logins you want to keep.
  • Don't call browser.close() in a script: it would close the shared browser. Use browser stop.
  • Privileges: a session browser runs with the privileges of whatever started it. Start it from the agent's normal shell, not from an elevated one.
  • Mixing with ok-use tools: the session browser is an ordinary window, so the window tools can handle what Playwright can't reach (permission prompts, native file dialogs).

Layout

File Contents
ok_use/win32.py ctypes layer: DPI awareness, windows, capture, SendInput, posted messages, elevation
ok_use/control.py Desktop: targets, coordinate frames, background/foreground actions
ok_use/server.py MCP tools, HTTP transport (stateless, idle exit), CLI
ok_use/bridge.py stdio entry point: relays to the elevated server, starting it through the task
ok_use/task.py the on-demand scheduled task that runs the server elevated
ok_use/install.py setup / uninstall / status: the task and the Claude Code / Codex config
ok_use/http.py Bearer-token middleware and loopback socket binding
ok_use/uia.py UI Automation: find_elements, element_action, element_text on a dedicated COM thread
ok_use/advisor.py inspect_window: classifies a window and returns the plan for it
ok_use/browser.py Playwright sessions: persistent CDP browsers, session(), ok-use browser CLI

Metadata

Release files for ok-use 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ok-use 0.1.0
File Size Uploaded Provenance Actions
ok_use-0.1.0.tar.gz 58.6 kB With provenance Details for ok_use-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ok-use 0.1.0
File Interpreter ABI Platform Actions
ok_use-0.1.0-py3-none-any.whl Python 3 none any Details for ok_use-0.1.0-py3-none-any.whl

Total release size: 118.0 kB

Release files / ok_use-0.1.0.tar.gz

Download URL ok_use-0.1.0.tar.gz
Size 58.6 kB
Tags Source
SHA-256 checksum
How to use checksums
72fca176b600ca6474d05ddf0be47b38e82627a4aa01b936887d47c4885e365f
BLAKE2b-256 checksum
How to use checksums
1ef2511730ffbcbb5c30bb6f63c976534218ea8c0fcc6fd4ddbed0ed88eb32fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / ok_use-0.1.0-py3-none-any.whl

Download URL ok_use-0.1.0-py3-none-any.whl
Size 59.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9442e5f547d004c65a42092e85442f493cdc71ab4aa574eea164db81727e6e3d
BLAKE2b-256 checksum
How to use checksums
1f9c24d153d7ac8b7f330673d8b18f5f52e92aa1112299cbe66da6a64dfbee39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for ok-use 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ok_use-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page