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, first ask them one question: "Install bug-fix updates automatically? Feature releases always ask first." Then run these two commands in PowerShell, passing fixes for yes or off for no, and tell the user to restart the agent (or start a new session):

uv tool install --force ok-use
ok-use setup --auto-update fixes

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. Installs the ok-use skill for Claude Code (scripting with ok_use.client).
  4. 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
ok-use update check for new releases now (--auto-update fixes|off changes the choice)
ok-use update --install [VERSION] install the latest bug-fix release (or VERSION) once no agent is using ok-use
ok-use skill reinstall the Claude Code skill
uv tool upgrade ok-use upgrade to the latest release by hand

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

Updates

Users stay on the version they installed. ok-use never upgrades itself to a new feature release.

  • Bug-fix (patch) releases (1.0.0 → 1.0.3) install automatically if the user chose --auto-update fixes. A detached helper waits until no agent is using ok-use (Windows locks a running Python environment's files), then runs uv tool install --force ok-use==X.Y.Z.
  • Feature releases (1.0 → 1.1) and major releases (1.x → 2.0) are only reported, in get_status, ok-use status and ok-use update. While the version is 0.y.z, each 0.y counts as a feature release.
  • The check runs at most once a day, in the background when an agent starts ok-use. It reads PyPI and updates.json in this repository.
  • The Claude Code skill follows the installed version: after an upgrade, the next agent start rewrites it.
  • Pin a version to opt out of everything: uv tool install --force ok-use==0.1.1.
  • Development checkouts (uv pip install -e .) never update themselves.

Maintainers: follow semantic versioning. Release fixes only as patches and anything that changes tools or behaviour as a feature release. To make agents tell users about an important release, add it to updates.json on main:

{"important": {"0.1.3": "fixes clicks landing in the wrong window"}}

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. Both reading and actions run in the background: the user's foreground window is never taken. Classic Win32 controls are driven with window messages and everything else (Chromium pages and browsers included) through MSAA. UI Automation's own action methods would activate the target window, so element_action refuses when no background path exists, unless allow_focus_change=True (then ok-use puts the user's window back right after).

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.

Scripts and the agent skill

For multi-step work, an agent can write a short Python script instead of making one MCP call per action. Every tool is a method of ok_use.client, running through the same elevated server:

from ok_use.client import connect

ok = connect()          # the elevated server after `ok-use setup`, else in-process; connect(local=True) forces in-process
print(ok.inspect_window(window="Notepad")["kind"])
for line in ok.find_elements(window="Notepad", interactive_only=True)["elements"][:10]:
    print(line)                                                    # e12 button "Settings" @[x, y, w, h]
print(ok.element_text(window="Notepad")["text"][:300])
ok.screenshot(window="Notepad", max_size=800, path="shot.png")   # images go to files

A script saves model round trips, and lets a check run right before the action that depends on it. Tool errors raise ok_use.client.ToolError.

ok-use setup also installs a Claude Code skill (~/.claude/skills/ok-use/SKILL.md) that teaches this: the API, the per-app method guide and patterns (verify then act, wait for a state), with this install's Python filled in. The skill's description is only a few lines, so it adds little to every session; its body loads when an agent uses it. ok-use uninstall removes it.

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/client.py connect(): every tool as a Python method, through the elevated server or in-process
ok_use/updates.py the update policy: daily check, patch auto-install, notices
ok_use/skill.py the Claude Code skill text that ok-use setup installs
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.1

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.1
File Size Uploaded Provenance Actions
ok_use-0.1.1.tar.gz 73.5 kB With provenance Details for ok_use-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 148.5 kB

Release files / ok_use-0.1.1.tar.gz

Download URL ok_use-0.1.1.tar.gz
Size 73.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7d7b19cb5a3e8f89c6e8926e95ca0832fd372ea58fb06cff67d78b75e339d0e2
BLAKE2b-256 checksum
How to use checksums
7485117893f49ec1eb756e6ebb966f27342be2a7a090801c90f1da58a0e362bc
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.1-py3-none-any.whl

Download URL ok_use-0.1.1-py3-none-any.whl
Size 74.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
797e747e4d73fc8b6171f4acdd97acd24c6ce8e26f843a89377a650d95f06573
BLAKE2b-256 checksum
How to use checksums
6aaf4ead0d84258b617f3a46203e57da246a3b12b6af9e9823de108aca9f1328
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.1

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