Karagöz
v0.5.1Device automation for Android emulators and phones, iOS simulators and iPhones.
Device automation for mobile apps. One tool for four targets: Android emulator, Android physical device, iOS simulator, iOS physical device. It is a CLI, and karagoz mcp serves the same commands to an AI agent as an MCP server. adb, simctl and devicectl run the command; karagoz tells you what the command actually did. karagoz is the primitive layer. Each command does one thing and exits.
Summary extracted from the README.
Karagöz
Device automation for mobile apps. One tool for four targets: Android emulator, Android physical device, iOS simulator, iOS physical device. It is a CLI, and karagoz mcp serves the same commands to an AI agent as an MCP server.
Contents
- Why karagoz
- Scope
- Status
- Guides
- Getting started
- MCP server
- Things to ask your agent
- Commands
- Output and errors
- How it works
- FAQ
- Contributing
- License
Why karagoz
adb, simctl and devicectl run the command; karagoz tells you what the command actually did.
- What happened, as a code.
am force-stopon an app that is not installed says nothing,simctlanddevicectlreport success for uninstalling an app that is not there, and Android answers a missing package with the code it gives a package it will not remove. karagoz checks first and returnsAPP_NOT_FOUND. A refused install isINSTALL_FAILEDwith the platform's own code inreason, not text to parse. - One contract on four targets. The same commands, flags, device selection, output and error codes on an Android emulator, an Android phone, an iOS simulator and an iPhone. The MCP server returns the CLI's JSON line unchanged.
- The accessibility tree first. To see the screen, read
ui-treebefore taking a screenshot. The tree is text a program can search, costs a few hundred to a few thousand tokens, and gives the bounds needed to tap. A screenshot is written to disk at full resolution and returned as a path, with its pixel size, logical size and scale (and safe area on Android) to measure against; the CLI never prints the image. - It installs only what you ask and starts no daemon of its own. Each command exits when it answers, and
karagoz mcpexits with its client. Only karagoz's runner stays up between calls, and it stops 10 minutes after its last use. The one thing karagoz installs unasked is that runner, on a simulator of a Mac that never had Xcode 27 (FAQ).
Scope
karagoz is the primitive layer. Each command does one thing and exits.
- Not a test framework. No assertions, no test runner, no recorded flows, no retry policy, no reports.
tap --timeoutwaits for a node to appear; it never repeats an action. - Not a design comparison tool. Figma diffing, measurement and reporting belong a layer above. karagoz produces the raw input, and the metadata to measure it with, but does not interpret it.
Status
Early development. Every command runs on all four targets, except install-runner, which runs only on iPhones, and uninstall-runner, which runs on iPhones and on simulators of a Mac that never had Xcode 27. For Windows and Linux, see the FAQ.
Guides
The website has a guide for each of these tasks:
- Let Claude Code control an Android emulator
- Read an Android screen as JSON and tap by text
- Drive an iOS simulator from the command line
- Let an AI agent drive a real iPhone
Getting started
Requirements
- Node 22 or newer.
- Android:
adbfrom Android platform-tools, and a running emulator or a phone with USB debugging on. - iOS simulator (macOS): Xcode, opened once, and a booted simulator.
tap,long-press,double-tap,swipe,textandkeyneed Xcode 27 or newer, or a Mac that never had Xcode 27, where they go through karagoz's runner. - iPhone (macOS): Xcode 15 or newer (27 for
screenshot) and the iPhone paired with the Mac.screenshot,install,launch,open-url,terminateanduninstallneed Developer Mode on, andlogsneeds a USB cable.ui-treeand the input commands need both, plus UI Automation on and karagoz's runner, whichinstall-runnerinstalls.
What each command needs, and how karagoz finds adb and Xcode.
Install
npm install -g karagoz-mcp
karagoz devices
Or without installing: npx -y karagoz-mcp devices. To build from source: Development.
Quick start
$ karagoz devices
Found 1 device:
Medium_Phone_API_37.0 • emulator-5554 • emulator • Android 17 (API 37) • device
Missing a device? Run karagoz doctor.
When stdout is not a terminal, as in a pipe or Claude Code's shell, every command prints one line of JSON, shown here; at a terminal the other commands indent it.
$ karagoz tap --text Chrome
{"device":"emulator-5554","x":667.5,"y":2002.5,"element":{"class":"android.widget.TextView","text":"Chrome","contentDesc":"Chrome","clickable":true,"longClickable":true,"focusable":true,"bounds":[581,1905,754,2100]}}
$ karagoz key HOME
{"device":"emulator-5554","key":"KEYCODE_HOME","code":3}
$ karagoz screenshot --out home.png
{"path":"/Users/me/home.png","device":"emulator-5554","pixels":{"width":1080,"height":2400},"logical":{"width":411.42857142857144,"height":914.2857142857143},"scale":2.625,"safeArea":{"top":63,"right":0,"bottom":63,"left":0},"rotation":0}
karagoz ui-tree prints the screen's accessibility tree; tap --text above found its target in that tree.
Claude Code with the MCP server on an iOS simulator, in real time. The right side lists each karagoz call and part of the JSON it returned.

