Hands
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Hands take a screenshot of my desktop"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🖐️ Hands
A macOS computer-use MCP server for autonomous AI agents.
Give an LLM eyes, a mouse, and a keyboard — with a real security model in between.
Quick Start • Tools • Security Model • Plugins • Docs
Most "computer use" demos give a model raw pixel coordinates and hope for the best. Hands is built differently: every action goes through a typed 7-phase dispatch pipeline — validate → rate-limit → authorize → lock → execute-with-retry → observe → audit — so that giving an agent control of your desktop doesn't mean giving up any of your say in what it's allowed to do.
import anyio
from hands import Container, HandsConfig
config = HandsConfig()
config.driver = "fake" # no macOS needed — great for a first look
container = Container.build(config)
async def main():
shot = await container.dispatcher.dispatch("screenshot", {})
print(shot["ok"], shot["bounds_pt"])
anyio.run(main)Why Hands
A real policy engine, not a rubber stamp. Rule-based profiles (
strict/default/trusted), an app deny-list (Passwords, 1Password, System Settings — blocked out of the box), secret-pattern detection on typed text, per-tool confirmation, and a sliding-window rate limiter. See Security Model.Tamper-evident audit log. Every action is appended to a SHA-256 hash-chained JSONL log; deleting or editing any line downstream breaks the chain, and
hands audit verifyproves it.Redaction by construction. Clipboard content and typed text never enter application state, logs, audit records, or metrics — only their length and a SHA-256 hash ever do.
A fake driver, not just mocks.
FakeDriveris a full in-memory virtual desktop (windows, apps, clipboard, AX tree, OCR boxes) that every tool runs against identically to the real macOS driver. The entire test suite — 215 tests — runs on Linux CI with zero macOS hardware, and it's the fastest way to try Hands out or build a plugin without touching your real screen.Perception, not just action. OCR-grounded text search (
find_text), an accessibility-tree fallback (get_ui_tree), and averify/waitcondition language so an agent can confirm an action worked instead of flying blind.A kill switch that actually works.
touch ~/.hands/KILLhalts the server immediately — checked before every single dispatch, including mid-way through a batchedexecute_sequence.Extensible without forking. Third-party plugins register tools through the exact same
ToolSpecmachinery as the 22 built-ins, loaded via Python entry points; a plugin that raises during setup is logged and skipped, not a server crash. (Plugins run in-process with access to the same services — this is crash isolation, not a security sandbox; don't load untrusted plugin code any more than you would an untrusted import.)
Related MCP server: macos-control-mcp
Requirements
macOS 13+ (Ventura or later) for real desktop control
Python 3.12+
Screen Recording and Accessibility permissions (System Settings → Privacy & Security) —
hands permissionstells you exactly what's missing
You can install and explore the library on any OS using the fake driver
(HANDS_DRIVER=fake) — only real desktop control requires macOS.
Installation
pip install hands-mcpWith the macOS driver and Vision OCR (needed for real desktop control):
pip install "hands-mcp[macos]"The import name is still hands regardless of the install name above:
import hands
print(hands.__version__)For development:
git clone https://github.com/yuvitbatra/hands-mcp.git
cd hands-mcp
uv sync --group dev
uv run pytest -qQuick Start
As an MCP server (for AI agents)
Add to your MCP client configuration (e.g. Claude Desktop's
claude_desktop_config.json):
{
"mcpServers": {
"hands": {
"command": "hands",
"args": ["serve"]
}
}
}Or run it directly over stdio:
hands serveAs a Python library
import anyio
from hands import Container, HandsConfig
# The fake driver is a full in-memory virtual desktop — no macOS needed.
config = HandsConfig()
config.driver = "fake"
container = Container.build(config)
async def main():
res = await container.dispatcher.dispatch("screenshot", {})
print(res["ok"]) # True
anyio.run(main)# Or run the full MCP server over stdio from your own process:
import anyio
from hands import run_server, load_config
anyio.run(run_server, load_config())Diagnostics
hands doctor # resolved config, driver, displays, registered tools
hands doctor --metrics # ...plus a metrics snapshot (counters + latency histograms)
hands permissions # TCC grant status (Screen Recording, Accessibility) + fix links
hands audit verify # verify the audit log's hash chain end to endTools (22)
Full argument/return reference: docs/TOOLS.md.
Tool | Policy | Description |
| read | Capture the screen (or a region); cached by default |
| read | Session state: cursor, displays, action history, dirty flag |
| read | OCR search returning bounding boxes for matching text |
| read | Accessibility tree for an app (roles, labels, frames) |
| read | Poll until a condition is met: text present, window state, duration |
| read | Check an expected outcome after acting; returns evidence |
| act | Move the cursor |
| act | Click at a point (single, double, or triple) |
| act | Click-drag along a path |
| act | Scroll at a point |
| act | Type text into the focused element (refused during secure input) |
| act | Press a key or chord (e.g. |
| sensitive | Read the current clipboard (text or image) |
| act | Set the clipboard to text or a PNG image |
| act | Paste via clipboard + Cmd+V, restoring the clipboard after |
| read | List windows, optionally filtered by app |
| act | Bring a window to front (stale refs re-resolve by fuzzy title) |
| act → sensitive on | Move, resize, minimize, maximize, or close a window |
| act | Launch an app by bundle ID or name, waiting for its window |
| act → sensitive on | Quit an app gracefully, or force-terminate |
| read | List running apps and the frontmost one |
| act | Batch up to 20 pre-decided acting steps in one round trip, gated by guard conditions |
Security Model
An agent that can move your mouse and type on your behalf is a genuinely different risk profile from a chatbot, so the policy layer isn't an afterthought — it's a fixed phase of every dispatch, before the tool ever runs:
validate args → rate limit → authorize (PermissionEngine) → acquire action lock
→ execute with retry → record state/screen-dirty → audit + metricsProfiles (HANDS_SECURITY__PROFILE, default default):
Profile |
|
|
| requires confirmation | requires confirmation |
| allowed | requires confirmation |
| allowed | allowed |
Evaluation order for every action: (1) is the frontmost app on the
deny-list? → denied outright, even under trusted. (2) does a configured
rule match? → first match wins. (3) does typed/pasted text match a
secret_patterns regex? → confirmation required regardless of profile. (4)
fall through to the profile's class default above.
App deny-list (HANDS_SECURITY__DENY_APPS, on by default): blocks
acting tools — reads still work — against com.apple.systempreferences*,
com.apple.Passwords*, com.apple.keychainaccess, 1Password (both bundle
id families). This applies uniformly whether the tool is called directly or
from inside execute_sequence.
Rate limiting (HANDS_SECURITY__MAX_ACTIONS_PER_S, default 10.0): a
1-second sliding window over acting tools; bursts past the limit are denied,
not queued.
Secure input refusal: keyboard_type and clipboard_get are refused
outright while macOS reports secure text entry active (a password field has
focus) — independent of profile.
Confirmation hooks: under dialog mode (default, macOS only) a
denied-by-default sensitive action pops a real confirmation dialog via
osascript; under deny mode (or off-macOS) it's auto-denied. Plug in your
own hook by subclassing the PermissionEngine's confirm callback if you need
a different UX (e.g. routing through your agent framework's own approval
flow).
Redaction invariant: clipboard content and typed text are used only
in-memory for policy matching (e.g. secret-pattern checks) — they never
reach state, the audit log, or metrics in raw form. Only length and a
SHA-256 hash ever leave those boundaries.
Kill switch: touch ~/.hands/KILL halts the server immediately —
checked at the top of every dispatch, including mid-sequence inside
execute_sequence. Remove the file to resume.
Audit log: every action is appended to ~/.hands/audit.jsonl as
{"event", "prev_hash", "hash"}, where hash = sha256(prev_hash + canonical_json(event)). Tampering with or deleting any line downstream
breaks the chain — verify with hands audit verify.
Configuration
All settings can be overridden via HANDS_* environment variables (nested
fields use __, e.g. HANDS_SECURITY__PROFILE). Full schema:
src/hands/config.py.
Variable | Default | Description |
|
|
|
|
|
|
| see above | JSON list of bundle-id globs blocked for acting tools |
|
| JSON list of regexes that force confirmation on typed/pasted text |
|
| Sliding-window rate limit for acting tools |
|
|
|
| (all allowed) | JSON list of allowed plugin entry-point names |
|
| Max screenshot dimension |
|
| JPEG quality (0–100) |
|
| Delay between mouse down and up |
|
| Characters per typing chunk |
|
| Depth-first-traversal node cap for |
Plugin System
Hands supports external plugins that register custom tools through the exact
same ToolSpec machinery as the built-ins — no side door around the
dispatcher, so plugin tools get the same policy, retry, and audit treatment.
from hands.plugins.api import HandsPlugin, PluginContext
class MyPlugin:
name = "my-plugin"
version = "1.0.0"
def setup(self, ctx: PluginContext) -> None:
from pydantic import BaseModel
from hands.registry import ToolSpec
from hands.retry import RetryPolicy
class Args(BaseModel, extra="forbid"):
query: str
async def my_tool(args: Args, ctx_) -> dict:
return {"result": f"searched for {args.query}"}
ctx.registry.register(ToolSpec(
"my_search", "Custom search tool",
Args, my_tool, "read", RetryPolicy.read(), idempotent=True))
def teardown(self) -> None:
passRegister it via the hands.plugins entry-point group in your own package's
pyproject.toml:
[project.entry-points."hands.plugins"]
my-plugin = "my_package.plugin:MyPlugin"Plugins load at server startup. A plugin that raises in setup is logged
and skipped — it never takes the server down. Restrict which plugins may
load with an allowlist:
HANDS_SECURITY__PLUGIN_ALLOWLIST='["my-plugin"]' hands serveSee docs/plugins.md for the full plugin author's guide,
and src/hands/plugins/api.py for the stable
import surface (semver-guarded — additive-only within a major version).
Testing
uv run pytest -q # 215 tests, any OS, ~2s
HANDS_CONTRACT_MACOS=1 uv run pytest tests/contract -q # real macOS driver (needs TCC grants)
HANDS_E2E_MACOS=1 uv run pytest tests/e2e -q # full stack vs. a real Tk fixture app
uv run pytest tests/perf -m perf --benchmark-only -q # latency budgets
uv run pytest tests/stress -m stress -q # 10k-action soak + concurrencyThe contract/e2e suites are opt-in because they genuinely move your mouse
and open/close real apps — don't run them unattended. See
CONTRIBUTING.md for the full development workflow.
Architecture
types, errors, config, retry
↓
driver/base (Protocol) ← fake.py (tests/CI) + macos.py (real hardware)
↓
services/ (screenshot, ocr, mouse, keyboard, clipboard, windows, apps,
waiter, verification)
↓
state, permissions (PermissionEngine), audit (hash-chained), metrics, registry
↓
dispatcher (7-phase pipeline: validate → rate-limit → authorize → lock →
execute-with-retry → observe → audit)
↓
tools/ (22 MCP tools)
↓
container → server (MCP stdio transport) → cliFull design rationale: docs/DESIGN.md.
Contributing
Contributions welcome — see CONTRIBUTING.md for the
development setup, test-driven workflow, and what a good PR looks like.
License
Available Tools
22 toolsapp_closeA
Quit an app gracefully; force=true force-terminates (sensitive, needs confirmation under the default policy).
Inputs: app (required), force.
app_listA
List running apps and the frontmost one.
Inputs: no named parameters.
app_openA
Launch an app by bundle id (preferred) or name; activates it if already running. wait_for_window waits for its first window.
Inputs: app (required), timeout_ms, wait_for_window.
clipboard_getA
Read the clipboard (sensitive: may require user confirmation). Refused while a password field has focus.
Inputs: format.
clipboard_pasteA
Paste text into the focused app via clipboard + Cmd+V, then restore the previous clipboard. Preferred over keyboard_type for long text.
Inputs: text (required), restore.
clipboard_setA
Set the clipboard to text or a base64 PNG.
Inputs: text, image_b64.
execute_sequenceA
Run up to 20 PRE-DECIDED acting steps in one call (click, type, press...), each optionally gated by a guard condition (same schema as wait). A failed guard halts the sequence and returns evidence. Use only when you already know every step; this is a macro, not a planner.
Inputs: steps (required), stop_on_failure, screenshot_after.
find_textA
OCR the screen (or a region, in points) and return boxes matching text. Each match has a center you can pass directly to mouse_click. Re-observe rather than act when confidence < 0.5. By default this matches fuzzily (case-insensitive substring either direction, or a similarity ratio >= 0.8); pass fuzzy=false for exact substring matching. This differs from wait's text_present condition and verify's text_present expectation, which always require an exact substring match.
Inputs: text (required), fuzzy, region.
get_stateB
Re-orientation: cursor position, displays, last screenshot metadata, kill-switch status, and recent action history.
Inputs: include_history.
get_ui_treeA
Accessibility tree for an app (frontmost if omitted): roles, titles, values, clickable regions in points. Ground truth where apps expose it; use find_text where they don't.
Inputs: app, max_depth.
keyboard_typeA
Type text into the focused element using layout-independent unicode injection. Click the target field first.
Inputs: text (required), chunk_delay_ms.
key_pressA
Press a key or shortcut chord, e.g. 'Return', 'cmd+s', 'cmd+shift+p', 'F5'. Use keyboard_type for regular text.
Inputs: chord (required), repeat.
mouse_clickA
Click at (x, y), or at the current cursor if omitted. Coordinates are logical points, origin top-left of the main display. Compute them from the screenshot tool's bounds_pt and px_per_pt metadata. After clicking, take a screenshot to verify the result.
Inputs: x, y, clamp, count, +3 more.
mouse_dragA
Press, drag along path, release. Coordinates are logical points, origin top-left of the main display. Compute them from the screenshot tool's bounds_pt and px_per_pt metadata.
Inputs: path (required), button, duration_ms, require_fresh_screenshot.
mouse_moveA
Move the mouse cursor. Coordinates are logical points, origin top-left of the main display. Compute them from the screenshot tool's bounds_pt and px_per_pt metadata.
Inputs: x (required), y (required), clamp, duration_ms, +1 more.
mouse_scrollA
Scroll at (x, y) (moves there first) or at the current cursor. Positive dy scrolls up, negative down, in wheel ticks unless pixels=true.
Inputs: x, y, dx, dy, +1 more.
screenshotA
Capture the screen (or a region, in points). The response includes bounds_pt and px_per_pt: point = bounds_pt.origin + pixel / px_per_pt. Take a screenshot before any coordinate action.
Inputs: fresh, format, region, max_dim.
verifyA
Check an expected outcome after acting. expect = {type: 'text_present'|'text_absent'|'region_changed'|'region_unchanged'|'cursor_at'|'window_present'|'window_gone'|'clipboard_contains'|'all_of'|'any_of', ...params, children?}. region_changed/unchanged need baseline_screenshot_id from an earlier screenshot response. text_present/text_absent require an exact (case-insensitive) substring match, not fuzzy. clipboard_contains never returns clipboard content, only matched/clipboard_len.
Inputs: expect (required), baseline_screenshot_id.
waitA
Wait for a condition: {type: 'duration', ms} | {type: 'text_present', text, region?} | {type: 'screen_stable', quiet_ms}. Timeout returns met=false (an answer, not an error). text_present requires an exact (case-insensitive) substring match, not fuzzy matching.
Inputs: condition, timeout_ms, duration_ms.
window_focusA
Focus (raise) a window by window_ref, or by app and/or title_match. Stale refs are re-resolved by pid + fuzzy title.
Inputs: app, window_ref, title_match.
window_listA
List windows (optionally filtered by app bundle id or name). Returns window_ref handles for window_focus/window_manage.
Inputs: app, on_screen_only.
window_manageA
move/resize/minimize/unminimize/maximize/close a window. close may trigger 'Don't Save' dialogs and needs confirmation under the default policy.
Inputs: action (required), window_ref (required), bounds.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 22 tools
Most tools target distinct resource-action pairs (mouse, keyboard, window, app, clipboard). The observation/verification trio (find_text, wait, verify) has overlapping text-matching concepts, but descriptions clearly delineate fuzzy search vs exact wait vs assertion, so agents can select correctly.
The set uses a consistent underscore style but mixes noun-verb (window_list, mouse_move) with verb-noun (get_state, find_text) and bare verbs/nouns (wait, screenshot). Within each domain (mouse, clipboard, window, app) the pattern is consistent, so it's predictable overall.
22 tools is on the high end, but the server's scope is broad GUI automation (input, observation, window management, clipboard, verification), so each tool covers a distinct capability and the count is justifiable.
The tool surface covers the full interactive loop: observe (screenshot, get_ui_tree, find_text), act (mouse, keyboard, clipboard), manage windows/apps, and verify outcomes (wait, verify). No obvious dead ends; sequences allow batching.
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
An MCP gateway for teams deploying AI tools at scale to employee-facing and headless agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server for macOS that enables AI agents to control the desktop GUI through keyboard input, mouse actions, and screen captures. It provides stable low-level primitives for UI automation and agent-driven desktop workflows.MIT
- AlicenseBqualityDmaintenanceMCP server that enables AI to fully control macOS — mouse, keyboard, terminal, screenshots, window management, UI element detection, and provides AI-optimized information reporting.36MIT
- AlicenseNot gradedqualityBmaintenanceAn MCP server that gives AI agents real OS-level control of macOS, enabling them to click real buttons, type real keys, and observe rendered screens just like a human would.1MIT
- FlicenseNot gradedqualityDmaintenanceEnterprise-grade macOS MCP server that gives AI agents eyes, hands, and a terminal, enabling screen capture, mouse/keyboard control, shell commands, and file operations.-