How to Let OpenAI Codex Use a Real iPhone (MCP Setup, No Jailbreak)
Codex is good at working through a task step by step on your computer. Some tasks, though, only exist on a phone: an app with no web version, a flow you want to check on a real device, a setting buried three screens deep
Codex is good at working through a task step by step on your computer. Some tasks, though, only exist on a phone: an app with no web version, a flow you want to check on a real device, a setting buried three screens deep. This guide shows how to give Codex a real iPhone to work on, using one local MCP server.
The phone stays stock. No jailbreak, no Xcode, no developer account.
How it works
The MCP server is the Manina AI CLI, esp32agent, which is open source in the esp32-iphone-agent repo (MIT). It talks to a small Seeed Studio XIAO ESP32S3 board plugged into the iPhone:
- Eyes: the board shows up in the iPhone's Screen Mirroring list as ESP32 Agent and receives the picture.
- Hands: to the iPhone, the board is a plain mouse and keyboard. With AssistiveTouch on, a click is a tap and a drag is a swipe.
- Brain: Codex. The CLI only provides the phone controls; Codex decides what to do and uses its own model.
Your computer reaches the board over Bluetooth, or over your Wi-Fi if you put the board on it.
What you need
- A standard Seeed Studio XIAO ESP32S3 (8 MB flash, 8 MB PSRAM) with its antenna attached. Not the Sense or Plus versions.
- Board firmware v0.2.2 or later. Flash it from Chrome or Edge with the browser installer.
- An iPhone XS or newer on iOS 18, or an iPhone 8 / X on iOS 16.4+, with cellular data.
- A computer with Bluetooth where Codex runs. Screenshots also need ffmpeg.
1. Install the CLI
macOS or Linux:
curl -fsSL https://manina.ai/install.sh | sh
Windows PowerShell:
irm https://manina.ai/install.ps1 | iex
Or with Node.js 18+:
npm install -g esp32agent
The shell installer puts the binary in ~/.local/bin, so make sure that's on your PATH. If esp32agent isn't found afterwards, reopen your terminal.
2. Pair the board
Plug the board into the iPhone. Then, within three minutes of powering it, run:
esp32agent devices
esp32agent pair
pair finds and pairs a single nearby board by itself, so you don't need to pair it in your computer's Bluetooth settings first. If several boards show up, pass the identifier from devices: esp32agent pair --device <id>. Missed the three-minute window? Unplug the board, plug it back in, and retry.
Pairing happens in the terminal only. The MCP tools don't do discovery or pairing, so finish this step before you open Codex.
3. Let it see and tap
On the iPhone:
-
Join the board's hotspot in Settings → Wi-Fi. It's named
ESP32Agent-…. With firmware v0.2.3 or later,esp32agent netshows the name and password. - Start mirroring: Control Center → Screen Mirroring → ESP32 Agent.
- Turn on AssistiveTouch: Settings → Accessibility → Touch → AssistiveTouch. Keep the pointer visible, and keep the phone unlocked and in portrait.
The phone keeps using cellular data for the internet while its Wi-Fi is the board's hotspot.
Now check it from the computer:
esp32agent device info
esp32agent screenshot
esp32agent calibrate
screenshot saves a PNG and prints its filePath. Open it and make sure it shows the phone's current screen. If it's stale, stop Screen Mirroring and start it again. calibrate measures the pointer. It also runs by itself on the first tap if needed.
Optional: put the board on your Wi-Fi
Over Bluetooth, screenshots can be about a second behind. If the board and your computer share a Wi-Fi network, commands and video go over Wi-Fi instead: screenshots are close to live and taps don't queue behind video.
esp32agent net join
It asks for your Wi-Fi name and password, then tells you to join the same Wi-Fi on the iPhone and restart Screen Mirroring. esp32agent net shows which link is in use (via: wifi or ble). esp32agent net hotspot puts the board back on its own hotspot. This needs firmware v0.2.3 or later. The board is 2.4 GHz only, and routers with client isolation can hide it from Screen Mirroring. The hotspot always works.
4. Add the MCP server to Codex
One command:
codex mcp add esp32agent -- esp32agent mcp
Codex now has these tools: screenshot, tap, longpress, swipe, type_text, press_key, press_button, device_info, history, intent_list, intent_show and intent_save.
If you'd rather run it through npx than a global install, the command is npx -y esp32agent mcp.
5. Give it a small first task
Start with something boring and easy to check. Paste this into Codex:
Use esp32agent to take a screenshot of my iPhone. Open Settings and go to Wi-Fi. Take a fresh screenshot after each action to check the result. Stop when the Wi-Fi page is visible.
What you want to see is a loop: look → one action → look again. Watch the first run, and interrupt Codex if it starts guessing without a fresh screenshot.
Once that works, try something with a few more steps:
Use esp32agent to open Chrome in incognito mode on my iPhone, visit the Google Maps website, and find coffee near East Broadway station in New York. Check a fresh screenshot after each action and stop when the map and café results are visible.
That prompt has the three things that make phone tasks go well: where to go, how to check each step, and what counts as done.
Tips that save time
- Coordinates are screenshot pixels. Taps and swipes use pixels from the original screenshot, not percentages. Have Codex take a fresh screenshot before each tap.
-
Small targets? The CLI's
io tap X,Y --aimfinds the pointer first, then taps. Useful when Codex keeps just missing a button. - Opening apps: the CLI can't launch or install apps directly. Codex has to go through the Home Screen or search, same as you would. HOME is the only hardware button.
- Typing: text is ASCII, one key per character. Chinese goes through the iPhone's Pinyin keyboard, so enable that keyboard first and have Codex check the text on screen.
-
One driver at a time: if the ESP32 Agent iPhone app is running a task, CLI commands answer
busy. -
Every command prints JSON (
{"status":"ok",...}or{"status":"error",...}with exit code 1), so you or Codex can also script the CLI directly in a shell.
Turn a good run into a reusable task
When Codex gets a task right, you don't have to explain it again next time. Saved tasks are called intents. Codex can save one with the intent_save tool, or you can do it from the terminal:
esp32agent history list
esp32agent intent save --name wifi-check --prompt "Open Settings and go to Wi-Fi" --from-run latest
esp32agent intent list
--from-run keeps that run's steps so they can be replayed, and --steps 1,3,4 keeps only the ones you want. esp32agent intent export writes an .esp32intent file the iPhone app can import, so the same task can run on the phone alone and start from Siri or Shortcuts.
Things iOS won't show the agent
Some screens never reach Screen Mirroring: passcode entry, Apple Pay and DRM video. The agent can't see them, so plan for a human step there. Mirroring also stops when the phone locks, and iPhone landscape apps aren't supported yet.
Privacy and responsible use
Screenshots go to whatever model Codex uses, so check its data policy before working in personal accounts. Only automate devices and accounts you own or are allowed to control, and stay close to the stop button for the first few runs.
Wrap-up
Install the CLI, pair the board, mirror the screen, then run codex mcp add esp32agent -- esp32agent mcp. That's the whole bridge. From there, the quality of a run mostly comes down to the prompt: a clear destination, a fresh screenshot after every action, and a clear finish line.
The full command list, Wi-Fi link details and logs are in the CLI & AI agents guide. The same MCP server also works in Claude Code and other MCP clients, and the source is on GitHub.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.