ghosthand
Automates Apple devices and apps: booting simulators, listing and targeting connected iPhones, interacting with installed apps (e.g. Settings) to change device state such as enabling dark mode, and capturing screenshots of the running screen.
Drives an iOS Simulator or a real iPhone the way a person would: reads the accessibility tree, takes screenshots, taps, swipes, types, presses Home, launches/terminates apps and opens URLs or deep links, optionally running an autonomous agent that completes natural-language tasks on the device.
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., "@ghosthand open Settings on the simulator and turn on dark mode"
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.
ghosthand
Natural-language automation for iOS: an agent (Claude) drives an iOS Simulator or a real iPhone the way a person would.
Runner/(Swift): an XCUITest app that runs on the device and serves a small HTTP API: accessibility tree, screenshots, taps, swipes, typing, buttons, app launching.ghosthand/(Python): drives simulators (simctl) and iPhones (devicectl), starts and talks to the runner, exposes everything as an MCP server, and includes an autonomous agent (Claude via the Anthropic API) and a web console.packages/ghosthand-client/: zero-dependency Python SDK to drive the console from pytest or CI.
Requirements
macOS with Xcode (tested with Xcode 27.1) and an iOS Simulator runtime (
xcodebuild -downloadPlatform iOS)uv (
brew install uv)
Related MCP server: ios-agent-driver
Getting started
uv sync
uv run ghosthand boot "iPhone 17" # boot a simulator
uv run ghosthand runner start # build (first time) and start the runner
uv run ghosthand tree # visible elements, numbered
uv run ghosthand tap -i 4 # tap element [4]
uv run ghosthand launch com.apple.Preferences
uv run ghosthand swipe up
uv run ghosthand type "hello"
uv run ghosthand screenshot screen.png
uv run ghosthand doctorDefault target: the only booted simulator, else the only reachable iPhone. Otherwise pick one with --device "iPhone 17" or GHOSTHAND_DEVICE.
The runner is rebuilt automatically when its Swift sources change. Its logs are in ~/.ghosthand/runners/.
On a real iPhone
One-time setup:
Xcode > Settings > Accounts: add your Apple ID. A free account works ("Personal Team").
iPhone: connect it over USB and accept "Trust This Computer". Afterwards, Wi-Fi works too.
Developer Mode: Settings > Privacy & Security > Developer Mode (requires a restart).
Auto-Lock: Settings > Display & Brightness > Auto-Lock > Never while automating. A locked iPhone cannot be driven; the agent stops with a clear message.
uv run ghosthand devices # the iPhone must be "reachable"
uv run ghosthand runner start -d "My iPhone" # builds, signs, installs and starts the runnerOn the very first launch, iOS refuses apps from an unknown developer: on the iPhone, go to Settings > General > VPN & Device Management > Apple Development: > Trust, then start again. The CLI prints these instructions when it detects the problem.
How it works:
the runner is signed with your team (set
GHOSTHAND_TEAMto force one) and bundle IDs unique to your account;with a free account, signing expires after 7 days: the runner is rebuilt automatically after 6 days;
the Mac reaches the runner through the CoreDevice tunnel that Xcode opens to the iPhone (USB or Wi-Fi). Its IPv6 address is resolved once at startup, because each mDNS lookup of
<udid>.coredevice.localtakes several seconds;screenshots are downscaled to point size and JPEG-encoded on the iPhone: about 30 KB instead of 1.7 MB.
With Claude Code (MCP)
uv run ghosthand mcp install # = claude mcp add --scope user ghosthand -- uv --directory <here> run ghosthand mcp serveRestart Claude Code, then ask for example: "On the simulator, open Settings and turn on dark mode." The runner starts on the first call. No API key is needed: Claude Code does the thinking.
Tool | Purpose |
| numbered element list + annotated screenshot (scaled to points) |
| tap by |
| a direction, or start and end points |
| type into the focused field |
| Home button |
| open / quit an app |
| URL or deep link |
| installed apps |
| list targets / get one ready (and start its runner) |
| hand a whole task to the built-in agent |
Each action returns the refreshed element list, saving a round trip.
An index always refers to the latest observation returned to the model.
Autonomous agent
export ANTHROPIC_API_KEY=sk-ant-... # or `ant auth login`
uv run ghosthand run "Turn on dark mode in Settings"
uv run ghosthand traces # recent runsEach step is one independent request to the model: the task, a text journal of previous steps and the current
screen (numbered elements + annotated screenshot). The model answers with exactly one action
(tap_element, tap_point, long_press_element, swipe, swipe_points, type_text, press_home,
launch_app, open_url, wait or finish) and a one-sentence reason.
Old screenshots are never resent: only the text journal grows, so the cost per step stays flat.
An action with no visible effect is reported to the model ("the screen did not change"), and so are errors.
Stops on
finish, the step budget (--max-steps, default 30), a model refusal, or 3 answers without an action.Model:
claude-opus-5-5atloweffort by default (--model,--effort, orGHOSTHAND_MODEL/GHOSTHAND_EFFORT). Server-side refusal fallbacks (fallbacks: "default") are enabled.
Reliable mode
uv run ghosthand run "Turn on dark mode in Settings" --mode reliablePlan: before acting, one request produces 2 to 6 checkpoints, each with the evidence expected on screen.
Verification: the agent claims a checkpoint with
checkpoint_done; an independent reviewer, which took no action and sees only the screen and the journal, confirms or rejects it.finish(success=true)is reviewed the same way: after two rejections the task fails instead of reporting a false success.Replanning:
replanwhen the situation no longer matches the plan.Slower and more expensive than
fast(one extra request per checkpoint), but a reported success is a seen success.
There is no risk guard: the prompts tell the model not to complete purchases, deletions or messages unless the task asks for them, and nothing else enforces it. Supervise runs on a real iPhone.
Target check (before every tap)
The model decides from a screen captured seconds earlier; animations, loading or scrolling can move or replace its target in the meantime. Right before tapping, the screen is read again:
an element tapped by index is found again by type, label and identifier: tapped where it is now if it moved, not tapped at all (and reported to the model) if it is gone;
a point tap aimed at a labeled element is cancelled if a different element is now under that point.
The same check applies to ios_tap in the MCP server.
Traces: ~/.ghosthand/traces/<id>/ holds run.json (task, mode, plan, status, summary, duration, tokens),
steps.jsonl (one line per step, with checks) and step-NNN.jpg (the screen the model saw).
From an MCP client: ios_run_task starts the agent in the background, ios_task_status follows it and
ios_task_cancel stops it. The API key must then be in the MCP server's environment
(claude mcp add … -e ANTHROPIC_API_KEY=…).
Web console
uv run ghosthand ui # http://localhost:8000, opens the browserLive screen of the simulator or iPhone: click to tap, hold for a long press, drag to swipe; Home, typing, opening an app or a URL; starting and stopping the runner.
Agent: run a task (fast or reliable mode, step budget) and follow the plan and steps live.
Traces: replay any run step by step (screen the agent saw, reason, outcome, checks, plan); ← → keys to navigate.
Elements: the numbered list exactly as the model sees it.
The console listens on 127.0.0.1 only and refuses requests from other hosts or other sites (DNS rebinding, CSRF),
since it controls your phone.
API (used by the page and the SDK): GET /api/devices, POST /api/devices/{udid}/runner,
GET /api/devices/{udid}/screen.jpg, GET /api/devices/{udid}/elements, POST /api/devices/{udid}/action,
GET|POST /api/tasks, GET /api/tasks/{id}, POST /api/tasks/{id}/cancel,
GET /api/traces, GET /api/traces/{id}, GET /api/traces/{id}/step-NNN.jpg.
Client SDK (tests, CI)
from ghosthand_client import GhosthandClient
def test_dark_mode():
result = GhosthandClient().run("Turn on dark mode in Settings", mode="reliable")
assert result.succeeded, result.summarySee packages/ghosthand-client/README.md.
Tests
uv run pytest # no device or API key needed: fake model and fake runnerRunner API
Every request must send Authorization: Bearer <token>. runner start creates the token and stores it in ~/.ghosthand/runners/. On the simulator the listener also accepts only connections from this Mac; an iPhone is reached through the CoreDevice tunnel, with the same token.
Route | Purpose |
| status, current app, whether the iPhone is locked |
| size in points, scale, orientation |
| full-resolution PNG, or a point-sized JPEG |
| raw accessibility tree of the foreground app (+ system alerts) |
| tap or long press, in points |
| swipe |
| type into the focused field |
|
|
| open an app |
| quit an app |
| state of each app |
| installed apps, used to find the foreground one (sent at startup) |
| open a URL or deep link |
| stop the runner |
Editing the Xcode project
Runner/GhosthandRunner.xcodeproj is generated from Runner/project.yml with XcodeGen: cd Runner && xcodegen generate.
License
MIT, see LICENSE.
Available Tools
14 toolsios_appsBRead-only
List installed apps: bundle ID and display name.
Inputs: device.
ios_bootA
Get a target ready: boot a simulator (name like "iPhone 17", or UDID) or pick an iPhone, then start the automation runner on it.
The first start compiles the runner (a minute or two). On an iPhone it must be unlocked, and the very first time the user must trust the developer certificate in Settings > General > VPN & Device Management.
Inputs: device (required).
ios_devicesARead-only
List simulators and real iPhones, and which ones are ready (booted / reachable).
Inputs: no named parameters.
ios_launchA
Open an app by bundle ID (see ios_apps). relaunch=True restarts it from scratch.
Inputs: bundle_id (required), device, relaunch.
ios_observeARead-only
See the screen: numbered list of visible elements, plus a screenshot.
Args: screenshot: Include a screenshot (scaled to points, so pixel = tap coordinate). annotate: Draw element indexes on the screenshot. device: Simulator name or UDID; defaults to the only booted one.
Inputs: device, annotate, screenshot.
ios_open_urlC
Open a URL or deep link (https://…, maps://…, app schemes).
Inputs: url (required), device.
ios_pressC
Press a hardware button. "home" goes to the home screen.
Inputs: button (required), device.
ios_run_taskA
Hand a whole task to the built-in agent (Claude via the Anthropic API) instead of driving step by step.
It runs in the background; poll with ios_task_status. Needs ANTHROPIC_API_KEY (or ant auth login)
in the server's environment.
Args: task: What to do, in plain language, e.g. "Turn on dark mode in Settings". max_steps: Step budget before giving up. wait_seconds: Block up to this long for the result (0 returns immediately). mode: "fast" acts directly; "reliable" plans checkpoints and has each one verified (slower, surer). device: Simulator name or UDID.
Inputs: task (required), mode, device, max_steps, +1 more.
ios_swipeA
Swipe: either a direction from the screen center, or explicit points.
The direction is the finger's: "up" scrolls content down (reveals what is below). To go back in most apps, swipe from x=2 to x=250 at mid-height.
Args: direction: up, down, left or right. from_x: Start x in points (with from_y, to_x, to_y instead of direction). from_y: Start y in points. to_x: End x in points. to_y: End y in points. duration: Gesture duration in seconds; shorter is a faster fling. device: Simulator name or UDID.
Inputs: to_x, to_y, device, from_x, +3 more.
ios_tapA
Tap an element by [index] from the latest observation, or a point (x, y) in points.
Args: index: Element index from the latest ios_observe or action result. x: Horizontal position in points (with y, instead of index). y: Vertical position in points. hold_seconds: Press duration for a long press (e.g. 1.0); 0 for a normal tap. device: Simulator name or UDID.
Inputs: x, y, index, device, +1 more.
ios_task_cancelB
Stop an agent task after its current step.
Inputs: task_id (required).
ios_task_statusARead-only
Status and latest steps of an agent task; without task_id, a list of all tasks.
Inputs: task_id.
ios_terminateC
Quit an app.
Inputs: bundle_id (required), device.
ios_typeA
Type text into the field that has keyboard focus (tap the field first). Use "\n" for Return.
Inputs: text (required), device.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool maps to a distinct action in the observation→interaction loop (observe, tap, swipe, type, press), and the agent-mode tools (ios_run_task / ios_task_status / ios_task_cancel) are clearly separated from manual driving. The only soft overlaps are ios_launch vs ios_open_url (an app scheme URL could effectively launch an app) and ios_press vs dedicated navigation, which an agent could occasionally misselect.
All 14 tools use a uniform ios_ prefix with snake_case, giving a highly predictable namespace. Most are verb or verb_noun (ios_boot, ios_tap, ios_open_url, ios_run_task), with a few noun-only list/query names (ios_devices, ios_apps, ios_task_status) that follow a conventional read-only pattern but are a minor deviation.
14 tools sits squarely in the well-scoped range and every tool maps to a needed primitive: discovery, boot, observation, four input gestures, app lifecycle, URL handling, plus an optional agent layer with status/cancel. Nothing looks redundant or padded for the scope of iOS device automation.
The core loop is fully covered end-to-end: list devices, boot, observe screen (elements + screenshot), interact (tap/swipe/type/press), and app lifecycle (apps, launch, terminate, open_url), plus an agent mode with status and cancellation. Minor gaps remain—no install/uninstall of apps, no orientation/rotation, no explicit wait/sleep or clipboard/keyboard-dismiss primitive—but agents can work around these with existing gestures.
Maintenance
Related MCP Connectors
Give your Grok Bot a phone: an MCP server to see and use your phone. Also works with Claude.
Give an AI agent an iPhone to see, tap and type on over MCP. Free early access (Simulator).
Let your AI agent control real iPhones: screenshots, tap, swipe, type and open apps.
Cloud iPhone Simulators for AI agents: build the Xcode project, read the screen, tap by label, test.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn MCP server that lets AI agents control iOS and Android devices (tap, scroll, type, take screenshots, read UI trees, and run code). Works with multiple devices at the same time.100 npm54MIT
- AlicenseAqualityNot gradedmaintenanceAn MCP server that lets an AI agent drive the iOS Simulator in a loop, enabling tapping, typing, swiping, reading the screen via the accessibility tree, and verifying app state.14MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that drives the iOS Simulator via accessibility-tree snapshots with stable element refs, enabling LLMs to interactively find, tap, type, and inspect UI elements at sub-200ms latency.39 npmMIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that lets LLMs drive a real iPhone through macOS iPhone Mirroring, with tools for screen capture, OCR, taps, typing, and Xcode build/test/install automation.9MIT