iphone-cli
This MCP server lets an AI agent read and control a real iPhone through accessibility and simulated input.
Connect to a paired iPhone by IP when automatic discovery fails, verifying and saving the address.
Read the current screen as structured accessibility elements; find elements by selector; optionally include off-screen elements, app-only elements, full identifiers, or cached readings.
Tap elements or coordinates, including long and double taps; swipe; pinch/rotate; and scroll until a target element appears.
Type text via clipboard, press keys, and press hardware buttons.
Launch apps, list installed apps, take PNG screenshots, and control Do Not Disturb.
Run multi-step batches, inline JavaScript, and saved scripts for loops, conditions, field/list reading, and longer UI flows.
Check phone readiness with doctor diagnostics and optionally fix Wi-Fi flags or skip the touch test.
Respect safety outcomes such as unknown/not_sent so agents avoid retrying uncertain taps or inputs.
Connects directly to Apple developer device services for accessibility and HID input, allowing control of a paired iPhone without Xcode, WebDriverAgent, or an installed app.
Enables AI agents to read the accessibility tree and operate apps on a real iPhone running iOS 27 or later, including taps, swipes, text input, and multi-step scripts over USB or Wi-Fi.
iphone-cli (iph)
Let AI agents read and operate any app on a real iPhone — straight from your terminal.
No Xcode. No WebDriverAgent. No app installed on the phone. 100% Rust.
Direct Apple developer services — connects over USB or Wi-Fi to the same accessibility and HID services Xcode uses, with no signing or test runner
Accessibility tree, not screenshots — reads structured UI elements cleanly, and runs multi-step flows in one call with a built-in QuickJS engine (
iph script)Agent-ready — CLI + MCP server (
iph mcp) + safety-first outcomes (done/not_sent/unknown)Single native binary (macOS & Windows) — no Python, Node.js, or Appium runtime; install one binary and target a real iPhone on iOS 27+
Website · llms.txt · crates.io · 한국어

