iphone-safari-mcp
Automates Safari on a physically attached iPhone, providing tools for navigation, screenshots, DOM snapshots, element interaction (click, type, tap, scroll), JavaScript evaluation, console log capture, and network timing analysis.
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., "@iphone-safari-mcp Screenshot https://example.com and get console logs"
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.
iphone-safari-mcp
An MCP server that drives Safari on a physically attached iPhone through Apple's
safaridriver (platformName: "ios"). No Xcode, no Appium, no WebDriverAgent.
Gives a coding agent the closed loop: navigate → screenshot + DOM snapshot + console + network timings → click/type/tap/scroll → repeat, all on the real device.
Prerequisites
On the iPhone — Settings → Apps → Safari → Advanced:
Web Inspector: ON
Remote Automation: ON
On the Mac, once:
safaridriver --enableAt session time the phone must be plugged in, unlocked, and trusted. Only one WebDriver session can exist at a time — close any Selenium script or Web Inspector automation session first.
Related MCP server: Safari Web Inspector Bridge
Install
Needs uv. Nothing else — uv fetches Python and the dependencies itself.
Run it straight from the repo, no clone and no venv:
uvx --from git+https://github.com/ikatkov/iphone-safari-mcp \
iphone-safari-mcp --selftest https://example.comOr work on it locally:
git clone https://github.com/ikatkov/iphone-safari-mcp
cd iphone-safari-mcp
uv sync # resolves dependencies into .venv
uv run iphone-safari-mcp --selftest https://example.comThe selftest prints the user agent (should say iPhone), writes
/tmp/iphone-safari-selftest.png, and reports how many interactive elements it found.
--help lists everything.
The examples below use uv run iphone-safari-mcp (from a clone); every one of them
works with the uvx --from git+… form too.
How it talks to safaridriver
The server starts one long-lived safaridriver and reuses it, rather than letting
Selenium spawn a throwaway one per session.
This matters. safaridriver needs several seconds after launch to enumerate USB
devices. Selenium's webdriver.Safari() spawns a fresh driver and fires New Session
immediately — which lands inside that window, when the attached iPhone is still
invisible and only already-cached network-paired devices exist. The symptom is baffling:
session creation fails naming some other household device, and your cabled phone is
absent from the list entirely while sitting right there in Safari → Develop.
So session creation also retries for IPHONE_SAFARI_DISCOVERY_TIMEOUT seconds
(default 45) instead of failing on the first miss.
To debug discovery, run your own driver and attach to it:
safaridriver --diagnose -p 4444 # logs to ~/Library/Logs/com.apple.WebDriver/
IPHONE_SAFARI_DRIVER_URL=http://localhost:4444 uv run iphone-safari-mcp --verifyPick the right phone
safaridriver will use any paired host that matches, including devices paired over
the network that you never plugged in. Always pin the device:
uv run iphone-safari-mcp --list-devices # what safaridriver can see, and why each was rejected
uv run iphone-safari-mcp --device "My iPhone" --selftest https://example.comFor the MCP server, pin it with an env var — IPHONE_SAFARI_DEVICE_NAME,
IPHONE_SAFARI_DEVICE_UDID, or IPHONE_SAFARI_DEVICE_TYPE. UDID is the robust choice
since names change. session_info reports both what you pinned and what you got.
A device missing from --list-devices entirely is not paired — check the cable, tap
Trust, and confirm it appears under Safari → Develop on the Mac. A device that is
listed but rejected tells you the reason ("Web Inspector is not enabled on device").
Register with Claude Code
Verify before you register. Other household devices pair too, and a wrong pin fails
silently — it just drives someone else's phone. --verify paints a large random code on
whatever screen it actually controls:
uv run iphone-safari-mcp --verify --device "My iPhone"Only register once the code appears on the phone you intend to drive:
claude mcp add iphone-safari --scope user \
-e IPHONE_SAFARI_DEVICE_UDID=<udid confirmed by --verify> \
-- uvx --from git+https://github.com/ikatkov/iphone-safari-mcp iphone-safari-mcpThat pins nothing to this directory — the agent can launch it from anywhere. uv caches the environment, so only the first start needs the network.
To run your own checkout instead, point uv at it by absolute path, since the agent won't launch from this directory:
claude mcp add iphone-safari --scope user \
-e IPHONE_SAFARI_DEVICE_UDID=<udid confirmed by --verify> \
-- uv run --directory /abs/path/to/iphone-safari-mcp iphone-safari-mcpPrefer the UDID over the name: --verify prints the UDID that safaridriver actually
bound to, and unlike names it can't drift or collide.
Run this from a real terminal with Claude Code closed — it rewrites ~/.claude.json
on exit and will clobber the edit otherwise.
Then in a session: "Use iphone-safari. Report what device you're connected to, open http://localhost:5173, screenshot it and list any console errors."
Tools
Tool | Purpose |
| Confirm you're on the iPhone, not Mac Safari — user agent, viewport, DPR |
| Open a URL and arm console capture |
| Downscaled PNG of the viewport |
| Start here. URL, viewport, scroll, and every visible interactive element with a CSS selector, label and rect |
| Raw HTML, truncated |
| Act on an element by |
| Real single-finger touch at viewport coordinates |
| Scroll by pixel delta |
| Run JS in the page |
| Console + uncaught errors + rejections |
| Resource timings; |
| Session control |
Prefer snapshot over page_source — it's a fraction of the tokens and gives you
selectors you can act on directly.
Limits
Apple's Safari WebDriver is deliberately web-content automation, not device automation. No Home screen, Settings, app switching, rotation, or system dialogs — Apple calls general device automation a non-goal. If you need those, use mobile-next/mobile-mcp, which drives the whole device but requires go-ios + WebDriverAgent provisioned onto the phone.
Safari 27 / STP 247+ ship an MCP server inside safaridriver itself
(safaridriver --mcp), but as of Safari 26.2 that flag does not exist, and Apple only
documents it against Safari on the Mac.
Available Tools
16 toolsclickC
Click/tap an element. by is one of css, xpath, text.
Inputs: selector (required), by.
close_sessionA
End the automation session on the phone. A later call reconnects automatically.
Inputs: no named parameters. Returns: result
console_logsA
Console messages and uncaught errors captured since the last navigation.
The capture hook is installed by navigate(); if a page navigated itself, call install_console_capture() to re-arm it.
Inputs: clear.
evaluate_javascriptA
Run JavaScript in the page and return the result as a string.
Wrap in return ... to get a value back, e.g. return document.title;
Inputs: code (required). Returns: result
go_backA
Navigate back in Safari's history.
Inputs: no named parameters.
install_console_captureA
(Re)install the console/error capture hook on the current page.
Inputs: no named parameters. Returns: result
network_timingsB
Resource timings from the Performance API — URL, type, duration, transfer size.
A zero transferSize on a non-cached entry usually means the request failed.
Inputs: max_entries.
page_sourceA
Raw HTML of the current page, truncated to max_chars.
Inputs: max_chars. Returns: result
reload_pageA
Reload the current page and re-arm console capture.
Inputs: no named parameters.
screenshotC
Screenshot the current iPhone Safari viewport.
Inputs: max_width.
scrollA
Scroll the page by a pixel delta. Positive dy scrolls down.
Inputs: dx, dy.
session_infoA
Report what device/browser this session is actually attached to.
Use this first to confirm you are driving the real iPhone and not Mac Safari.
Inputs: no named parameters.
snapshotA
Compact structured view of the page: URL, viewport, scroll position, and every visible interactive element with a CSS selector, label and on-screen rect.
Prefer this over page_source() — it is the cheap way to decide what to click.
Inputs: no named parameters.
tapA
Send a real single-finger touch at viewport coordinates (CSS pixels).
Use when there is no sensible selector — e.g. a canvas or a custom overlay.
Inputs: x (required), y (required).
type_textA
Type into an input on the phone, optionally clearing it first or submitting the form.
Inputs: text (required), selector (required), by, clear, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 16 tools
Every tool has a clearly distinct purpose: navigate vs. reload_page vs. go_back are separate navigation actions; click vs. tap distinguish element-based from coordinate-based interaction; screenshot, snapshot, and page_source each offer a different view of the page. There is no meaningful overlap that would cause an agent to misselect.
Most tool names follow a verb_noun pattern (navigate, reload_page, evaluate_javascript, install_console_capture), with a few single-verb commands (click, tap, scroll) and noun-like names (screenshot, snapshot, page_source) that act as commands. All names are lowercase snake_case, which keeps the set predictable and readable despite minor pattern deviations.
With 16 tools, this server sits just above the ideal 3-15 range, but each tool covers a distinct aspect of mobile browser automation—navigation, interaction, inspection, and session control. The count is justified by the breadth of features needed for iPhone Safari and does not feel bloated or redundant.
The tool set covers the core lifecycle of a browsing session: navigate, go_back, reload, click/tap/scroll/type, extract page data (snapshot, page_source, screenshot), execute JS, and capture console/network diagnostics. Minor gaps exist (e.g., no explicit wait-for-element or cookie management), but they are workable and the server is functionally complete for typical automation tasks.
Maintenance
Related MCP Connectors
MCP server to assist with JxBrowser development.
Hosted real Google Chrome MCP with per-user persistent state. Navigate, click, type, screenshot.
A remote MCP server to convert HTML documents (URL or raw source) to PDF or screenshots
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceMCP server that connects to your browser to capture screenshots, inspect console logs, network requests, and more via Chrome DevTools Protocol.2-
- AlicenseAqualityDmaintenanceAn MCP server that gives AI agents the ability to inspect, observe, and automate WKWebViews on connected iOS devices via Safari Web Inspector.141MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server for headless mobile QA automation that controls real Safari, Flutter, and native iOS apps on Xcode Simulators via WebKit Remote Debugging Protocol, enabling parallel multi-device testing and persistent login sessions.16MIT
- AlicenseBqualityCmaintenanceLocal, multi-session MCP server driving real Chrome, Chromium, WebKit, and Safari engines, with attach-to-running-Chrome support, no API keys or cloud required.10MIT