Skip to content

About

MCP server that drives apps and games on Android emulators, iOS / tvOS / visionOS simulators and the Mac

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

One game driven on an Android emulator and on iOS, tvOS and visionOS simulators

virtual-device-mcp

Let an AI agent see, touch and test your app on virtual devices.
An MCP server for Android emulators, iOS / tvOS / visionOS simulators and apps on the Mac.

npm version CI MIT license Node 24 or newer macOS No dependencies

Install · Tools · Command line · How it works · Verified


Claude (or any MCP client, or a plain script) takes screenshots, touches the screen by position, presses keys and controller buttons, presses system popups by their label, reads logs, records video, and starts and stops the virtual devices itself. Point it at a build and ask it to try the app and report what breaks.

  • Works with any app. Nothing is added to the app under test: no SDK, no test hooks. Unity games, other engines and ordinary apps are driven the same way.
  • Five targets, one set of tools. Android emulator, iOS, tvOS and visionOS simulators, and macOS apps.
  • Positions are fractions of the screenshot, so one script fits every screen size.
  • System popups by name. tap_element label=Allow answers a permission request.
  • Zero dependencies. Node, Xcode and the Android SDK you already have; everything else is in this repository.
  • Virtual devices only. A real phone on USB is never listed and never touched.
A script playing a game on the iOS simulator through the tools A game played through the tools.

A small script reads each screenshot, finds the traffic and calls tap to change lane, on an iOS simulator. The same loop ran on an Android emulator, on Apple TV through the virtual controller, and on Apple Vision Pro.

screenshot → decide → tap, about 0.6 s per turn.

Install

Requirements: macOS, Node 24 or newer, Xcode 27 (for simulators), and the Android SDK (for emulators; found through ANDROID_HOME or ~/Library/Android/sdk). There are no npm dependencies.

Add it to Claude Code, for every project on this machine:

claude mcp add --scope user virtual-device -- npx -y virtual-device-mcp mcp

--scope decides where the server is available:

Scope Available in Stored in
user every project of yours on this machine your Claude Code user settings
local (the default when --scope is left out) only the folder you ran the command in, only for you your Claude Code user settings, under that folder's path
project that project, for everyone who checks it out .mcp.json in the project, meant to be committed

A virtual-device server is a tool of the machine rather than of one project, so user is the usual choice. Use project to share it with a team working on the same app.

Any other MCP client: run npx -y virtual-device-mcp mcp as a stdio server.

From a checkout instead of npm:

git clone https://github.com/Bitfaring/virtual-device-mcp.git
claude mcp add --scope user virtual-device -- node /path/to/virtual-device-mcp/src/server.ts

Permissions (System Settings > Privacy & Security), for the terminal or app that runs the server:

  • Accessibility: needed for apps on the Mac and for touches on Apple Vision Pro (both post mouse events).
  • Screen Recording: needed for screenshots and video of apps on the Mac.

Android emulators and iOS / tvOS simulators need no permission.

The first call on a simulator takes about 30 seconds: the server builds its XCUITest agent with xcodebuild and starts it. The small native helpers are compiled on first use too. Everything is cached in ~/Library/Caches/VirtualDeviceMCP.

Tools