Built on the principle of Poki (a new implementation from its documented behaviour and device experiments, with no Poki code). Device communication relies on idevice (MIT).
$ iph read --human
Settings 430x932 15 elements
application "Settings" @0,0 430x932
header "Settings" @20,119.3 53.7x37
switch "Airplane Mode" = "0" @20,489.3 390x49.3
button "Wi-Fi, HomeNet" @20,538.7 390x49.3
button "General" @20,700 390x49.3
…
$ iph tap "General"
{"ok":true,"outcome":"done","elapsed_ms":1752,"sent":true,"verified":true,"screen_changed":true,…}Scope
Host | macOS, Windows 10/11 (x64) |
Device | A real iPhone, iOS 27 or later (verified on one iPhone 15 Pro Max with iOS 27.0.1 only, Korean interface). Touch and text input go through the phone's screen-sharing service ( |
Connection | USB or the same LAN (the computer may use Ethernet; verified over USB and Wi-Fi on Windows) |
Out of scope | Simulators, Android, Linux hosts, landscape |
On Windows, doctor, reading, touch and scripts were checked with one iPhone19,4 on iOS 27.2 over USB.
Related MCP server: mcp-baepsae
Comparison with alternatives
Capability |
| iPhone Mirroring + OCR tools | Appium / WebDriverAgent |
|
Native Accessibility Tree | Yes (structured JSON) | No (screenshots / Vision OCR) | Yes | Partial (WDA on real iOS) |
No Xcode / No code signing | Yes | Yes | No (requires Xcode & signing) | No (WDA signing on real iOS) |
No app installed on iPhone | Yes | Yes | No (installs WDA runner) | No (installs WDA on real iOS) |
Windows host support | Yes (macOS & Windows) | No (macOS 15+ only) | Limited (needs macOS to build WDA) | Limited on real iOS |
Works in the EU | Yes (no Mirroring needed) | No (Mirroring unavailable) | Yes | Yes |
Unicode / clipboard text input | Yes (paste + restore) | Simulated keystrokes | Yes | Varies |
Built-in multi-step scripting | Yes (embedded QuickJS) | External / per-turn calls | External SDK | Per-turn MCP calls |
Safety outcome contract |
| Varies | Standard exceptions | Standard tool errors |
Target scope | Real iPhone, iOS 27+ | Real iPhone, iOS 18+ (macOS 15+) | Real iOS & Simulators | Simulators, Android, WDA iOS |
Choose
iphone-cli(iph) when you want Claude Code, Codex, or another AI agent to operate a real iPhone (iOS 27+) via the accessibility tree without Xcode or WebDriverAgent — including on Windows or in the EU.Choose an iPhone Mirroring + OCR tool if your phone runs iOS 18–26 on macOS 15+ outside the EU.
Choose Appium / WebDriverAgent or
mobile-mcpif you need iOS Simulators, Android, or iOS 26 and earlier with an element tree.
Install
Neither Rust nor Xcode is needed. On a Mac it is one line in Terminal (it uses only tools macOS ships: curl, tar, shasum).
curl -fsSL https://raw.githubusercontent.com/HyunSeob/iphone-cli/main/install.sh | sh
iph setup # walks through what the phone needsIt downloads the universal binary (Apple silicon and Intel) from the latest release, checks its checksum and puts it at ~/.local/bin/iph. IPH_INSTALL_DIR picks another folder and IPH_VERSION=v0.1.0 a specific version. On Windows, download iph-windows-x86_64.zip from the releases and put iph.exe in a folder on your PATH.
Mac: plug the phone in and tap Trust on it; that pairs it.
Windows: Apple's device service must be installed: the Apple Devices app from the Microsoft Store, or just the service with
winget install Apple.AppleMobileDeviceSupport. Then plug the phone in and tap Trust.Developer disk image: when the phone lacks it,
iph doctorinstalls it. It uses Xcode's copy when the Mac has one, and otherwise fetches one once from the public doronz88/DeveloperDiskImage repository (about 18 MB, pinned commit and SHA-256). The iph repository contains no Apple files.
With Rust 1.93 or later, the crate on crates.io installs the same iph (building it takes a few minutes; on Windows it needs Visual Studio Build Tools (C++)):
cargo install iphone-cli # ~/.cargo/bin/iphOr from a checkout:
git clone https://github.com/HyunSeob/iphone-cli
cd iphone-cli
cargo install --path . # ~/.cargo/bin/iphFirst-time setup
iph setup runs iph doctor, says in one line what to do on the phone for each failed check, and checks again. An agent can read checks[].user_action from iph doctor (JSON) and guide the user.
Check | Required | What it is |
| yes | The Mac holds a pairing record for the phone. If not: connect by USB and tap Trust |
| yes | The phone is visible over USB or the same Wi-Fi |
| yes | Settings → Privacy & Security → Developer Mode. If it is off, |
| yes | Source of the accessibility, display and input services. When missing, |
| yes | The phone is unlocked. Only lockdown's word decides a lock |
| yes | Settings comes to the front (fails when something covers it). When the screen cannot be read, |
| yes | Screen elements can really be read |
| yes | Scrolls the Settings list down one step and back to see that touch lands ( |
| recommended | Wireless lockdown flags and the phone's usbmuxd |
| recommended | Auto-Lock → Never for long sessions |
| info | Shown only while Do Not Disturb from |
Setup requirements and how to interpret the checks are in docs/onboarding.md (Korean).
Wi-Fi setup and troubleshooting
Pair by USB first, then keep the iPhone unlocked on the same LAN. The computer may use Ethernet. To enable wireless connections, run this while USB is attached:
iph doctor --fix-wifiIf the phone is still not discovered, register its IP below. Wireless setup details (Korean).
Notification banners take taps near the top of the screen. Banners cover the top of the screen and are not part of the accessibility tree. A tap near the top then lands on the banner and opens another app (this happened once during development). For long unattended work turn Do Not Disturb on with iph dnd on, and put it back with iph dnd off afterwards. Details: Do Not Disturb below.
Direct IP when automatic discovery fails
For a USB-trusted phone missing from discovery, use the IP shown in Settings → Wi-Fi → the network's info button:
iph devices # while USB is attached: note the UDID
iph --udid <UDID> connect --ip <iPhone-IP> # after unplugging USB
iph --udid <UDID> readThe Apple device service is still required. CLI, MCP and scripts share the saved address for the selected UDID; register it again if the IP changes. Connection details (Korean).
Commands
Every command prints JSON; add --human for people. The device is chosen by --udid, then IPH_UDID, then udid in ~/.config/iph/config.toml, then the only connected phone. With several phones and none chosen, you get an error with the list.
Command | Does |
| Verify and save the selected paired phone's IP |
| Connected phones, iOS version, connection, readiness |
| Preparation and checks |
| Elements on screen. |
| Elements matching a selector |
| Tap the middle of an element, or a point |
| Swipe. |
| Two fingers. |
| One step, or until an element shows |
| Paste text into the field that has the keyboard (any language, emoji). The clipboard is put back and the field's value checked |
|
|
| Hardware buttons |
| Launch an app, list apps. |
| PNG capture |
| Record the screen to an MP4 file while other commands run |
| A JSON array of steps in one call |
| Run JavaScript as given ( |
| Run a saved script, list saved scripts |
| MCP server on stdio |
| Turn Do Not Disturb on, put the earlier Focus back, or show the current state |
| Capture the phone's log in memory while other commands run; |
| Stop the resident process for this phone |
Selectors
A plain string is an exact label:
iph tap "General"label="exact",label~="contains",label/regex/role=button(application, button, switch, text_field, search_field, key, tab, header, text, image, link, adjustable, other)id=…matches the accessibility identifier or the elementidfromiph read;id~=andid/regex/work toovalue="…",value~=…within="<selector>"only inside that element,index=Nthe Nth match (from 0)Several matches are an
ambiguous_selectorerror with the candidates; nothing is picked for you
Rows labelled "name, value" (as in Settings: "Wi-Fi, HomeNet") also match label="Wi-Fi".
Scripts, MCP and batch also take an object: {label, label_contains, label_regex, value, value_contains, value_regex, role, id, id_contains, id_regex, within, index}.
Results
{"ok": true, "outcome": "done", "elapsed_ms": 1752, "sent": true, "verified": true, "screen_changed": true, "element": {…}}
{"ok": false, "outcome": "not_sent", "error": {"code": "not_found", "message": "…", "hint": "…"}, "elapsed_ms": 1210, "screen_summary": {…}}
| Meaning | Exit code |
| Ran to the end. With | 0, 1 with |
| Nothing reached the phone. Safe to try again | 1 |
| Input may have reached the phone. Do not resend; read the screen | 2 |
The exit code is 0 only with ok: true. batch, script and run follow the same table (1 when nothing went out). The one ok: false with outcome: "done" is scroll --until that did not find its target: the scrolls did go out, so it is not not_sent; the result has error.code: "not_found", found: false, exit code 1. Trying again is safe, but the screen has moved by those scrolls.
The phone does not acknowledge touch reports. So results separate sent from verified (the screen was read again afterwards), and taps, typing and scrolls report screen_changed. When another app came to the front, app_changed: true is added.
For type, ok: true / outcome: "done" means the command completed, and sent: true means the input keys were sent. verified: true keeps its meaning of reading the field's value afterwards; it does not prove the intended text was entered. Apps can format, mask, correct or clear pasted text, so no exact match with the requested text is required.
| Observation |
| The original field's value before input and after input, before Return. |
|
|
| Actual comparison of the accessibility trees before input and after restoring the on-screen keyboard (and after Return, if sent). |
|
|
|
|
An unchanged value may mean paste was blocked, but can also come from masking, app behavior or replacing text with identical text using --clear. Check with iph read or a screenshot; do not automatically retype. If paste appears blocked, check Settings → Apps → the target app → Paste from Other Apps → Allow. The observation does not establish that permission was denied.
--submit withholds Return whenever there is a warning, returning ok: false, outcome: "unknown", error.code: "type_not_verified", submit_sent: false (exit code 2). The paste/clear keys have already gone out. This also stops scripts and batches, including scripts that catch the error. Inspect before deciding to submit separately with iph key return; re-running type could duplicate input. This intentionally also holds an identical replacement with --clear --submit. Clear-only (iph type "" --clear) may submit when the field is observed empty, even if it was empty already. CLI, MCP and script calls share these fields; batch keeps them in each type step, and --human shows observations and warnings.
Configuration
# ~/.config/iph/config.toml
udid = "00008130-…"
[dnd]
# focus = "Work" # a Focus for iph dnd on to switch to instead of Do Not Disturb, by the name the phone shows
# control = "Focus" # label of the Focus control in Control Center, for a phone not in Korean or English
[daemon]
input_idle_secs = 120 # close the input session after this long unused; 0 closes it after every command
idle_exit_secs = 1800 # the resident process exits after this long without requests
screen_video = false # also take the screen video while sending input. Touches do not need it, and over Wi-Fi it clogs the tunnel
restart_accessibility = true # when the phone's accessibility daemon stops answering or answers only with empty readings, end it so the phone starts a new one (takes about 20 s)
record_max_secs = 1800 # `iph record` ends a recording after this long (up to 1.4 GB at the phone's 6 Mbit/s)
[script]
timeout_secs = 300 # how long one script may run (840 at most)
memory_mb = 64 # how much memory a script may holdSending input needs the phone to be in "screen sharing" state (an indicator shows at the top of the phone). iph sets that up with the audio stream alone and does not take the screen video (screen_video). For an app that hides its content or warns while the screen is shared, set input_idle_secs = 0: the phone is then in that state only while input is being sent, at the price of 3 to 4 s more per input. Reading does not depend on screen sharing.
iph does not judge what it presses. Pay, send and order buttons are pressed like any other, and input goes to whatever app is in front. What to press is up to the caller.
Do Not Disturb
On and off:
iph dnd onturns Do Not Disturb on,iph dnd offputs back the Focus that was on before. iph never switches it by itself.Put back to what: at
onthe Focus that was on (or none) is written to~/Library/Application Support/iph/<udid>.dnd.json, andoffrestores it as it was. If the phone was already in Do Not Disturb, iph leaves it alone; if a person switched to another Focus meanwhile, that one stays. The record outlives the resident process.How: no service on the phone offers this, so iph does what a person does: pull Control Center down, hold the Focus control, pick the mode in the list, press Home twice. Control Center is therefore visible for a moment, and one switch usually takes 11 to 15 s, or 19 to 36 s when the resident process has just started.
Needs: the Focus control on Control Center's first page, and Control Center opening while an app is in front. For a phone in a language other than Korean or English, put the names the phone shows in
controlandfocusunder[dnd].Not covered: whatever comes through Do Not Disturb (alarms and timers, emergency alerts, people and apps allowed in the Do Not Disturb settings) and system pop-ups. Whether banners really stay away while Do Not Disturb is on was not tested separately (it relies on how iOS behaves).
Phone log
iph syslog start collects what the phone logs, in a buffer inside the resident process, while taps, reads and scripts go on as usual. iph syslog read returns what arrived since the last read without stopping the capture, so a test or an agent can check what an app logged after each tap. No sudo log collect on the Mac is needed.
iph syslog start --app com.apple.Preferences # an app by bundle id or name, as `iph launch` takes it
iph launch com.apple.Preferences --restart
iph tap "Battery"
iph syslog read --grep "battery" # what was logged since start; the result has "cursor": 12
iph tap "General"
iph syslog read --after 12 --grep "general" # only what is newer than the last read
iph syslog stop # or: stop --grep "general" --max 20The buffer: kept entries go into a ring buffer in memory, at most 100,000 entries and 64 MiB (
--buffer-entries,--buffer-mb); the oldest are dropped first. Each entry gets aseq: 1 for the first of a capture, one more for each after it. Nothing is written to disk unless you ask with-o. The buffer lives in the resident process, so it goes with the capture wheniph stopends it, a newer build replaces it, or it exits after its idle time.statusshows how full it is underbuffer(entries,bytes,oldest_seq,newest_seq,evicted).read: returns the entries newer than--after SEQwhose message matches--grep(a regular expression), oldest first, at most--max(50 by default, at most 1000). Each message is cut to 500 characters (message_cut;-okeeps the whole message). Without--afterit starts at the oldest entry the buffer still holds. The result hasentries,count,cursor,more,droppedandstate, andended_reasononce the capture has ended.cursor: pass it as the next--after. It is the last entry returned when--maxcut the page short, and the newestseqwhen the whole buffer was looked through, even if nothing matched. So a loop never reads an entry twice and never skips one that is still in the buffer. A cursor belongs to the capture that gave it: seqs start again at 1 with each capture, so after a newstartread without--after.more:truewhen--maxcut the page short and another matching entry is already waiting.dropped: entries newer than--afterthat were pushed out of the buffer before this read. Anything but 0 means entries were lost; read more often or filter.A capture that ended (a dropped connection) can still be read until you
stopit.
The file (optional):
-o <file>also writes every kept entry to a JSON Lines file with its whole message, readable by you only: a{"event": "start", …}line, one line per entry (seq,time(UTC),pid,process,sender,level,subsystem,category,message) and a final{"event": "end", "reason": …}line. A file without anendline was cut off by a killed resident process. At--max-mbMiB (1 to 4096, 64 by default; it needs-o) the file moves to<file>.1, replacing the previous one (thestartline goes with it). Starting again empties the file once the phone has started sending; astartthat fails leaves it as it was.Filters:
--appkeeps the entries of an app, named by bundle id or display name the wayiph launchtakes it (repeatable). iph looks up where the app is installed and keeps an entry when its executable lies in that bundle, so the app's extensions count too and the filter keeps matching across restarts of the app. An app that is not installed (or a name that fits two) fails before anything starts.--processkeeps entries by executable name, exactly (repeatable); Settings isPreferences. With both, an entry is kept if it is from any listed app or any listed process.--leveldrops anything below debug, info, notice, error or fault, whichever of those selected it.--pidmakes the phone send only that process's entries, so it narrows what--appand--processcan match.Volume: unfiltered over Wi-Fi it is a lot. In one 60 s idle run the phone sent about 4,800 entries/s, 1.4 MB/s. At that rate the default buffer holds about 20 s (100,000 entries), so read often or filter with
--processfor anything longer. An entry of about 290 B as JSON weighs about 430 B in memory, so a full default buffer takes about 41 MiB; the 64 MiB limit applies when messages run long.Cost to other commands: in one run over Wi-Fi (an iPhone 16 Pro, the first tap after starting iph: 6 taps without a capture, 4 with an unfiltered capture receiving 2,900 to 9,900 entries/s, 3 with
--pid), the capture did not slow taps: the medians were 10.0, 10.1 and 9.7 s. Every tap over 6 s, with a capture or without, waited for one screen reading the phone did not answer, which iph asks again after 6.5 s. The resident process used at most 12% of one core. The volume itself costs reads: with the phone locked, areadtook 2.3 s at 9,000 unfiltered entries/s against 1.0 s without a capture, so over Wi-Fi use--pidwhen reads must stay quick (--appand--processfilter on the computer, after the entries have crossed the network).stop: returnsseen(entries the phone sent),kept(put in the buffer),bufferand why it ended, and with-oalsorotationsandpath. With--grepor--maxit also returnsmatched, the number of entries in the buffer that matched, andentries, the latest--maxof them, oldest first (50 by default, at most 1000, cut likeread's). The buffer is gone afterstop, so read what you need first.What ends a capture:
stop, a dropped connection, iph rebuilding its connections (after a command times out or the phone stops answering),iph stop, a newer build of iph replacing the resident process, or the resident process exiting after its idle time (a capture does not keep it alive). Theendline (with-o) andstatussay which. A capture is not restarted by itself, so a gap in the log is never hidden. One capture runs at a time: a secondstartfails withcapture_running, or withcapture_endedwhile an ended capture waits to be read;stopit first.After a dropped connection the phone sends nothing to the next capture for about 20 to 30 s.
statusandreadsay so in ahintwhile nothing has arrived.Private values: values an app marks private in its log calls arrive as
<private>, as in Console. In one app's launch, about a fifth of its entries carried one.Also in scripts as
syslog(action, opts)and over MCP asiph_syslog. A script cannot write a file. Not inbatch: a capture outlives the call that started it.
Recordings
Visual evidence for a test run, made by iph itself: no ffmpeg is needed.
Recording. iph record start -o run.mp4 starts writing the screen to an MP4 (HEVC, as the phone sends it), and iph record stop ends it and returns {path, duration_s, frames, keyframes, lost_packets, bytes, width, height}, with first_loss_s and a packets_lost warning when packets were lost. iph record status shows the state. Taps, swipes and reads keep working while it runs (tap latency was the same with and without a recording). One recording at a time: a second start fails with recording_running and a stop with nothing running with no_recording, and neither changes anything.
How: the recorder opens a screen-sharing session of its own with the phone, the video of one display, next to the input session's audio, so the phone shows its screen-sharing indicator. Each session stops only its own streams: input sessions open, close and retry as usual while a recording runs, and
stopleaves the input session alone.Use USB. The phone sends one keyframe, at the start, and never another, so a lost packet damages the picture from there to the end of the file. Players still open such a file. When packets were lost, the result has
lost_packetsabove 0,first_loss_s(seconds into the file where the damage starts) and awarningwith codepackets_lost; the result staysok. On an iPhone 16 Pro over Wi-Fi, 2 of 9 short recordings lost packets (9 and 51). Over USB no packet was lost in the runs measured.Still screens: the phone sends few frames or none while nothing moves. The last frame then lasts until
stop, so the file is as long as the recording.Which display: without
--display, displays 1, 0 and 2 are tried and the first whose video has the shape of the screen being read is kept: its width and height in pixels must match the points ofiph readto within 1%, elsedisplay_mismatch. A display whose video does not start (record_failed) is passed over too, and the displays are tried for at most 45 s, after whichstartfails withstart_timeout. On an iPhone Duo folded, displays 0 and 1 both show the cover screen and display 2 sends nothing.The file: frames go to
<file>.partas they come, andstopadds the index and renames it. If the resident process stops (iph stop), the file is completed too. If it is killed, only<file>.partis left, without the index; the stream it left running on the phone is stopped within seconds after the next command connects to the phone. So is the video of a start that was cut off, or of a recording that ended because the connection was reset; a stream still left when the resident process exits is stopped on its way out. Streams another client started, such as Xcode's screen view, are left alone.Ending on its own: a recording also ends, and its file is completed with what came, when the connection to the phone is closed, or reset after a connection error, an accessibility service that would not open, or a command that ran out of time (not when only the accessibility connection or the input session is made again), when the phone stops sending the video (none for 2.5 s, and the phone no longer lists the stream or did not answer three checks in a row), when the phone changes the video's parameter sets, or after
record_max_secs([daemon]inconfig.toml, default 1800: at the phone's cap of 6 Mbit/s, 30 minutes is up to 1.4 GB). The reason is inended_reason.stopreturns that report, or else the nextstartdoes, underprevious. The resident process does not exit for being idle while it records, nor for its idle time after a recording ended with nobody told.Scripts: a recording a script started and did not stop ends with the script, also when the script throws, and the script's result has its report under
recording.Measured on an iPhone Duo (iOS 27.2.1, folded, USB): 1408x2048, 50 to 52 fps while the screen moves, about 0.5 Mbit/s.
Scripts
A sequence you run often is written in JavaScript and runs in one call. The commands (read, tap, scroll …) are functions; loops, conditions and variables are the language's own. The engine (QuickJS) is inside iph, so there is nothing else to install.
// Read the iOS version from Settings
launch("com.apple.Preferences", { restart: true });
scroll("down", { until: "일반" });
tap("일반");
tap("정보");
return { ios_version: readField({ selector: { label: "iOS 버전" }, take: "value" }) };iph script flow.js --arg city=Seoul # run a file
iph script - <<'EOF' # from stdin
return { front: read({ app: true }).apps[0].name };
EOF
iph run settings-version # a saved script, by name
iph scripts # list saved scripts{"ok": true, "outcome": "done", "elapsed_ms": 10712, "outputs": {"ios_version": "27.0.1"}, "logs": [], "calls": 5, "inputs_sent": 4, "script": "settings-version", "source": "builtin:settings-version"}Where they live:
~/.config/iph/scripts/<name>.js(personal, wins), then the repository'sscripts/(examples, built into the binary). A file's first comment line is its description iniph scripts.Arguments and results:
--arg k=varrives asargs.k(text, so a number isNumber(args.n)). The object the script returns, plus anything set withoutput(k, v), becomesoutputs; lines written withlog(…)come back inlogs.
Function | What it does |
| Same arguments and result as the command of that name |
| For a selector: waits up to 5 s for it to appear and taps once it has been in the same place on two readings in a row (a screen that has just come up may still shift its rows). |
| Tap several targets in a row on the screen as it is, without reading in between (keypads) |
| Swipe, scroll |
| Pinch, spread or turn two fingers (as |
| Type, key, button |
| Launch and check it is in front. |
| Until the element appears (8 s by default). It sits out a system panel (Face ID) that covers the app for a moment |
| One value, as text. |
| Collect a list while scrolling, each row once; returns |
| Wait, note, add a value to the result |
|
|
A function returns the JSON object the CLI command of the same name prints (
tap("일반").screen_changed,read().elements). Selectors can be strings or objects.A failure is an exception. A call that fails throws an
Errorcarryinge.code,e.outcome,e.hintande.result(the whole result object). Uncaught, it ends the script, and the result hasfailed_call: {cmd, line, outcome},reason: {code, message}andscreen_summary. Nothing is guessed. Usetry { … } catch (e) { … }only around something that may legitimately be missing.The
outcomeof a script that stopped:unknownif any input had gone out before it stopped (running it again would send that input again), andnot_sentif none had.inputs_sentcounts the calls that sent input.Nothing follows
unknown. After a call whose input may or may not have reached the phone (outcome: "unknown") the script is ended there. Catching the error does not help: no further call reaches the phone.Any call takes
hint: "…"among its options: what to tell the person if the script stops at that call ("look at the phone" on awaitForthat sits out Face ID).After
launch, that app must stay in front. If another app comes up, input calls andreadField/readListstop withunexpected_app.readList:columnsis{name: {take, regex, selector}}, or{name: {value: "…"}}for the same value on every row.group: {selector, regex, as}turns headings between rows (a date line) into a column of the rows under them, andstop_below: Nstops once a heading's number falls below N.key: "column"says two rows are the same row when that column agrees; use it for lists whose rows change while they are read (a clock, time left). Without it the whole row has to agree.readListreads each screen once and works out by itself how far to scroll so that the last two rows of one screen land at the top of the next (that depends on the phone and the app, so it is computed from where rows were read). The two shared rows stitch the screens together, which shows whether a row was skipped. Before it calls the end of a list it moves the list up and down once to check.Walls: a script cannot reach files, the network or other processes (no module loading, no timers).
Date,JSON,RegExp,Mapand the rest of the language are there. A script that runs past[script] timeout_secs(300 s by default) or holds more thanmemory_mb(64 MB) is stopped.
Examples: settings-version, calculator-multiply, clock-world-list, and settings-list with a loop and a condition (all written for a Korean-language phone). Keep personal scripts (banking, delivery) out of the repository, in ~/.config/iph/scripts/.
batch
iph batch runs a JSON array of steps in order and stops at the first failure. It is for short sequences that need no loop or condition.
Step | What it does |
| Launch and check it is in front |
| Until the element appears (8 s by default) |
| Tap, tap several in a row |
| Type, swipe |
| Pinch, spread or turn two fingers |
| Scroll until it shows |
| Read one value, read a list (as |
| Continue only if it is there, button, key, wait (ms) |
(on any step) | Condition, what to say if it stops |
A failing step returns {failed_step, reason, screen_summary, inputs_sent}; each step's elapsed_ms is in steps. Recording is not a step: a recording spans requests, and a failing batch would leave it running. Scripts have record().
MCP
claude mcp add iph -- iph mcp # Claude Code
codex mcp add iph -- iph mcp # Codex
iph mcp --tools read,find,script # offer only some toolsTo have an agent reach for iph on its own, link the skill (it works with iph in the shell alone, without the MCP registration).
ln -s "$PWD/skills/iph" ~/.claude/skills/iph # Claude Code
ln -s "$PWD/skills/iph" ~/.codex/skills/iph # CodexTools: iph_connect, iph_read, iph_find, iph_tap, iph_swipe, iph_pinch, iph_scroll, iph_type, iph_key, iph_button, iph_launch, iph_apps, iph_screenshot, iph_record, iph_batch, iph_script, iph_run, iph_scripts, iph_doctor, iph_dnd, iph_syslog. Arguments and results are the same as the CLI's; iph_launch takes arguments (array of strings) and environment (object of strings). iph_script takes code (JavaScript) and args; iph_run takes name and args. Guidance for agents: skills/iph/SKILL.md.
MCP Registry: mcp-name: io.github.HyunSeob/iphone-cli
Speed
iPhone 15 Pro Max, iOS 27.0.1, Wi-Fi, with the resident process connected (2026-11-11).
Action | Time |
| median 1.35 s, max 2.10 s |
| median 1.45 s, max 1.79 s |
| median 1.75 s, max 4.30 s |
| 2.1 to 2.6 s |
| 4 to 7 s |
Script | 9.9 to 13.3 s (8 runs) |
First | about 2 to 3 s |
Turning Do Not Disturb on, or putting the earlier Focus back | median 12.5 s with the connection up (11 runs, 10.9 to 14.2 s); 19 to 36 s right after the resident process starts |
A reading takes more than a second because of the phone: after a request it waits about 1.1 s in silence before it sends the screen. In apps whose screen often changes on its own, readings are taken twice and compared so that an out-of-date screen is not used; that adds 1 to 2 s per step. Details: docs/how-it-works.md (Korean).
Known limits
Verified on one device. Other iOS versions may number the accessibility attributes differently (check with
iph read --raw).Apps whose screen keeps moving (animations, video) take longer to read.
Notification banners and system pop-ups are not in the app's tree.
iph dnd onkeeps most banners away, but not what comes through Do Not Disturb.The screen-reading service can stop answering. iph attempts a restart at most every two minutes, except when the last screen was a system panel or a previous restart did not help. If Control Center cannot be read while recording, close it with
iph button homeor bring an app up withiph launch, then read again. See recovery behavior (Korean).Portrait only.
Record over USB. Over Wi-Fi, 2 of 9 short recordings lost packets in testing, and with one keyframe per stream a lost packet damages the rest of the file (
warning.codeispackets_lost).iph appsshows the names the phone reports (usually English). Launch by bundle id to be sure.iph typeputs back the clipboard's text (or one image). Content copied in an app (text from Notes, which comes with formatting) is not put back. Reading it from the computer stalls the phone's clipboard for about a minute, so it is left unread and the clipboard is emptied after typing. The result saysclipboard_restored: falsewith aclipboard_note.Nothing works on a locked phone. Face ID and passcode prompts are never answered for you.
Mounting the developer disk image automatically is written but untested (the test phone already had it mounted).
FAQ
How can Claude Code or Codex control a real iPhone without Xcode or WebDriverAgent?
Install HyunSeob/iphone-cli (iph), connect an iOS 27+ iPhone over USB, run iph setup, and register the built-in MCP server (claude mcp add iph -- iph mcp or codex mcp add iph -- iph mcp). You can also link skills/iph so an agent drives iph directly in the shell without registering MCP.
Why use the accessibility tree instead of screenshots and OCR?
iph reads Apple's native remote accessibility service (axAuditDaemon.remoteAXService) and returns compact JSON elements with role, label, value, id, enabled, and frame. Agents spend far fewer tokens than sending screenshots every turn and target controls semantically (iph tap "General", role=button label~="Save") rather than relying on fragile pixel coordinates.
Can I automate a real iPhone from Windows without a Mac?
Yes. iph is a single native binary for both macOS and Windows 10/11 (x64). On Windows, install Apple's device service via the Apple Devices app or winget install Apple.AppleMobileDeviceSupport, download iph-windows-x86_64.zip from releases, and connect over USB or Wi-Fi.
Does iphone-cli work in the EU without macOS iPhone Mirroring?
Yes. iph communicates directly with Apple's developer services over USB or LAN/Wi-Fi and does not use macOS iPhone Mirroring, so it is unaffected by regional iPhone Mirroring restrictions.
How does iphone-cli prevent accidental double taps or duplicate orders?
Because iOS never confirms HID touch packets, every command separates sent, verified, and screen_changed and returns an explicit outcome (done, not_sent, or unknown). When an outcome is unknown (exit code 2), scripts stop immediately—even inside try/catch—so the agent reads the screen before deciding whether to act again.
Does iphone-cli support iOS 26 or earlier, iOS Simulators, or Android?
No. Touch and text input rely on com.apple.coredevice.displayservice, introduced in iOS 27. Simulators, Android, Linux hosts, and landscape orientation are out of scope.
How it is put together
One iph call is one request over a Unix socket (~/Library/Application Support/iph/<udid>.sock) to a resident process (iph daemon, started by the first call). It keeps the tunnel, the accessibility subscription and the touch-input session open per phone and handles requests one at a time. It exits after 30 minutes without requests.
iph (CLI) ─┐
iph mcp ──┼─ unix socket ─ iph daemon ─ lockdown → CoreDeviceProxy → userspace TCP tunnel → RSD
┘ ├ axAuditDaemon.remoteAXService (screen elements)
├ displayservice + universalhid (touch, keyboard)
├ pasteboardservice (clipboard)
├ appservice (launch, app list)
└ screencaptureservice (capture)Reporting a problem
Create an issue attachment with one command, even when no phone is detected:
iph diagnose
iph diagnose -- read --full # run the failing iph command once and capture its output
iph diagnose --wifi -- read # start with USB connected; unplug when promptedAttach the generated iph-diagnostics-*.txt to a GitHub issue, along with the reproduction steps and expected/actual behavior. The file contains readable JSON: versions and network state, raw and parsed usbmuxd lists, phone facts and wireless settings, pairing/connection/tunnel errors with timings, Bonjour advertisements and endpoint TCP probes, recent connection events and daemon logs, and related macOS system logs. UDIDs, addresses, command arguments and captured output are retained for debugging. Pairing records and private keys are not collected.
--wifi records USB facts first, then observes discovery for 30 seconds while you unplug the cable. --duration 60 changes that observation window. The phone selected during the USB baseline remains selected after it disappears; use --udid when several phones are attached. Bonjour services may belong to other devices, so the report preserves the advertisements without assuming their identity. On Windows, the Bonjour checks use dns-sd if it is installed; missing tools and failed checks are recorded and do not prevent the attachment.
Use -o report.txt to choose the output path (existing files are preserved). --command-timeout 180 changes the reproduction timeout. Collection itself does not change phone settings, install a developer image, or operate the screen. A command supplied after -- performs its normal actions; the collector runs it once and never repeats it. For ordinary command capture, active device probes run afterwards so they do not initialize a session before the failure. setup, mcp, daemon and nested diagnose are not accepted as reproduction commands. Ctrl+C saves the collected partial report. Exit code 0 means the report was saved; the reproduced command's exit code and output are inside it.
Connection events are recorded automatically under ~/Library/Application Support/iph/events/ on macOS or %LOCALAPPDATA%\iph\events\ on Windows, including failures before a phone is selected. Files rotate at 512 KiB, with 32 recent files retained; the report includes tails of the 8 most recently updated files and the selected phone's daemon log. Each captured output is limited to its last 256 KiB, with truncation marked. USBMUXD_SOCKET_ADDRESS can select a nondefault usbmuxd socket for both normal commands and diagnosis.
Development
cargo test # runs without a phone: parser (real Calculator dumps), selectors, scripts
IPH_TRACE=1 iph … # logs request and dump times to ~/Library/Application Support/iph/<udid>.log
IPH_PCAP=<dir> iph … # writes the tunnel's packets out for Wireshark; they hold screen contents, delete them afterReleasing: raise version in Cargo.toml and push to main. The release workflow then tags vX.Y.Z, publishes the macOS and Windows binaries as a GitHub release (what install.sh downloads) and publishes the crate to crates.io through Trusted Publishing, so no token is kept anywhere. Pushes that leave the version alone release nothing.
License
MIT, see LICENSE. The media-session bring-up is adapted from an idevice example tool (LICENSE.idevice). src/tcp is the tunnel's TCP stack, taken from jktcp 0.1.8 (MIT), with two constants changed so that it waits longer before giving a connection up, the microseconds of its packet capture fixed, and a way to reset one connection (RST) added for iph syslog (LICENSE.jktcp).
Available Tools
21 toolsiph_appsB
List installed apps with their bundle ids.
Inputs: no named parameters.
iph_batchA
Run several steps in one call, stopping at the first failure. Each step is a one-key object: {"launch": "…"}, {"wait_for": selector}, {"tap": selector}, {"type": {"text": "…"}}, {"swipe": "up"}, {"pinch": "out"}, {"scroll_until": selector}, {"read_field": {"name", "selector", "take"}}, {"read_list": {"name", "row", "columns"}}, {"assert": selector}, {"button": "home"}, {"key": "return"}, {"sleep": ms}.
Inputs: steps (required).
iph_buttonC
Press a hardware button.
Inputs: button (required).
iph_connectA
Verify and save the selected paired iPhone's IP address when automatic discovery fails. Requires prior USB trust on this computer. Checks a paired session and reported UDID before saving. Subsequent tools and scripts use the address; this does not establish developer-service readiness or repair Apple's discovery list.
Inputs: ip (required).
iph_dndA
Do Not Disturb on the phone, so a notification banner cannot take a tap. "on" before the work, "off" when it is done (puts back the Focus that was on).
Inputs: action (required).
iph_doctorC
Check that the phone is ready. Each check says what the user must do when it fails.
Inputs: fix_wifi, no_touch_test.
iph_findC
Find elements on screen that match a selector.
Inputs: selector (required), all.
iph_keyB
Press a key: return, esc, tab, space, backspace, delete, arrows, or a combination like cmd+a.
Inputs: key (required).
iph_launchB
Bring an app to the front by bundle id (com.apple.Preferences) or by its name.
Inputs: app (required), restart, arguments, environment.
iph_pinchA
Two fingers on the screen: pinch in or out to zoom, turn to rotate (a map, an image, a web page). Give a direction, or a scale and/or a rotation. The fingers meet in the middle of the screen, or at at. screen_changed: false is a fair answer on a screen that does not zoom. Never retry one whose outcome is "unknown".
Inputs: at, scale, rotate, direction, +1 more.
iph_readA
Read the iPhone's current screen as a list of elements (id, role, label, value, frame in points, traits, enabled). Read before acting; coordinates and labels come from here. Only on-screen elements unless all=true.
Inputs: all, app, full, max_age_ms.
iph_recordA
Record the phone's screen to an MP4 file while other calls run, as evidence of a test. "start" (one recording at a time; taps keep working), "stop" (ends it and returns path, duration_s, frames, lost_packets; with first_loss_s and a packets_lost warning when packets were lost), "status". The phone shows its screen-sharing indicator while recording. Prefer USB: the phone sends one keyframe, so a packet lost over Wi-Fi damages the picture until the end.
Inputs: action (required), path, display.
iph_runB
Run a saved script by name (see iph_scripts) in one call and get its outputs. Same result as iph_script.
Inputs: name (required), args.
iph_screenshotA
Save a PNG screenshot to a file on this computer. Use iph_read for content; this is for looks.
Inputs: path (required).
iph_scriptA
Run JavaScript that drives the phone, in one call: loops, conditions and several steps without a round trip each. The commands are functions that return what the tool of the same name returns: read(opts), find(selector), tap(target, opts), swipe(direction | {from, to}, opts), pinch(direction | {scale, rotate, at}, opts), scroll(direction, {until, max}), type(text, {clear, submit}), key(name), button(name), launch(app, {restart, arguments, environment}), apps(). Also waitFor(selector, {timeout_ms}), readField({selector, take, regex}) → text, readList({row, columns, group, stop_below, max_scrolls}) → {rows, scrolls, ended}, sleep(ms), log(…), output(key, value). syslog("start" | "read" | "stop" | "status", {app, process, pid, level, after, grep, max}) captures the phone's log as iph_syslog does and returns what it returns; a script cannot write a file. record("start" | "stop" | "status", {display}) records the screen as iph_record does; a script cannot choose the file. tap(target) waits up to 5 s for a selector to appear and hold still; tap([a, b, c]) presses a keypad without re-reading. A call that fails throws an Error with .code, .outcome, .hint and .result (the full result object); uncaught, it ends the script and the result says which call and line. After a call whose outcome is "unknown" the script is stopped and cannot go on. For type(), verified means read back, not text matched; inspect value_changed and warning, never automatically retype. submit withholds Return with unknown / type_not_verified when the effect is uncertain. No files, network or timers; Date, JSON, RegExp, Map and the rest of the language are there. The result has outputs (the returned object, plus output() calls), logs, calls and inputs_sent.
Inputs: code (required), args.
iph_scriptsA
List saved scripts: name, what each does, and where it lives.
Inputs: no named parameters.
iph_scrollB
Scroll the content. "down" shows what is further down. With until, keeps scrolling until that element is on screen.
Inputs: direction (required), max, until.
iph_swipeC
Swipe the finger up, down, left or right across the middle of the screen, or between two points.
Inputs: to, drag, from, direction, +1 more.
iph_syslogA
Capture the phone's log in the background while other calls run, to check what an app logged after a tap. "start" (one capture at a time; stop an ended one before starting again) keeps the entries in a buffer in memory, newest last, each with a seq; "read" returns the entries newer than after (the cursor of the previous read) without stopping the capture, so the loop is start, tap, read, tap, read, stop; "stop" ends it (with grep or max it returns the latest matching entries); "status". Filter with app (bundle id or name, as iph_launch takes it; matched by where the app is installed, so it survives restarts and includes its extensions), process (executable names such as Preferences; survives app restarts) or pid; an entry is kept if it is from any listed app or process; unfiltered over Wi-Fi it is thousands of entries a second, and the buffer keeps the last 100,000 entries by default. A read says how many entries were dropped before it could get them.
Inputs: action (required), app, max, pid, +8 more.
iph_tapA
Tap an element (selector) or a point ("x,y" in points). Waits for the screen to change and hold still, then returns it (elements, as iph_read does) and whether it changed. Never retry a tap whose outcome is "unknown".
Inputs: target (required), double, long_ms, no_wait.
iph_typeA
Type text into the field that has the keyboard (tap the field first). Pasted through the clipboard, so Korean and emoji work; the user's clipboard is put back (not content copied in an app: see clipboard_note). verified means the value was read, not that it matches the intended text. Inspect value_before, value, value_changed (true/false/null) and warning. An unchanged value can mean blocked paste, masking or identical replacement; never automatically retype. screen_changed compares accessibility readings after keyboard restoration (null if unavailable). submit withholds Return with outcome unknown / type_not_verified when the input effect is uncertain.
Inputs: text (required), clear, submit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
Most tools target clearly distinct actions or resources: read vs find, tap vs swipe/pinch/scroll, launch vs apps, syslog vs record. The main overlap is the orchestration cluster (iph_script, iph_batch, iph_run, iph_scripts), where an agent could initially hesitate between batch and script for multi-step work, though the descriptions give usable boundaries.
All tools use the same `iph_` prefix and lowercase snake-style naming, which is highly predictable. Most names are short verbs or resource nouns rather than a strict verb_noun pattern, but the convention is consistent enough to avoid confusion.
Twenty-one tools is on the high side for a general MCP server, but iPhone automation naturally needs a broad set of interaction, inspection, setup, and evidence-capture primitives. Each tool has a recognizable role, though the scripting/batch/run cluster makes the surface feel slightly heavier than necessary.
The server covers the core iPhone automation lifecycle: connection and readiness checks, app listing/launch, screen reading/finding, touch and keyboard actions, hardware buttons, DND, screenshots, logging, recording, and multi-step scripting. Minor gaps such as standalone wait/assert tools or app termination are workable through existing tools.
Maintenance
Related MCP Connectors
Drive real devices from your AI Coding tool. Embed a client SDK (Unity, Godot, Flutter, iOS/macOS, Android, React Native, Web) in your app, then capture screenshots, traverse the UI tree, inject taps and key events, and run automated test tasks on the physical device over a secure relay.
remote debug iOS/Android/Unity/Godot/Flutter/RN/Web on real-device.ui-tree/screenshots/taps,tests.
Let your AI agent control real iPhones: screenshots, tap, swipe, type and open apps.
Melaya is a remote MCP server. It gives an assistant hands on your own Android phone and browser: it reads the screen through the accessibility tree, then taps, types and navigates inside the apps and sites you allow-list, with no per-app API. It also builds, schedules and runs agent pipelines across 6k+ connected tools. OAuth 2.1, nothing to install.
Related MCP Servers
AlicenseNot gradedqualityCmaintenanceHigh-performance MCP server for iOS development and test automation. Gives AI coding assistants direct access to iOS simulators with sub-20ms screenshots, UI interaction, building, testing, and an intelligent operator mode.10MIT- AlicenseNot gradedqualityDmaintenanceLocal MCP server for iOS Simulator and macOS app automation with a TypeScript MCP layer and Swift native bridge. Enables UI inspection, input automation, and simulator control through unified generic tools.73 npm26MIT
- 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 gradedqualityBmaintenanceEnables AI agents to operate a real iPhone from a Mac by reading the screen over USB and sending taps, swipes, typing, and app launches over Bluetooth, with every action returning a fresh screenshot so the agent can verify its work. Runs as a local MCP server, so agents can test iOS apps on physical devices and automate everyday phone tasks.40 npm10MIT