OculOS If it's on the screen, it's an API. Control any desktop app through JSON. REST API + MCP server. Single binary. Zero dependencies. Quick Start • How It Works • API • SDKs • MCP Setup • Dashboard • Security • Examples • API Spec • Changelog • Contributing OculOS is a lightweight daemon that reads the OS accessibility tree and exposes every button, text field, checkbox, and menu item as a JSON endpoint. It…
OculOS is a lightweight daemon that reads the OS accessibility tree and exposes every button, text field, checkbox, and menu item as a JSON endpoint. It works as a REST API for scripts, testing, and CI/CD — and as an MCP server for AI agents like Claude, Cursor, and Windsurf.
No screenshots. No pixel coordinates. No browser extensions. No code injection. No AI required. Just structured JSON.
Demo — Claude Code + OculOS → Calculator (5×5=25)
Claude Code uses OculOS MCP tools to open Calculator, find buttons, click 5 × 5 =, and read the result — fully autonomous.
Claude Code + OculOS → Spotify
Claude Code uses OculOS MCP tools to find Spotify, focus it, search for a song, and play it — fully autonomous.
Web Dashboard
Built-in dashboard with window list, interactive element tree, inspector, recorder, and live WebSocket events.
Quick Start
git clone https://github.com/huseyinstif/oculos.git
cd oculos
cargo build --release
macOS: Grant Accessibility Permission
OculOS reads the OS accessibility tree, so macOS requires you to grant permission:
Open System Settings → Privacy & Security → Accessibility
Click the lock icon and enter your password
Click + and add your terminal app (Terminal, iTerm2, Windsurf, etc.) or the oculos binary itself
Make sure the toggle is enabled
Without this permission, OculOS can list windows but cannot read UI elements or interact with them.
Linux: requirements
OculOS talks to the AT-SPI2 accessibility bus, which every mainstream desktop (GNOME, KDE, Xfce…) starts automatically. It also enables org.a11y.Status.IsEnabled at startup so Chromium/Electron/Firefox apps expose their trees.
at-spi2-core — the accessibility bus and registry (sudo apt install at-spi2-core)
xdotool — keyboard input (send-keys, keyboard scrolling) and window focus/close (sudo apt install xdotool). X11 only; on Wayland it reaches XWayland apps only.
wmctrl(optional) — graceful window close
HTTP mode (API + Dashboard)
./target/release/oculos
# API → http://127.0.0.1:7878
# Dashboard → http://127.0.0.1:7878 (embedded in the binary)
By default OculOS only listens on 127.0.0.1 and needs no token. See Security before exposing it to a network.
MCP mode (for AI agents)
./target/release/oculos --mcp
How It Works
OculOS reads the OS accessibility tree and assigns each UI element an oculos_id (16 hex chars). You use that ID to interact. IDs are stable: finding the same element again returns the same ID, so polling agents don’t pile up new IDs. An ID expires after 30 minutes without use, or when the element disappears — then you get a not_found error and simply search again.
# 1. List open windows
curl http://localhost:7878/windows
# 2. Get the UI tree for a window
curl http://localhost:7878/windows/{pid}/tree
# 3. Find a specific element
curl "http://localhost:7878/windows/{pid}/find?q=Submit&type=Button"
# 4. Click it
curl -X POST http://localhost:7878/interact/{id}/click
# 5. Type into a text field
curl -X POST http://localhost:7878/interact/{id}/set-text \
-H "Content-Type: application/json" \
-d '{"text":"hello world"}'
Every element includes an actions array — the API tells you exactly what you can do:
Batch — each action is {"element_id", "action", "text"?, "keys"?, "value"?, "direction"?}. All steps are validated before anything runs (one bad step → 400, nothing executed). With stop_on_error (default true) execution stops at the first failing step; delay_ms pauses between steps (max 5000). The response has one {index, action, element_id, success, error, code?} per executed step.
Tool output is compact JSON (null/empty fields dropped) to save context; failures come back as isError: true tool results with the error code. Logs go to stderr, so the stdout JSON-RPC stream stays clean.
For non-MCP agents (OpenAI, Gemini, custom), paste AGENTS.md into the system prompt and give the agent HTTP access.
Dashboard
Built-in web UI at http://127.0.0.1:7878, embedded in the binary (no static/ folder needed; --static-dir overrides it while developing):
Window list — all open windows with focus/close buttons
Element tree — full interactive UI tree with search and filter
Inspector — element details, properties, all available actions, element screenshot
Recorder — record a sequence of interactions, export as Python, JavaScript, or curl. Steps are saved as selectors (window exe_name + element automation_id, or label + type), so exported scripts keep working after a restart; they read OCULOS_TOKEN when auth is on
JSON viewer — raw element data with copy
WebSocket — live event indicator, real-time action feed
Shortcuts — R refresh · / search · E expand · C collapse · H highlight · J JSON
Security
OculOS can drive every app on your desktop, so the defaults are strict:
Loopback only by default — it binds to 127.0.0.1:7878; nothing on the network can reach it.
Host check — the Host header must be an IP address or localhost (add names with --allow-host), which blocks DNS-rebinding attacks from web pages.
Origin check, no CORS — browser requests carrying an Origin must come from the dashboard itself (same host) or an origin listed with --allow-origin; Origin: null is rejected. No CORS headers are sent otherwise, so other websites can’t call the API. Scripts, SDKs and MCP clients send no Origin and are unaffected. Rejections are 403 forbidden.
Optional token — --token <T> or OCULOS_TOKEN=<T> requires the token on every route except GET /health and the dashboard page. Send it as X-OculOS-Token: <T> or Authorization: Bearer <T> (WebSocket: /ws?token=<T>); otherwise you get 401 unauthorized.
Automatic token for network binds — binding to a non-loopback address (e.g. --bind 0.0.0.0:7878) without a token generates a random one and prints it in the log at startup.
The dashboard gets the token automatically when opened from the same machine. From another machine, open http://<host>:7878/?token=<token> (the token is removed from the address bar and kept for the browser tab), or paste it into the prompt in the top bar.
# Expose on the LAN with your own token
OCULOS_TOKEN=$(openssl rand -hex 16) ./target/release/oculos --bind 0.0.0.0:7878
# Let a local web app on :3000 call the API from the browser
./target/release/oculos --allow-origin http://localhost:3000
Traffic is plain HTTP; for remote use prefer an SSH tunnel or VPN. See SECURITY.md.
Platform Support
Platform
Backend
Status
Windows
UI Automation (windows-rs)
✅ Full — Win32, WPF, Electron, Qt
Linux
AT-SPI2 (atspi + zbus)
✅ Working — GTK, Qt, Electron
macOS
Accessibility API (AXUIElement + CoreGraphics)
✅ Working — Cocoa, Electron, Qt
App Compatibility
App type
Coverage
Notes
Win32 / WPF / WinForms
Excellent
Full deep tree, all interactions
GTK / Qt
Excellent
Full tree on all platforms
Electron (Spotify, VS Code, Slack, Chrome)
Good
Key interactive elements exposed; tree is shallower than native
Cocoa (macOS native)
Good
Standard controls fully exposed
Custom-drawn / OpenGL / DirectX
Poor
Minimal or no accessibility tree — games, CAD, etc.
Tip: Run curl "localhost:7878/windows/{pid}/find?interactive=true" to see what’s available for any app.
Client SDKs
Official wrappers for the REST API, with token support (OCULOS_TOKEN), waits, screenshots, batches, request timeouts and typed errors (OculOSError with code / status). Install from source (PyPI/npm packages coming soon):
Python
cd sdk/python
pip install .
from oculos import OculOS
client = OculOS() # token from $OCULOS_TOKEN if set
windows = client.list_windows()
[ok] = client.wait_for(pid=pid, q="OK", type="Button", timeout_ms=5000)
client.click(ok["oculos_id"])
client.set_text(element_id, "hello world")
client.wait_for(pid=pid, q="Saving", until="gone")
oculos [OPTIONS]
-b, --bind <ADDR> Bind address [default: 127.0.0.1:7878]
--token <TOKEN> Require this API token [env: OCULOS_TOKEN]
(auto-generated when binding to a non-loopback address)
--allow-origin <ORIGIN> Allow a browser origin to call the API (enables CORS for it; repeatable)
--allow-host <HOST> Accept an extra Host header name (repeatable)
--static-dir <DIR> Serve the dashboard from DIR instead of the embedded copy (development)
--log <LEVEL> Log level: trace/debug/info/warn/error [default: info] (logs go to stderr)
--mcp Run as MCP server over stdin/stdout
-h, --help Print help
-V, --version Print version
How OculOS Differs
OculOS
Vision agents
Screen coordinate tools
Browser-only tools
Approach
OS accessibility tree
Screenshots + LLM
Pixel positions
DOM / a11y tree
Scope
Any desktop app
Any (with latency)
Any (fragile)
Browser only
Speed
Instant
Seconds
Instant
Instant
Deterministic
✅
❌
✅
✅
GPU required
❌
✅
❌
❌
Cloud required
❌
Usually
❌
❌
Semantic
✅ Labels + types
Varies
❌ Coordinates
✅
Everything Built So Far
Core
Windows UIA backend (full — Win32, WPF, Electron, Qt)
See docs/ROADMAP.md for the prioritised roadmap (compact text snapshots, post-action diffs, coordinate actions, event-driven waits, selectors, vision/OCR fallback, safety layer…).
macOS element highlighting (native overlay)
Python & TypeScript client SDKs
Batch operations (multiple interactions per request)
Conditional waits (/wait endpoint with timeout, until=gone, by PID or HWND)
评论