Tool What it does
devices List the virtual devices and whether they are running
device_start, device_stop Boot / shut down an emulator or simulator
screenshot The screen (on the Mac: the app's window), scaled to 1280 px on its long edge; maxSize=0 keeps full resolution
tap Touch a position; holdMs for a long press
swipe Drag one finger from one position to another
pinch Two fingers: spread, pinch and / or rotate (Android: anywhere; iOS: around the centre of the screen)
key Keys and hardware buttons: arrows, enter, back, home; the Apple TV remote
gamepad Buttons of a virtual game controller on a simulator: d-pad, a b x y, menu, options, l1 r1 l2 r2
type_text Type into the focused text field
ui_elements The labelled native elements on screen (system popups, dialogs, ads, native controls) with their positions
tap_element Press an element by its label, for example Allow
app_install, app_launch, app_stop Install, start, quit an app
app_reset Back to first-launch state, so first-run popups show again (deletes the app's data on that device)
logs Recent log lines of the device or of one app, filtered by a regular expression
record_start, record_stop Record a video of the screen (Android: .webm, simulators: .mp4, Mac: .mov)
playtest A whole smoke test in one call: reset, launch, press through system popups, run your steps, background and return, scan the log; returns a report with a screenshot per step

Positions are always fractions of the screenshot: x=0, y=0 is the top left corner, x=1, y=1 the bottom right. The same script works on any screen size.

tap, swipe, pinch, key, gamepad, tap_element and app_launch take screenshotAfterMs: wait, then return a screenshot too, so one call both acts and shows the result.

A game that draws its own UI (Unity, for example) has no labelled elements: look at the screenshot and tap by position. ui_elements and tap_element are for what the system or native toolkits draw.

Example prompts

  • "Boot an iPhone simulator, install Build/MyGame.app, launch it, allow notifications, play one round and tell me about any exception in the log."
  • "Run a playtest of com.example.game on the Android emulator: tap START, wait 5 seconds, and show me each screen."

Command line

The same tools without an MCP client, for scripts and for trying things by hand:

npx virtual-device-mcp devices
npx virtual-device-mcp app_launch device="Medium_Phone_API_37.0" app=com.example.game
npx virtual-device-mcp tap device=<id> x=0.5 y=0.87 screenshotAfterMs=800 --out after.png
npx virtual-device-mcp tap_element device=<id> label=Allow
npx virtual-device-mcp logs device=<id> app=com.example.game filter="exception|error"
npx virtual-device-mcp playtest device=<id> app=com.example.game \
  'steps=[{"tool":"tap","x":0.5,"y":0.87},{"tool":"wait","ms":3000}]' --out report.png

In a checkout, node src/cli.ts <tool> ... does the same.

How it works

MCP client ──stdio──> virtual-device-mcp (Node, src/)
                         │
                         ├─ Android emulator ───── adb + emulator (Android SDK tools)
                         ├─ iOS / tvOS / visionOS ─ simctl
                         │     ├─ agent/        XCUITest agent inside the simulator, HTTP on 127.0.0.1
                         │     ├─ vdevice-pad   virtual game controller (mac/)
                         │     └─ vdevice-mac   clicks on the simulator's display in DeviceHub (mac/)
                         └─ This Mac ───────────── screencapture + vdevice-mac (CGEvent, Accessibility)

All input code is in this repository; no third-party automation tool is used.

Target Touch Keys / buttons Screenshot Labelled elements
Android emulator adb shell input; two fingers as raw multi-touch events through the emulator console adb shell input keyevent adb emu screenrecord screenshot, fallback screencap uiautomator dump
iOS simulator XCUITest agent home; virtual controller simctl io screenshot XCUITest agent
tvOS simulator no touch screen virtual controller (the remote); home through the agent simctl io screenshot XCUITest agent (press with the remote)
visionOS simulator click on the display in DeviceHub virtual controller simctl io screenshot (the whole room) XCUITest agent
This Mac vdevice-mac (CGEvent) vdevice-mac (CGEvent) screencapture -l Accessibility tree

Apple simulators need three mechanisms, because none covers everything:

  • The XCUITest agent (public API). A UI test that never finishes: it serves commands over HTTP on 127.0.0.1. It touches the screen on iOS, presses system popups by label and reads labelled elements. The server builds it once per platform, keeps it running between calls and restarts it when it stops.
  • A virtual game controller (vdevice-pad). It creates a GCExtendedGamepad and forwards its state into the simulator through SimulatorKit, the way Xcode forwards a controller connected to the Mac. Apple TV needs it: a Unity game reads the remote as a controller and ignores XCUIRemote, keyboard keys and DeviceHub's remote buttons, which only drive tvOS's own UI. SimulatorKit is a private Xcode framework, so this part may need changes for a new Xcode.
  • DeviceHub (vdevice-mac hub). On visionOS, XCUITest cannot touch a window without an accessibility scene (a Unity game). The helper finds the simulator's display in the DeviceHub window through Accessibility and clicks there; a click is a look-and-pinch at that spot.

Node 24+ runs the TypeScript sources directly. The npm package ships dist/ (the sources with types stripped, because Node does not run .ts inside node_modules), agent/ and mac/.

What has been verified

Run on 2026-11-28 with a Unity 6 game (Brick Race), Xcode 27.2, through the command line.

Android emulator iOS simulator tvOS simulator visionOS simulator This Mac
List, start, stop devices pass pass pass pass n/a
Screenshot pass pass pass pass (whole room) pass
Tap, long press pass pass no touch pass pass
Swipe pass pass no touch runs, effect not checked runs, effect not checked
Two fingers (pinch) pass runs, effect not checked no touch not available not available
Keys pass home only pass (remote) d-pad: pass pass
Virtual controller (gamepad) not available runs, effect not checked pass pass in game not available
System popup by label pass pass not tried not tried not tried
Labelled elements pass pass pass pass pass (Calculator)
Type text pass pass not tried not tried not tried
Install, launch, stop, reset pass pass launch, reset: pass install, launch, reset: pass launch, stop, reset: pass
Logs pass pass pass pass pass
Record video file written, not viewed pass pass file written, not viewed pass
A full round played by a screenshot-reading bot pass pass pass pass not tried
playtest pass pass not tried not tried not tried

Known limits

  • visionOS touches take over the DeviceHub window. DeviceHub has to be open and is brought to the front for each touch; it ignores pointer events while another app is in front. Two booted simulators with the same name are refused, because DeviceHub lists them by name only.
  • Two-finger gestures on iOS happen at the centre of the screen, because XCUITest only offers them on elements. They are not available on visionOS or the Mac.
  • A game's own popup may ignore the controller. On visionOS, one Unity UI popup did not react to the virtual controller while the game behind it did; tap worked.
  • The virtual controller uses a private Xcode framework (SimulatorKit) and was only run with Xcode 27.2.
  • Injecting touches through that private framework was tried and dropped: the events did not reach the app, and a wrong value restarted the simulator's backboardd. It is used for the controller only.
  • Each call takes 0.3 to 2 seconds (Android taps are fastest, controller presses slowest), so this is for turn-based driving and slow games, not for fast real-time play.

Development

npm test         # unit tests and an MCP protocol test over stdio
npm run build    # writes dist/ (no dependencies needed)
npm pack         # builds and creates the package tarball

The backends need real virtual devices, so they are exercised through src/cli.ts.

Releasing

Publishing a GitHub release publishes that version to npm (.github/workflows/publish.yml, through npm trusted publishing, so no token is stored anywhere):

npm version patch                 # or minor / major: bumps package.json, commits and tags vX.Y.Z
git push origin main --follow-tags
gh release create "v$(node -p "require('./package.json').version")" --generate-notes

License

MIT. See LICENSE.

About

MCP server that drives apps and games on Android emulators, iOS / tvOS / visionOS simulators and the Mac

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages