Screen Capture

Tools for capturing screenshots, component tree snapshots, querying native UI trees, and performing visual regression testing.

take_screenshot

Capture the device/simulator screen as a JPEG image (720p).

Parameters

ParameterTypeRequiredDescription
platform"ios" | "android"Yesandroid: uses adb. ios: uses simctl (simulator only)
filePathstringNoPath to save the screenshot file

Example

// Request
{ "tool": "take_screenshot", "arguments": { "platform": "ios" } }

Tips

  • Returns base64 JPEG and point size metadata for coordinate conversion.
  • Prefer assert_text or assert_visible over screenshots when possible — screenshots consume vision tokens.
  • iOS only supports simulators, not physical devices.

take_snapshot

Capture the React Native component tree. Compact text output for massive token savings.

Parameters

ParameterTypeRequiredDescription
platform"ios" | "android"NoTarget platform
deviceIdstringNoTarget device
maxDepthnumberNoMax tree depth (1–100). Default: 30
interactivebooleanNoIf true, show only interactive elements (Touchable, Button, TextInput, Switch, etc.)

Example

// Request
{ "tool": "take_snapshot", "arguments": { "maxDepth": 10 } }

// Response (compact text)
- View #app-root uid=RCTView:0
  - View #header
    - Text "Home" uid=header>Text:0
  - TextInput #email-input
  - TouchableOpacity #submit-btn
    - Text "Submit"
// interactive mode: only interactive elements
{ "tool": "take_snapshot", "arguments": { "interactive": true } }

// Response
- TextInput #email-input
- TouchableOpacity #submit-btn

Tips

  • Compact output: Over 90% token savings compared to JSON. Hierarchy is represented by indentation.
  • Use interactive: true to show only tappable/input elements, further reducing tokens.
  • Use uid values with measureView(uid) via evaluate_script to get exact coordinates.
  • Reduce maxDepth for large component trees to limit output size.

describe_ui

Query the native UI/accessibility tree. Compact text output for significant token savings.

Parameters

ParameterTypeRequiredDescription
platform"ios" | "android"YesTarget platform
mode"all" | "point"NoiOS: all dumps full tree, point queries at (x,y). Android: ignored. Default: all
xnumberNoX in points. Required for iOS mode=point
ynumberNoY in points. Required for iOS mode=point
nestedbooleanNoiOS: return hierarchical tree. Android: ignored. Default: false
deviceIdstringNoDevice ID

Example

// Request — iOS point query
{
  "tool": "describe_ui",
  "arguments": { "platform": "ios", "mode": "point", "x": 200, "y": 400 }
}

Tips

  • Compact output: Over 78% token savings compared to JSON/XML. Android shows [clickable], [scrollable], bounds= etc. iOS shows role=, enabled=, frame=.
  • Prefer query_selector for querying React Native elements.
  • iOS uses idb ui describe-all/describe-point. Android uses uiautomator dump.
  • Useful for inspecting native components that aren't part of the React tree (e.g., native alerts, system UI).

visual_compare

Compare the current screen against a baseline PNG for visual regression testing.

Parameters

ParameterTypeRequiredDescription
platform"ios" | "android"YesTarget platform
baselinestringYesAbsolute path to the baseline PNG file
selectorstringNoSelector to crop a specific element. Omit for full-screen comparison
thresholdnumberNopixelmatch threshold (0–1). Default: 0.1
updateBaselinebooleanNoIf true, save current screenshot as new baseline (skip comparison)
saveDiffstringNoPath to save the diff image PNG
saveCurrentstringNoPath to save the current screenshot PNG
deviceIdstringNoDevice ID

Example

// Create baseline
{
  "tool": "visual_compare",
  "arguments": {
    "platform": "ios",
    "baseline": "/tmp/baselines/home.png",
    "updateBaseline": true
  }
}

// Compare against baseline
{
  "tool": "visual_compare",
  "arguments": {
    "platform": "ios",
    "baseline": "/tmp/baselines/home.png",
    "saveDiff": "/tmp/diffs/home-diff.png",
    "threshold": 0.05
  }
}

// Response
{
  "pass": false,
  "diffRatio": 0.023,
  "diffPixels": 4821,
  "totalPixels": 209664,
  "threshold": 0.05,
  "message": "Visual difference detected: 2.3% of pixels differ"
}

Tips

  • Use updateBaseline: true to create initial baselines.
  • Use selector to compare only a specific component (e.g., #header) instead of the full screen.
  • Lower threshold values are stricter (0 = pixel-perfect, 1 = any difference passes).
  • Uses sharp + pixelmatch internally.

Video recording

Start and stop screen recording on the device/simulator. Uses idb on iOS and adb screenrecord on Android. Only one recording can be active per MCP server at a time.

start_video_recording

Start recording the device screen. The recording continues until you call stop_video_recording.

Parameters

ParameterTypeRequiredDescription
platform"ios" | "android"YesTarget platform
filePathstringYesHost path to save the recording. Must be under the current working directory (e.g. e2e-artifacts/recording.mp4).
deviceIdstringNoDevice ID. Omit when only one device is connected.

Example

{
  "tool": "start_video_recording",
  "arguments": {
    "platform": "ios",
    "filePath": "e2e-artifacts/session.mp4"
  }
}

Tips

  • If a recording is already in progress, the tool returns an error. Call stop_video_recording first.
  • On server exit (or session end), any active recording is stopped automatically.

stop_video_recording

Stop the current recording and save the file to the path given when starting.

Parameters

ParameterTypeRequiredDescription
platform"ios" | "android"NoPlatform to stop. Omit when only one recording.
deviceIdstringNoDevice ID. Omit for single device.

Example

{ "tool": "stop_video_recording", "arguments": { "platform": "ios" } }

Tips

  • Returns the path to the saved file on success.
  • iOS: uses idb. Android: uses adb screenrecord (SIGINT to stop and finalize).