Control a real USB-connected iPhone from Linux (no Mac, no paid developer account) and expose it to AI agents as MCP tools
CLI
Every command is iphone-control <command>. --help shows help, --version the version. Output is in Simplified Chinese by default; set IPHONE_CONTROL_LANG=en for English (the first-run guide asks).
iphone-control with no command runs the first-run guide the first time; once set up, it shows the status (and starts the daemon first if it isn't running).
Global options
These go before the command, for example iphone-control --socket /path/ctl.sock mcp.
| Option | Environment variable | Meaning |
|---|---|---|
--data-dir <dir> |
ICTL_DATA_DIR |
Data directory; defaults in Configuration |
--socket <path> |
ICTL_SOCKET |
The daemon's control socket; defaults in the same place |
Running
| Command | What it does |
|---|---|
daemon |
The long-running daemon. Usually started by the background service; you can also run it in a terminal |
mcp [--url <viewer> [--ca <PEM>]] |
MCP stdio server, started by the AI client. With --url (or IPHONE_CONTROL_URL set), a bridge to another machine's viewer /mcp: for a phone on that machine and a client that only starts a command. With a task's token (IPHONE_CONTROL_TASK_TOKEN) only that is sent, otherwise the login from IPHONE_CONTROL_VIEWER_TOKEN; a command under task run --url has these set, so a plain iphone-control mcp works there |
mcp-config |
Prints the command that registers the MCP server with Claude Code, with a program path that stays the same across upgrades (Homebrew's opt link) |
Shell completion
iphone-control completions <bash|zsh|fish> writes a completion script to stdout, including the current build's subcommands, options and enum values. It does not read the settings file, acquire a device maintenance lock, or connect to the daemon or a phone. Descriptions default to Chinese; prefix the command with IPHONE_CONTROL_LANG=en for English.
# Bash: enable in the current session
mkdir -p ~/.config/iphone-control
iphone-control completions bash > ~/.config/iphone-control/completion.bash
source ~/.config/iphone-control/completion.bash
# Zsh: save in a custom completion directory
mkdir -p ~/.zsh/completions
iphone-control completions zsh > ~/.zsh/completions/_iphone-control
# Fish: use its automatically loaded completion directory
mkdir -p ~/.config/fish/completions
iphone-control completions fish > ~/.config/fish/completions/iphone-control.fish
For Zsh, add fpath=(~/.zsh/completions $fpath) before compinit in ~/.zshrc, and make sure autoload -Uz compinit; compinit runs. For Bash, put the source line above in ~/.bashrc to load completions on startup. Regenerate the completion file for your shell after upgrading. If you use a custom Fish configuration directory, use its completions subdirectory.
Host software updates
Run iphone-control update to check the publisher's latest stable release. It reports when you are up to date. When an upgrade is available, it first says what it will do (from which version to which, and whether the background service restarts), asks whether to continue, then upgrades through the installation method of the running executable. In a script or without a terminal, add --yes to upgrade without asking.
| Installation | What iphone-control update does |
|---|---|
| Managed per-user service installed by the signed release script | Verifies the publisher's signature, installs the update, then restarts the service and checks its health; if the new version doesn't start within 60 seconds, the old one is put back. Close Viewer, MCP and other device clients first. If you pinned a version with --version, run iphone-control update unpin when you are ready to upgrade. |
| Homebrew | Runs the Homebrew upgrade through the tap bound to this installation. The tap determines which version is available. A running brew services service is restarted afterwards. |
| Debian / Ubuntu package | Downloads the matching .deb for the target version and host architecture from the same publisher, checks the publisher's signature for it, then installs it with apt through sudo (asks for your password). The package's systemd user service is restarted afterwards if it was running. A package held with apt-mark hold isn't upgraded; release it with sudo apt-mark unhold iphone-control first. |
| Source builds, script installs without a managed service, or unrecognized installations | Shows instructions for a manual upgrade. A development build without a publisher displays guidance locally. |
Restarting the background service interrupts running AI tasks and the control page's picture. After a Homebrew or apt upgrade the command checks that the service now runs the new version; if it can't confirm that, it prints the restart command to run by hand. Reopen Viewer and reconnect your MCP client to use the new executable there too.
Use iphone-control update check for a version check only, or iphone-control update check --json for machine-readable output. This check and About & updates in Viewer share the local release cache. If the network check fails, the previous successful record is kept. A red dot on the ⓘ button beside Settings indicates a newer release. Open the panel to read the release notes and copy the update command for the current executable into a local terminal.
Viewer needs a login token (see viewer below). Anyone with a token, a read-only one too, can read installation information and request a version check; upgrades and policy changes are only done from a terminal on this machine.
Managed services check in the background by default. update apply installs without asking (managed services), and update recover finishes an interrupted replacement. There is no command to go back to the previous version: to run an older one, uninstall with the release's install script and --uninstall (settings and device data are kept), then install that version with --version vX.Y.Z. If you currently run the 0.2.2 CLI, use iphone-control update check and follow the command it shows to upgrade to a version with the new iphone-control update command.
Run iphone-control update policy auto-patch to opt in to installing compatible patches when idle. Viewer, MCP and direct device clients (including paused tasks) must exit before the service can restart. If the new daemon fails its health checks the updater restores the old executable and holds the failed version for an explicit retry. update policy notify checks without installing; update policy manual removes the scheduled job.
If the new executable cannot start, invoke <prefix>/bin/.iphone-control-update/recovery update recover directly. For a custom socket, add --socket <path> before update.
Background service
The daemon runs as a per-user service: launchd on macOS, a systemd user service on Linux. It starts when you log in and restarts after a crash. No root needed.
| Command | What it does |
|---|---|
service install |
Set up the service and start it; if one exists, just start it |
service uninstall |
Stop and remove the service this program set up; data is kept. A service that came with Homebrew or the .deb isn't removed: it is disabled, or you're told how to stop it |
service start / stop |
Start or stop it |
service restart |
Restart it, after editing ~/.config/iphone-control/env |
service status |
Which service is set up, whether the daemon is running, and whether the viewer service is set up and running |
service viewer install |
Set up the viewer as a service of its own that starts at login, and start it. Its port and whether it is open to the local network come from IPHONE_CONTROL_VIEWER_PORT, IPHONE_CONTROL_VIEWER_LAN and IPHONE_CONTROL_VIEWER_LAN_HOSTS in the settings file. It keeps this shell's PATH so the viewer finds claude and codex; install again if that changes |
service viewer uninstall / start / stop / restart |
Remove, start or stop the viewer service; restart after changing those settings. An update stops it first and starts it again afterwards (an automatic update waits while an AI task runs) |
These commands find the service set up by the one-command install, iphone-control service install, brew services or the .deb, and act on whichever is there.
Setup and signing {#setup}
| Command | What it does |
|---|---|
setup |
Runs the whole guide again: language, proxy, background service, pairing, Developer Mode, Apple ID, signing and installing WDA, auto-unlock, notifications, MCP registration. Done steps are skipped; on iOS 27 and later (native control) the Apple ID and WDA steps are too. The phone part only acts on the controlled device |
setup --reconfigure |
Set up one part again, picked from a menu: all of it, language, proxy, background service, Apple ID (sign in again and re-sign WDA), phone (pairing, Developer Mode, WDA), auto-unlock passcode, notifications, MCP registration (Claude Code, Codex) |
login [email] |
Sign in to the Apple ID (devices on WDA only). The password and code are only typed here; without an email it asks for one |
sign |
Sign and install WDA now (devices on WDA only), same as resign --force. Registers the device with the Apple ID |
resign [--force] |
Re-sign only when fewer than RESIGN_MIN_DAYS days remain; --force re-signs now. Without --force it doesn't register a device that has never had WDA |
In setup menus, use ↑/↓ to move and Enter to confirm, or type a number and press Enter. Confirmation prompts also accept ←/→. Esc dismisses the guide. Ctrl+C interrupts it with exit status 130. Both preserve saved steps. A > marker identifies the selection without relying on color. After resizing the terminal, the next key redraws the menu at the new width.
With TERM=dumb, redirected output or a terminal that is too small when the menu starts, menus use the original numbered/text prompts. Shrinking an active menu preserves its input and pauses confirmation until the window is enlarged; cancellation remains available. Setup still requires stdin to be a terminal; it cannot run unattended through a pipe. These shortcuts apply to menus only; passwords stay hidden.
Cancellation preserves saved settings and discards unsaved changes. In the full guide, language and proxy settings are saved together, so cancelling at the proxy step also discards the language choice made just before it.
Checking state
| Command | What it does |
|---|---|
status |
State, phone, how the device was chosen, time left on the profile, auto-unlock, notifications, recent log |
doctor |
Layer-by-layer checks with a fix for each failure |
Several devices
See Several Devices.
| Command | What it does |
|---|---|
devices |
Lists devices on USB; marks the controlled one and whether it has an auto-unlock passcode |
select <UDID|name|auto> |
Control another device, remembered across restarts; auto goes back to automatic choice |
Auto-unlock
See Auto-unlock. --device takes a UDID or name, and the device must be connected; without it, the controlled device is used.
| Command | What it does |
|---|---|
passcode set [--device <device>] |
Save this device's passcode and turn auto-unlock on |
passcode clear [--device <device>] |
Delete this device's passcode |
passcode clear --all |
Delete every device's passcode |
unlock-reset |
Turn auto-unlock back on after it was disabled. It doesn't check the passcode, so make sure it's right first |
Other
| Command | What it does |
|---|---|
notify-test [event] |
Send test notifications: one per event type, or one type (resign, session, pin, pin-recovered, unlock, offline, online) |
wda-bridge [--port <port>] |
Expose WDA on 127.0.0.1 (devices on WDA only) (default port 8100) for other tools. WDA has no authentication and every local user can reach it, so stop it when done |
viewer [--port <port>] [--lan] [--lan-host <name>…] [--tls auto|on|off] [--tls-cert <PEM> --tls-key <PEM>] [--mcp on|off] |
Control page in the browser, behind a login: every HTTP visit (from this machine too; one forwarded by frp or another reverse proxy looks just like it) needs the token, and viewer token shows it with links that log in; a browser stays logged in for 30 days, programs and MCP clients send Authorization: Bearer <token>. The same port also serves MCP over HTTP at /mcp (see Connect an AI Client; --mcp off turns it off). The page is at http://127.0.0.1:8200/ (default port); with --lan also at https://<this machine's address>:8200/ on the local network (same port; http:// from the network is sent to https://). The certificate is a self-signed one made on this machine (kept in viewer-tls/ in the data directory and reused), so the first time the browser warns that it isn't trusted: check that the SHA-256 fingerprint matches the one printed at startup or by service status, then go on. With a certificate of your own (--tls-cert/--tls-key: mkcert, tailscale cert…) there is no warning. With --tls off the network gets plain HTTP and the picture falls back to MJPEG (browsers only offer WebCodecs on localhost or HTTPS). The page is in English or Chinese (follows IPHONE_CONTROL_LANG, switchable on the page). Screen: the live picture works like a touchscreen: click to tap, drag to swipe, hold to long-press, scroll with the mouse wheel or trackpad, plus a text field and the hardware buttons. On iOS 27 and later the finger follows the pointer as it moves (over CoreDevice HID, which keeps the phone awake until 30 seconds after the last touch); older versions get the whole gesture on release. Everything goes through the daemon like an MCP call, so it queues with the agent and unlocks the phone first. On iOS 27 and later the picture is the phone's own video; otherwise it comes from WDA (none until WDA is ready), as H.264 or MJPEG; see Picture below. Touch is available when the frame matches the measured size and orientation. After rotating or switching devices, start a new gesture on the updated picture. Settings at the bottom of the sidebar controls the theme and text size. The picture has its own zoom controls, the − and + above it (pinching doesn't zoom, so a drag can't turn into one). Device panel: state and readiness checks, installed apps, on-screen elements. The page follows the device the daemon controls: switch on the page or anywhere else, and the picture and panels move over; see Several Devices. AI tasks: type a task and a local agent carries it out (Claude Code or Codex, whichever is on PATH; picked on the page). Before it starts you can limit it to some apps with the App button next to the agent; in any other app each step waits for you. You can pause, take over and hand back, or stop it, and it asks on the page before paying, deleting or sending messages. The token is the key: keep it to yourself. See Viewer and Remote Use |
viewer token [--new] |
Show the viewer's owner login token, links that log in on this machine and the local network, and the command to connect to its HTTP MCP; --new replaces it: browsers and MCP clients that used the old one need the new one. Tokens are kept in viewer-tokens.json in the data directory (0600); changes take effect at once, without restarting the viewer |
viewer token add <name> [--read-only], list, show <name> [--new], remove <name> |
Named tokens, one per person or device, say; the page's task log records which token paused, took over or confirmed. A --read-only token can watch the picture, the device's state and tasks; every action is refused and the page hides them. list doesn't show the tokens themselves; the last token that may operate stays |
task run [--title <title>] [--owner <name>] [--app <app>…] -- <command> |
AI tasks for other agent platforms: opens a task on the controlled device and runs the command in it. An iphone-control mcp the command starts takes part (through IPHONE_CONTROL_TASK_TOKEN): the control page shows every step and can pause, take over and stop it, and it waits for you before paying or sending a message. The task ends when the command does, with the command's exit code as its result; to write its own summary the command runs task finish [--failed] <summary>. When the task is stopped elsewhere, so is the command; Ctrl-C stops the task. --owner is who the page shows as carrying it out (default external). While a task runs, other clients can look but not act on the phone. --app (repeatable, name or bundle ID) limits the task to those apps: in any other app, or to open a link that isn't a web page, each step waits for you first. With the phone on another machine, add --url https://<that machine>:8200 (and --ca cert.pem for a self-signed certificate) and put the login token in IPHONE_CONTROL_VIEWER_TOKEN: the task is opened through that machine's viewer, and the command gets the task's token and IPHONE_CONTROL_MCP_URL, for its agent to connect to MCP over HTTP (see Connect an AI Client). The login token isn't passed to the command, so the agent can't pause or confirm its own task; task finish in the command works as usual |
task list / task events <id> |
Recent tasks (--json for programs); follow a task's events, one JSON per line |
task pause|resume|takeover|handback|stop <id>, task approve|reject <id> [--step <n>] |
Control a task from the command line, like the buttons on the control page; --step answers only that step's confirmation. Only for a person: from inside the task (the agent's environment or a process it started) they are refused, except stop. Every task subcommand (list and events too) takes --url <viewer> [--ca <PEM>] (or IPHONE_CONTROL_URL) to work on another machine's phone through its viewer, with the login token in IPHONE_CONTROL_VIEWER_TOKEN; a command under task run --url has no login, so an agent is refused there as well |
The debug subcommand for diagnostics isn't compiled by default; see the contributing guide.
Notes
- Need the daemon running: the phone part of
setup,status,doctor,sign,resign,devices,select,unlock-reset,wda-bridge,viewer,task, and MCP tool calls. - Need an interactive terminal:
iphone-controlwith no command (the first time),setup,login,passcode set. - Settings: every command except
completionsreads~/.config/iphone-control/envwhen it starts; a variable already in the environment wins. See Configuration.
The control page's picture {#viewer-picture}
iOS 27 and later: the picture is the phone's own hardware-encoded video (the CoreDevice screen media stream, HEVC), about 60 frames a second at native resolution; nothing is encoded on this machine and WDA doesn't capture anything. It takes 150–600 KB/s while scrolling, and a little even on a still screen (about 15 KB/s on a white page, 250 KB/s on a busy one). When the screen turns, the page turns the picture with it within about 1–2 seconds. The browser has to decode HEVC: Chrome and Safari on a Mac can; Firefox and Chrome on most Linux machines can't and fall back to H.264 or MJPEG as below. While you watch, the phone doesn't auto-lock and the Dynamic Island shows it is being viewed; that ends 30 seconds after the page closes.
Below iOS 27, or a browser without HEVC: On macOS, and on Linux with ffmpeg installed, the control page's picture is H.264; otherwise MJPEG. The phone's picture is encoded on this machine (on macOS by VideoToolbox, called by this program, no ffmpeg needed; on Linux by ffmpeg) and decoded in the browser with WebCodecs (the browser picks hardware decoding itself). For the same picture it is about 1/15 of MJPEG's traffic: next to nothing on a still screen and about 300–450 KB/s while scrolling, against 4–10 MB/s for MJPEG. The delay is within a frame of MJPEG's.
- Encoder:
viewertries them in order when it starts, uses the first that works and says which in the terminal: NVENC on NVIDIA; VAAPI on AMD and Intel (the JPEG is decoded by the GPU too); QSV on Intel as well; V4L2 on ARM boards such as the Raspberry Pi; VideoToolbox on macOS (called directly, the JPEG decoded by the hardware too; with ffmpeg installed, its VideoToolbox is the fallback); otherwise x264 in software (uses the CPU). One that fails on the real picture is replaced by the next. On Linux the user must be in therendergroup to use the GPU;doctorchecks it. - Slow links: the page tells viewer every 100 ms how much it has received. When the link can't keep up, fewer frames are encoded: the frame rate drops, but the picture doesn't fall further and further behind. On a 200 KB/s link, for example, the picture catches up about 0.6 s after scrolling stops.
- Falling back to MJPEG: on Linux without ffmpeg, without a working encoder, or in a browser without WebCodecs (older ones), the page uses MJPEG. It no longer repeats the same frame while the screen is still, and on a slow link it only sends the newest frame.
- Low-bandwidth mode: a switch in the control page's Settings, for use over the internet or a weak signal. About half the picture's traffic at the same frame rate; a still screen looks the same, while things move edges get a little blocky, clear again about half a second after they stop. The phone's own video (HEVC) is one stream per phone, its bitrate cap agreed with the phone when it starts, so while the mode is on every page watching that phone gets it (a 6 Mbit/s cap becomes 2 Mbit/s), and the first page to turn it on and the last to turn it off interrupt everyone's picture for about half a second and end a touch under way. H.264 only changes for the page that turned it on (qp 26). While it is on, the line under the picture says "Low-bandwidth mode".
- Which one is in use: shown under the picture, e.g. "Live · Native · HEVC iPhone 312 KB/s" (native control, the phone's own video), "Live · WDA · HEVC iPhone 312 KB/s" or "Live · WDA · H.264 VAAPI 254 KB/s".
- Settings:
IPHONE_CONTROL_VIEWER_CODEC(device: only the phone's own video,mjpeg: only MJPEG),IPHONE_CONTROL_VIEWER_QP,ICTL_FFMPEG, see Configuration. On Linux install ffmpeg withsudo apt install ffmpeg; the .deb recommends it. Nothing to install on macOS.