MCP server
karagoz mcp
Starts an MCP server for an AI agent on stdin and stdout. It opens no port: the client starts the process and talks to it over stdio. The 18 commands are its tools, and each tool returns the JSON line the CLI prints.
Claude Code
claude mcp add karagoz -- npx -y karagoz-mcp mcp
Claude Desktop
Download karagoz.mcpb from the latest release and open it. Desktop installs it as an extension.
Cursor
Or in .cursor/mcp.json:
{"mcpServers":{"karagoz":{"type":"stdio","command":"npx","args":["-y","karagoz-mcp","mcp"]}}}
VS Code
In .vscode/mcp.json:
{"servers":{"karagoz":{"type":"stdio","command":"npx","args":["-y","karagoz-mcp","mcp"]}}}
Codex
codex mcp add karagoz -- npx -y karagoz-mcp mcp
Then add these two lines under [mcp_servers.karagoz] in ~/.codex/config.toml. The command cannot write them, and without them Codex hides ANDROID_HOME from karagoz and cuts long calls short:
env_vars = ["ANDROID_HOME", "ANDROID_SDK_ROOT", "KARAGOZ_DEVICE", "ANDROID_SERIAL", "DEVELOPER_DIR"]
tool_timeout_sec = 600
Agent instructions
Optional. Add this to your CLAUDE.md, AGENTS.md or your agent's rules, or ask your agent to add it, and it uses karagoz for a request about a device without being told to:
## Mobile devices
For anything on an Android emulator or phone, an iOS simulator or an iPhone (reading the screen, tapping, typing, screenshots, installing or launching an app, logs), use karagoz instead of calling adb, xcrun simctl, devicectl or xcodebuild yourself. Use the karagoz MCP tools when they are available; otherwise run `npx -y karagoz-mcp <command>`. Read the screen with ui-tree before taking a screenshot, tap by text or id, and branch on error.code.
Token cost
What the server adds to a Claude Code session, measured on 2026-11-21 with Claude Code 2.1.325 and claude-opus-5-5: input tokens of the first API call with karagoz registered, minus the same call with no MCP server.
| Case | Tokens |
|---|---|
Every session, tool search on (the default): the 18 tool names and instructions |
386 |
All 18 definitions, loaded by one ToolSearch call |
3,958 |
Every session, tool search off (ENABLE_TOOL_SEARCH=false): every definition and instructions |
3,816 |
The tools/list result is 10,471 characters, instructions 459. One ui_tree of the launcher home screen is 5,127 characters (11,767 with detail: full).
Things to ask your agent
Once the server is registered, describe the task to your agent. It reads the screen with ui_tree and calls one tool per step.
- "Open Settings on the emulator and turn on dark mode."
- "Install
./build/app-debug.apk, open it, and tell me what the first screen shows." - "On the sign-in screen, type
test@example.cominto the email field and tap Continue." - "Open
myapp://orders/42on the iOS simulator and take a screenshot." - "The app closes right after launch on the emulator. Show me its last 50 log lines."
Commands
| Command | Does |
|---|---|
devices |
List connected devices |
screenshot |
Save a full-resolution PNG and return its path with scale metadata |
ui-tree |
Return the accessibility tree of the focused window |
tap |
Tap a point, or a node found by text or id |
long-press |
Press and hold a point or a node |
double-tap |
Tap a point or a node twice |
swipe |
Swipe between two points |
text |
Type text into the focused field |
key |
Press a key |
install |
Install or replace an app |
launch |
Start an app as its launcher icon does |
open-url |
Open a URL or deep link in the app that handles it |
terminate |
Stop every process of an app |
uninstall |
Remove an app |
logs |
Read the device log |
doctor |
Report which adb and Xcode karagoz uses |
install-runner |
Build karagoz's runner and install it on an iPhone |
uninstall-runner |
Remove karagoz's runner from an iPhone or a simulator |
mcp |
Start the MCP server on stdio |
Every command except devices, doctor and mcp works on one device. When more than one is listed, pick it with --device <id or name> or KARAGOZ_DEVICE: Device selection.
Output and errors
Every command prints one line of JSON on stdout: its result with exit code 0, or {"error":{"code":"<CODE>","message":"<text>"}} with exit code 1. Branch on error.code, not on the message. At a terminal, devices and doctor print a summary instead and the other commands indent their JSON; when stdout is not a terminal, as in a pipe, the line is printed.
Output, arguments and coordinates · Error codes · Known limitations
How it works
A command finds the device, runs the platform's own tool for the job, and turns the answer into one JSON line. karagoz mcp calls the same code.
| Target | Screen | Accessibility tree | Input | Apps | Logs |
|---|---|---|---|---|---|
| Android emulator and phone | adb screencap |
uiautomator dump |
input; text outside ASCII and double-tap through a helper copied to the device for the call |
adb install, am, pm, cmd package |
logcat |
| iOS simulator | simctl io screenshot |
karagoz's Swift helper, compiled on first use with Xcode's swiftc |
The helper: the simulator's input service, and XCUIAutomation for text (Xcode 27). On a Mac that never had Xcode 27, karagoz's runner inside the simulator |
simctl |
log show inside the simulator |
| iPhone | devicectl |
karagoz's runner, an XCUITest bundle that xcodebuild starts and karagoz reaches over USB |
karagoz's runner | devicectl |
The phone's log relay over USB, read with macOS's log |
FAQ
Nothing by itself, with one exception: on a Mac that never had Xcode 27, the first tap, long-press, double-tap, swipe, text or key on a simulator installs karagoz's runner there (Requirements). Typing text outside ASCII on Android copies a small helper to /data/local/tmp and deletes it when the call ends (text).
A Mac with Xcode and the iPhone paired. Screenshots and app commands such as install need Developer Mode on, and logs needs a USB cable. ui-tree and input need both, plus UI Automation on and karagoz's runner, installed once with install-runner. A free Apple ID signs the runner for 7 days (Known limitations).
The tree answers most questions about a screen as text. karagoz keeps the PNG at full resolution on disk, with the scale needed to measure against it. Over MCP, inline: true also returns the image, which the client scales down, so take coordinates from the tree (MCP results).
iOS targets need macOS. Android targets need only Node and adb, and karagoz looks for adb in the Windows and Linux SDK folders too. No device command has been run on either system yet. On Linux, CI runs the type check, lint, build and the smoke tests that need no device.
On Android only one UiAutomation client can be connected, so ui-tree, and a tap by --text or --id, return AUTOMATION_BUSY while another holds it. On an iOS simulator, text fails the same way while a UI test runs (Error codes).
Contributing
Bug reports and pull requests are welcome. CONTRIBUTING.md covers what to put in an issue, the checks a pull request needs, and what device data must never be posted.
License
MIT © 2026 Yılmaz Yağız Dokumacı