react-native-ai-devtools 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +1250 -0
  3. package/build/__tests__/helpers/fake-cdp-server.d.ts +56 -0
  4. package/build/__tests__/helpers/fake-cdp-server.d.ts.map +1 -0
  5. package/build/__tests__/helpers/fake-cdp-server.js +108 -0
  6. package/build/__tests__/helpers/fake-cdp-server.js.map +1 -0
  7. package/build/__tests__/integration/connection-health.test.d.ts +2 -0
  8. package/build/__tests__/integration/connection-health.test.d.ts.map +1 -0
  9. package/build/__tests__/integration/connection-health.test.js +151 -0
  10. package/build/__tests__/integration/connection-health.test.js.map +1 -0
  11. package/build/__tests__/integration/execute-in-app.test.d.ts +2 -0
  12. package/build/__tests__/integration/execute-in-app.test.d.ts.map +1 -0
  13. package/build/__tests__/integration/execute-in-app.test.js +115 -0
  14. package/build/__tests__/integration/execute-in-app.test.js.map +1 -0
  15. package/build/__tests__/integration/tools.test.d.ts +2 -0
  16. package/build/__tests__/integration/tools.test.d.ts.map +1 -0
  17. package/build/__tests__/integration/tools.test.js +228 -0
  18. package/build/__tests__/integration/tools.test.js.map +1 -0
  19. package/build/__tests__/setup.d.ts +2 -0
  20. package/build/__tests__/setup.d.ts.map +1 -0
  21. package/build/__tests__/setup.js +11 -0
  22. package/build/__tests__/setup.js.map +1 -0
  23. package/build/__tests__/unit/bundle.test.d.ts +2 -0
  24. package/build/__tests__/unit/bundle.test.d.ts.map +1 -0
  25. package/build/__tests__/unit/bundle.test.js +53 -0
  26. package/build/__tests__/unit/bundle.test.js.map +1 -0
  27. package/build/__tests__/unit/connection-health.test.d.ts +2 -0
  28. package/build/__tests__/unit/connection-health.test.d.ts.map +1 -0
  29. package/build/__tests__/unit/connection-health.test.js +28 -0
  30. package/build/__tests__/unit/connection-health.test.js.map +1 -0
  31. package/build/__tests__/unit/executor.test.d.ts +2 -0
  32. package/build/__tests__/unit/executor.test.d.ts.map +1 -0
  33. package/build/__tests__/unit/executor.test.js +79 -0
  34. package/build/__tests__/unit/executor.test.js.map +1 -0
  35. package/build/__tests__/unit/logs.test.d.ts +2 -0
  36. package/build/__tests__/unit/logs.test.d.ts.map +1 -0
  37. package/build/__tests__/unit/logs.test.js +81 -0
  38. package/build/__tests__/unit/logs.test.js.map +1 -0
  39. package/build/__tests__/unit/metro.test.d.ts +2 -0
  40. package/build/__tests__/unit/metro.test.d.ts.map +1 -0
  41. package/build/__tests__/unit/metro.test.js +61 -0
  42. package/build/__tests__/unit/metro.test.js.map +1 -0
  43. package/build/__tests__/unit/network.test.d.ts +2 -0
  44. package/build/__tests__/unit/network.test.d.ts.map +1 -0
  45. package/build/__tests__/unit/network.test.js +102 -0
  46. package/build/__tests__/unit/network.test.js.map +1 -0
  47. package/build/__tests__/unit/tap.test.d.ts +2 -0
  48. package/build/__tests__/unit/tap.test.d.ts.map +1 -0
  49. package/build/__tests__/unit/tap.test.js +157 -0
  50. package/build/__tests__/unit/tap.test.js.map +1 -0
  51. package/build/core/android.d.ts +265 -0
  52. package/build/core/android.d.ts.map +1 -0
  53. package/build/core/android.js +1413 -0
  54. package/build/core/android.js.map +1 -0
  55. package/build/core/bundle.d.ts +49 -0
  56. package/build/core/bundle.d.ts.map +1 -0
  57. package/build/core/bundle.js +368 -0
  58. package/build/core/bundle.js.map +1 -0
  59. package/build/core/connection.d.ts +43 -0
  60. package/build/core/connection.d.ts.map +1 -0
  61. package/build/core/connection.js +963 -0
  62. package/build/core/connection.js.map +1 -0
  63. package/build/core/connectionState.d.ts +108 -0
  64. package/build/core/connectionState.d.ts.map +1 -0
  65. package/build/core/connectionState.js +284 -0
  66. package/build/core/connectionState.js.map +1 -0
  67. package/build/core/errorScreenParser.d.ts +30 -0
  68. package/build/core/errorScreenParser.d.ts.map +1 -0
  69. package/build/core/errorScreenParser.js +198 -0
  70. package/build/core/errorScreenParser.js.map +1 -0
  71. package/build/core/executor.d.ts +113 -0
  72. package/build/core/executor.d.ts.map +1 -0
  73. package/build/core/executor.js +1877 -0
  74. package/build/core/executor.js.map +1 -0
  75. package/build/core/format.d.ts +8 -0
  76. package/build/core/format.d.ts.map +1 -0
  77. package/build/core/format.js +34 -0
  78. package/build/core/format.js.map +1 -0
  79. package/build/core/guides.d.ts +14 -0
  80. package/build/core/guides.d.ts.map +1 -0
  81. package/build/core/guides.js +261 -0
  82. package/build/core/guides.js.map +1 -0
  83. package/build/core/httpServer.d.ts +14 -0
  84. package/build/core/httpServer.d.ts.map +1 -0
  85. package/build/core/httpServer.js +2459 -0
  86. package/build/core/httpServer.js.map +1 -0
  87. package/build/core/httpServerProcess.d.ts +25 -0
  88. package/build/core/httpServerProcess.d.ts.map +1 -0
  89. package/build/core/httpServerProcess.js +153 -0
  90. package/build/core/httpServerProcess.js.map +1 -0
  91. package/build/core/index.d.ts +25 -0
  92. package/build/core/index.d.ts.map +1 -0
  93. package/build/core/index.js +53 -0
  94. package/build/core/index.js.map +1 -0
  95. package/build/core/ios.d.ts +214 -0
  96. package/build/core/ios.d.ts.map +1 -0
  97. package/build/core/ios.js +1232 -0
  98. package/build/core/ios.js.map +1 -0
  99. package/build/core/logs.d.ts +43 -0
  100. package/build/core/logs.d.ts.map +1 -0
  101. package/build/core/logs.js +144 -0
  102. package/build/core/logs.js.map +1 -0
  103. package/build/core/metro.d.ts +23 -0
  104. package/build/core/metro.d.ts.map +1 -0
  105. package/build/core/metro.js +96 -0
  106. package/build/core/metro.js.map +1 -0
  107. package/build/core/network.d.ts +43 -0
  108. package/build/core/network.d.ts.map +1 -0
  109. package/build/core/network.js +217 -0
  110. package/build/core/network.js.map +1 -0
  111. package/build/core/networkInterceptor.d.ts +3 -0
  112. package/build/core/networkInterceptor.d.ts.map +1 -0
  113. package/build/core/networkInterceptor.js +203 -0
  114. package/build/core/networkInterceptor.js.map +1 -0
  115. package/build/core/ocr.d.ts +69 -0
  116. package/build/core/ocr.d.ts.map +1 -0
  117. package/build/core/ocr.js +212 -0
  118. package/build/core/ocr.js.map +1 -0
  119. package/build/core/state.d.ts +17 -0
  120. package/build/core/state.d.ts.map +1 -0
  121. package/build/core/state.js +50 -0
  122. package/build/core/state.js.map +1 -0
  123. package/build/core/tap.d.ts +91 -0
  124. package/build/core/tap.d.ts.map +1 -0
  125. package/build/core/tap.js +542 -0
  126. package/build/core/tap.js.map +1 -0
  127. package/build/core/telemetry.d.ts +4 -0
  128. package/build/core/telemetry.d.ts.map +1 -0
  129. package/build/core/telemetry.js +289 -0
  130. package/build/core/telemetry.js.map +1 -0
  131. package/build/core/types.d.ts +134 -0
  132. package/build/core/types.d.ts.map +1 -0
  133. package/build/core/types.js +2 -0
  134. package/build/core/types.js.map +1 -0
  135. package/build/httpServerStandalone.d.ts +7 -0
  136. package/build/httpServerStandalone.d.ts.map +1 -0
  137. package/build/httpServerStandalone.js +31 -0
  138. package/build/httpServerStandalone.js.map +1 -0
  139. package/build/index.d.ts +3 -0
  140. package/build/index.d.ts.map +1 -0
  141. package/build/index.js +3012 -0
  142. package/build/index.js.map +1 -0
  143. package/build/pro/tap.d.ts +91 -0
  144. package/build/pro/tap.d.ts.map +1 -0
  145. package/build/pro/tap.js +542 -0
  146. package/build/pro/tap.js.map +1 -0
  147. package/package.json +63 -0
package/README.md ADDED
@@ -0,0 +1,1250 @@
1
+ # React Native AI DevTools
2
+
3
+ An MCP server that gives AI assistants real-time access to a running React Native app. It bridges the gap between static code and live runtime, turning AI assistants from guessing machines into informed development partners.
4
+
5
+ **Positioning:** This is not a debugger. This is not a QA tool. This is a Runtime AI Bridge — the missing layer between AI coding assistants and live mobile applications. Without it, your AI assistant is blind. With it, the AI sees everything happening in your app in real time.
6
+
7
+ ## Features
8
+
9
+ ### Runtime Interaction
10
+
11
+ - **Console Log Capture** - Capture `console.log`, `warn`, `error`, `info`, `debug` with filtering and search
12
+ - **React Component Inspection** - Inspect component tree, props, state/hooks, and layout styles at runtime
13
+ - **Network Request Tracking** - Monitor HTTP requests/responses with headers, timing, and body content
14
+ - **JavaScript Execution** - Run code directly in your app (REPL-style) and inspect results
15
+ - **Global State Debugging** - Discover and inspect Apollo Client, Redux stores, Expo Router, and custom globals
16
+ - **Bundle Error Detection** - Get Metro bundler errors and compilation issues with file locations
17
+ - **Debug Web Dashboard** - Browser-based UI for real-time log and network monitoring
18
+
19
+ ### Device Control
20
+
21
+ - **iOS Simulator** - Screenshots, app management, URL handling, boot/terminate (via simctl)
22
+ - **Android Devices** - Screenshots, app install/launch, package management (via ADB)
23
+ - **Unified Tap** - Single `tap` tool with automatic fallback chain: fiber tree → accessibility → OCR → coordinates. Auto-detects platform, accepts pixels from screenshots
24
+ - **UI Automation** - Swipe, long press, text input, and key events on both platforms
25
+ - **Accessibility Inspection** - Query UI hierarchy to find elements by text, label, or resource ID
26
+ - **OCR Text Extraction** - Extract visible text with tap-ready coordinates (works on any screen content)
27
+
28
+ ### Under the Hood
29
+
30
+ - **Auto-Discovery** - Scans Metro on ports 8081, 8082, 19000-19002 automatically
31
+ - **Smart Device Selection** - Prioritizes Bridgeless > Hermes > standard React Native targets
32
+ - **Auto-Reconnection** - Exponential backoff (up to 8 attempts) when connection drops
33
+ - **Efficient Buffering** - Circular buffers: 500 logs, 200 network requests
34
+ - **Platform Support** - Expo SDK 54+ (Bridgeless) and React Native 0.70+ (Hermes)
35
+
36
+ ## Claude Code Skills
37
+
38
+ This repository includes pre-built [Claude Code skills](https://docs.anthropic.com/en/docs/claude-code/skills) for common React Native debugging workflows. Skills let Claude handle multi-step tasks (session setup, log inspection, network debugging, etc.) with a single slash command instead of manual back-and-forth.
39
+
40
+ ### Available Skills
41
+
42
+ | Skill | Description |
43
+ | ----- | ----------- |
44
+ | `session-setup` | Bootstrap a debugging session: discover devices, boot simulators, connect to Metro |
45
+ | `debug-logs` | Capture, filter, and analyze console logs to find errors and warnings |
46
+ | `network-inspect` | Monitor and inspect HTTP requests, filter by status/method, and analyze failures |
47
+ | `app-state` | Inspect Redux/Apollo/context state, navigate the app, and execute code in the runtime |
48
+ | `component-inspect` | Inspect React component tree, props, state, and layout |
49
+ | `layout-check` | Verify UI layout against design specs using screenshots and component data |
50
+ | `device-interact` | Automate device interaction: tap, swipe, text input, and element finding |
51
+ | `bundle-check` | Detect and diagnose Metro bundler errors and compilation failures |
52
+ | `native-rebuild` | Rebuild and verify the app after installing native Expo packages |
53
+
54
+ See [`skills/overview.md`](./skills/overview.md) for a decision guide on which skill to use and a recommended workflow.
55
+
56
+ ### Installing Skills (Claude Code)
57
+
58
+ Copy the skill files into your project's `.claude/skills/` directory:
59
+
60
+ ```bash
61
+ # Install all skills
62
+ mkdir -p .claude/skills
63
+ curl -s https://api.github.com/repos/igorzheludkov/react-native-ai-devtools/contents/skills \
64
+ | grep download_url \
65
+ | cut -d '"' -f 4 \
66
+ | xargs -I {} sh -c 'curl -sL {} -o .claude/skills/$(basename {})'
67
+ ```
68
+
69
+ Or pick individual skills from the [`skills/`](./skills/) folder and drop them into `.claude/skills/`.
70
+
71
+ Then invoke in Claude Code:
72
+
73
+ ```
74
+ /session-setup
75
+ /debug-logs
76
+ /network-inspect
77
+ ```
78
+
79
+ Skills can also be triggered **automatically** — each skill file contains a "When to Trigger" section that tells Claude when to proactively invoke it without a slash command. For example, Claude will run `bundle-check` on its own when it detects a red screen, or `session-setup` when starting a fresh debugging task with no connection established yet.
80
+
81
+ ## Requirements
82
+
83
+ - Node.js 18+
84
+ - React Native app running with Metro bundler
85
+ - **Optional for iOS UI automation**: [Facebook IDB](https://fbidb.io/) - `brew install idb-companion`
86
+ - **Optional for OCR**: Python 3.6+ (EasyOCR is installed automatically, see [OCR Setup](#ocr-text-extraction))
87
+
88
+ ## Claude Code Setup
89
+
90
+ No installation required - Claude Code uses `npx` to run the latest version automatically.
91
+
92
+ ### Global (all projects)
93
+
94
+ ```bash
95
+ claude mcp add rn-debugger --scope user -- npx react-native-ai-devtools
96
+ ```
97
+
98
+ ### Project-specific
99
+
100
+ ```bash
101
+ claude mcp add rn-debugger --scope project -- npx react-native-ai-devtools
102
+ ```
103
+
104
+ ### Manual Configuration
105
+
106
+ Add to `~/.claude.json` (user scope) or `.mcp.json` (project scope):
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "rn-debugger": {
112
+ "type": "stdio",
113
+ "command": "npx",
114
+ "args": ["react-native-ai-devtools"]
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ Restart Claude Code after adding the configuration.
121
+
122
+ ## VS Code Copilot Setup
123
+
124
+ Requires VS Code 1.102+ with Copilot ([docs](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)).
125
+
126
+ **Via Command Palette**: `Cmd+Shift+P` → "MCP: Add Server"
127
+
128
+ **Manual config** - add to `.vscode/mcp.json`:
129
+
130
+ ```json
131
+ {
132
+ "servers": {
133
+ "rn-debugger": {
134
+ "type": "stdio",
135
+ "command": "npx",
136
+ "args": ["-y", "react-native-ai-devtools"]
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ ## Cursor Setup
143
+
144
+ [Docs](https://docs.cursor.com/context/model-context-protocol)
145
+
146
+ **Via Command Palette**: `Cmd+Shift+P` → "View: Open MCP Settings"
147
+
148
+ **Manual config** - add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
149
+
150
+ ```json
151
+ {
152
+ "mcpServers": {
153
+ "rn-debugger": {
154
+ "command": "npx",
155
+ "args": ["-y", "react-native-ai-devtools"]
156
+ }
157
+ }
158
+ }
159
+ ```
160
+
161
+ ## Available Tools
162
+
163
+ ### Usage Guide
164
+
165
+ | Tool | Description |
166
+ | ----------------- | --------------------------------------------------------------------------- |
167
+ | `get_usage_guide` | Get recommended workflows for all tools. Call without params for overview, with a topic (`setup`, `inspect`, `layout`, `interact`, `logs`, `network`, `state`, `bundle`) for the full guide |
168
+
169
+ The server also sends instructions on connection, so MCP clients automatically learn about `get_usage_guide`.
170
+
171
+ ### Connection & Logs
172
+
173
+ | Tool | Description |
174
+ | ----------------------- | ------------------------------------------------------------------ |
175
+ | `scan_metro` | Scan for Metro servers and auto-connect. **Call this first** to start debugging |
176
+ | `connect_metro` | Connect to a specific Metro port (use when you know the exact port) |
177
+ | `disconnect_metro` | Disconnect from all Metro servers. Frees the CDP slot for the built-in RN debugger. Reconnect with `scan_metro` |
178
+ | `get_apps` | List connected apps. Run `scan_metro` first if none connected |
179
+ | `get_connection_status` | Get detailed connection health, uptime, and recent disconnects |
180
+ | `ensure_connection` | Verify/establish connection with health checks |
181
+ | `get_logs` | Retrieve console logs (filtering, truncation, summary, TONL format) |
182
+ | `search_logs` | Search logs for specific text (truncation, TONL format) |
183
+ | `clear_logs` | Clear the log buffer |
184
+
185
+ ### Network Tracking
186
+
187
+ | Tool | Description |
188
+ | ---------------------- | ---------------------------------------------------------- |
189
+ | `get_network_requests` | Retrieve network requests (filtering, summary, TONL format) |
190
+ | `search_network` | Search requests by URL pattern (TONL format) |
191
+ | `get_request_details` | Get full details of a request (headers, body with truncation) |
192
+ | `get_network_stats` | Get statistics: counts by method, status code, domain |
193
+ | `clear_network` | Clear the network request buffer |
194
+
195
+ ### App Inspection & Execution
196
+
197
+ | Tool | Description |
198
+ | -------------------- | ------------------------------------------------------------------- |
199
+ | `execute_in_app` | Execute simple JS expressions using globals discovered via `list_debug_globals` |
200
+ | `list_debug_globals` | Discover available debug objects (Apollo, Redux, Expo Router, etc.) |
201
+ | `inspect_global` | Inspect a global object to see its properties and callable methods |
202
+ | `reload_app` | Reload the app (auto-connects if needed). Use sparingly - Fast Refresh handles most changes |
203
+ | `get_debug_server` | Get the debug HTTP server URL for browser-based viewing |
204
+ | `restart_http_server` | Restart the debug HTTP server |
205
+
206
+ ### Bundle Tools
207
+
208
+ | Tool | Description |
209
+ | -------------------- | ------------------------------------------------------------------- |
210
+ | `get_bundle_status` | Get Metro bundler status and build state |
211
+ | `get_bundle_errors` | Get compilation errors with file locations |
212
+ | `clear_bundle_errors` | Clear the bundle error buffer |
213
+
214
+ ### React Component Inspection
215
+
216
+ **Recommended Workflow**: Use `get_component_tree(focusedOnly=true, structureOnly=true)` for a token-efficient overview of just the active screen (~1-3KB), then drill down with `inspect_component` or `find_components`.
217
+
218
+ | Tool | Description |
219
+ | -------------------- | ------------------------------------------------------------------- |
220
+ | `get_component_tree` | **Start here** with `focusedOnly=true, structureOnly=true` for active screen overview |
221
+ | `inspect_component` | **Drill-down tool**: Inspect specific component's props, state/hooks, children |
222
+ | `find_components` | **Targeted search**: Find components by pattern with optional layout info |
223
+ | `get_screen_layout` | Full layout data - use sparingly, can be large for complex screens |
224
+
225
+ ### Element Inspector (Coordinate-Based)
226
+
227
+ Inspect React components at specific screen coordinates - like React Native's built-in Element Inspector, but programmatically.
228
+
229
+ | Tool | Description |
230
+ | -------------------------- | ------------------------------------------------------------------------------ |
231
+ | `get_inspector_selection` | **Main tool**: Get React component at coordinates. Auto-enables inspector and taps if x/y provided |
232
+ | `toggle_element_inspector` | Manually toggle the Element Inspector overlay on/off |
233
+ | `inspect_at_point` | Inspect React component at (x,y) coordinates |
234
+
235
+ **Quick Inspection (Recommended)**:
236
+ ```
237
+ # Single call - auto-enables inspector, taps, returns component info
238
+ get_inspector_selection(x=210, y=400)
239
+ ```
240
+
241
+ Returns:
242
+ ```
243
+ Element: FastImageView
244
+ Path: App > RootNavigation > ... > PlayerModal > FastImage > FastImageView
245
+ Frame: (62.3, 130.0) 295.67x295.67
246
+ Style: { borderRadius: 15, overflow: "hidden" }
247
+ ```
248
+
249
+ **Manual Flow** (for more control):
250
+ ```
251
+ # 1. Enable the inspector overlay
252
+ toggle_element_inspector()
253
+
254
+ # 2. Tap to select element
255
+ tap with x=630 y=1200 # pixel coordinates from screenshot
256
+
257
+ # 3. Read the selection
258
+ get_inspector_selection()
259
+
260
+ # 4. Disable overlay when done
261
+ toggle_element_inspector()
262
+ ```
263
+
264
+ **Token Efficiency**: Returns ~0.2-0.5KB vs 15-25KB for full component tree. Works on all React Native versions including Fabric/New Architecture.
265
+
266
+ ### UI Interaction (Cross-Platform)
267
+
268
+ | Tool | Description |
269
+ | ---------------- | ------------------------------------------------------------------------ |
270
+ | `tap` | **Unified tap** — auto-detects platform, tries fiber tree → accessibility → OCR → coordinates. Accepts text, testID, component name, or pixel coordinates from screenshots |
271
+ | `ocr_screenshot` | Extract all visible text with tap-ready coordinates (works on iOS/Android) |
272
+
273
+ **Examples:**
274
+ ```
275
+ tap with text="Submit" # Finds and taps by visible text
276
+ tap with testID="login-btn" # Finds by testID prop
277
+ tap with component="HamburgerIcon" # Finds by React component name
278
+ tap with x=300 y=600 # Taps at pixel coordinates (auto-converts)
279
+ tap with text="Menu" strategy="ocr" # Forces OCR strategy only
280
+ ```
281
+
282
+ ### Android (ADB)
283
+
284
+ | Tool | Description |
285
+ | --------------------------- | ------------------------------------------------------------- |
286
+ | `list_android_devices` | List connected Android devices and emulators via ADB |
287
+ | `android_screenshot` | Take a screenshot from an Android device/emulator |
288
+ | `android_install_app` | Install an APK on an Android device/emulator |
289
+ | `android_launch_app` | Launch an app by package name |
290
+ | `android_list_packages` | List installed packages (with optional filter) |
291
+ | `android_long_press` | Long press at specific coordinates |
292
+ | `android_swipe` | Swipe from one point to another |
293
+ | `android_input_text` | Type text at current focus point |
294
+ | `android_key_event` | Send key events (HOME, BACK, ENTER, etc.) |
295
+ | `android_get_screen_size` | Get device screen resolution |
296
+ | `android_describe_all` | Get full UI accessibility tree via uiautomator |
297
+ | `android_describe_point` | Get UI element info at specific coordinates |
298
+ | `android_find_element` | Find element by text/contentDesc/resourceId (no screenshot) |
299
+ | `android_wait_for_element` | Wait for element to appear (useful for screen transitions) |
300
+
301
+ ### iOS (Simulator)
302
+
303
+ | Tool | Description |
304
+ | ----------------------- | --------------------------------------------------------------- |
305
+ | `list_ios_simulators` | List available iOS simulators |
306
+ | `ios_screenshot` | Take a screenshot from an iOS simulator |
307
+ | `ios_install_app` | Install an app bundle (.app) on a simulator |
308
+ | `ios_launch_app` | Launch an app by bundle ID |
309
+ | `ios_open_url` | Open a URL (deep links or web URLs) |
310
+ | `ios_terminate_app` | Terminate a running app |
311
+ | `ios_boot_simulator` | Boot a simulator by UDID |
312
+ | `ios_swipe` | Swipe gesture (requires IDB) |
313
+ | `ios_input_text` | Type text into active field (requires IDB) |
314
+ | `ios_button` | Press hardware button: HOME, LOCK, SIRI (requires IDB) |
315
+ | `ios_key_event` | Send key event by keycode (requires IDB) |
316
+ | `ios_key_sequence` | Send sequence of key events (requires IDB) |
317
+ | `ios_describe_all` | Get full accessibility tree (requires IDB) |
318
+ | `ios_describe_point` | Get element at point (requires IDB) |
319
+ | `ios_find_element` | Find element by label/value (requires IDB, no screenshot) |
320
+ | `ios_wait_for_element` | Wait for element to appear (requires IDB) |
321
+
322
+ ## Usage
323
+
324
+ 1. Start your React Native app:
325
+
326
+ ```bash
327
+ npm start
328
+ # or
329
+ expo start
330
+ ```
331
+
332
+ 2. In Claude Code, scan for Metro:
333
+
334
+ ```
335
+ Use scan_metro to find and connect to Metro
336
+ ```
337
+
338
+ 3. Get logs:
339
+ ```
340
+ Use get_logs to see recent console output
341
+ ```
342
+
343
+ ### `get_logs` Tool Reference
344
+
345
+ The `get_logs` tool has multiple parameters for controlling output size and format. Here's the complete reference:
346
+
347
+ | Parameter | Type | Default | Description |
348
+ |-----------|------|---------|-------------|
349
+ | `maxLogs` | number | 50 | Maximum number of logs to return |
350
+ | `level` | string | "all" | Filter by level: `all`, `log`, `warn`, `error`, `info`, `debug` |
351
+ | `startFromText` | string | - | Start from the last log containing this text |
352
+ | `maxMessageLength` | number | 500 | Max chars per message (0 = unlimited) |
353
+ | `verbose` | boolean | false | Disable all truncation, return full messages |
354
+ | `format` | string | "text" | Output format: `text` or `tonl` (30-50% smaller) |
355
+ | `summary` | boolean | false | Return counts + last 5 messages only |
356
+
357
+ #### Recommended Usage Patterns
358
+
359
+ ```
360
+ # Quick overview (always start here)
361
+ get_logs with summary=true
362
+
363
+ # Recent errors only
364
+ get_logs with level="error" maxLogs=20
365
+
366
+ # Logs since last app reload
367
+ get_logs with startFromText="Running app" maxLogs=100
368
+
369
+ # Full messages for debugging specific issues
370
+ get_logs with maxLogs=10 verbose=true
371
+
372
+ # Token-efficient format for large outputs
373
+ get_logs with format="tonl" maxLogs=100
374
+
375
+ # Compact overview with shorter messages
376
+ get_logs with maxMessageLength=200 maxLogs=50
377
+ ```
378
+
379
+ ### Filtering Logs
380
+
381
+ ```
382
+ get_logs with maxLogs=20 and level="error"
383
+ ```
384
+
385
+ Available levels: `all`, `log`, `warn`, `error`, `info`, `debug`
386
+
387
+ ### Start from Specific Line
388
+
389
+ ```
390
+ get_logs with startFromText="iOS Bundled" and maxLogs=100
391
+ ```
392
+
393
+ This finds the **last** (most recent) line containing the text and returns logs from that point forward. Useful for getting logs since the last app reload.
394
+
395
+ ### Search Logs
396
+
397
+ ```
398
+ search_logs with text="error" and maxResults=20
399
+ ```
400
+
401
+ Case-insensitive search across all log messages.
402
+
403
+ ### Token-Optimized Output
404
+
405
+ The tools include several options to reduce token usage when working with AI assistants.
406
+
407
+ #### Summary Mode (Recommended First Step)
408
+
409
+ **Always start with `summary=true`** - it gives you the full picture in ~10-20 tokens instead of potentially thousands:
410
+
411
+ ```
412
+ get_logs with summary=true
413
+ ```
414
+
415
+ Returns:
416
+ - **Total count** - How many logs are in the buffer
417
+ - **Breakdown by level** - See if there are errors/warnings at a glance
418
+ - **Last 5 messages** - Most recent activity (truncated to 100 chars each)
419
+
420
+ Example output:
421
+
422
+ ```
423
+ Total: 847 logs
424
+
425
+ By Level:
426
+ LOG: 612
427
+ WARN: 180
428
+ ERROR: 55
429
+
430
+ Last 5 messages:
431
+ 14:32:45 [LOG] User clicked button...
432
+ 14:32:46 [WARN] Slow query detected...
433
+ 14:32:47 [ERROR] Network request failed...
434
+ ```
435
+
436
+ #### Why Summary First?
437
+
438
+ | Approach | Tokens | Use Case |
439
+ |----------|--------|----------|
440
+ | `summary=true` | ~20-50 | Quick health check, see if errors exist |
441
+ | `level="error"` | ~100-500 | Investigate specific errors |
442
+ | `maxLogs=50` (default) | ~500-2000 | General debugging |
443
+ | `verbose=true` | ~2000-10000+ | Deep dive into specific data |
444
+
445
+ **Recommended workflow:**
446
+ 1. `summary=true` → See the big picture
447
+ 2. `level="error"` or `level="warn"` → Focus on problems
448
+ 3. `startFromText="..."` → Get logs since specific event
449
+ 4. `verbose=true` with low `maxLogs` → Full details when needed
450
+
451
+ #### Message Truncation
452
+
453
+ Long log messages are truncated by default (500 chars). Adjust as needed:
454
+
455
+ ```
456
+ # Shorter for overview
457
+ get_logs with maxMessageLength=200
458
+
459
+ # Full messages (use with lower maxLogs)
460
+ get_logs with maxLogs=10 verbose=true
461
+
462
+ # Unlimited
463
+ get_logs with maxMessageLength=0
464
+ ```
465
+
466
+ #### TONL Format
467
+
468
+ Use TONL (Token-Optimized Notation Language) for ~30-50% smaller output:
469
+
470
+ ```
471
+ get_logs with format="tonl"
472
+ ```
473
+
474
+ Output:
475
+
476
+ ```
477
+ [Format: TONL - compact token-optimized format. Fields in header, values in rows.]
478
+ {logs:[{time:"14:32:45",level:"LOG",msg:"App started"},{time:"14:32:46",level:"WARN",msg:"Slow query"}]}
479
+ ```
480
+
481
+ TONL is also available for `search_logs`, `get_network_requests`, and `search_network`.
482
+
483
+ ## Network Tracking
484
+
485
+ ### View Recent Requests
486
+
487
+ ```
488
+ get_network_requests with maxRequests=20
489
+ ```
490
+
491
+ ### Filter by Method
492
+
493
+ ```
494
+ get_network_requests with method="POST"
495
+ ```
496
+
497
+ ### Filter by Status Code
498
+
499
+ Useful for debugging auth issues:
500
+
501
+ ```
502
+ get_network_requests with status=401
503
+ ```
504
+
505
+ ### Search by URL
506
+
507
+ ```
508
+ search_network with urlPattern="api/auth"
509
+ ```
510
+
511
+ ### Get Full Request Details
512
+
513
+ After finding a request ID from `get_network_requests`:
514
+
515
+ ```
516
+ get_request_details with requestId="123.45"
517
+ ```
518
+
519
+ Shows full headers, request body, response headers, and timing.
520
+
521
+ Request body is truncated by default (500 chars). For full body:
522
+
523
+ ```
524
+ get_request_details with requestId="123.45" verbose=true
525
+ ```
526
+
527
+ ### Summary Mode (Recommended First Step)
528
+
529
+ Get statistics overview before fetching full requests:
530
+
531
+ ```
532
+ get_network_requests with summary=true
533
+ ```
534
+
535
+ This returns the same output as `get_network_stats` - counts by method, status, and domain.
536
+
537
+ ### TONL Format
538
+
539
+ Use TONL for ~30-50% smaller output:
540
+
541
+ ```
542
+ get_network_requests with format="tonl"
543
+ ```
544
+
545
+ ### View Statistics
546
+
547
+ ```
548
+ get_network_stats
549
+ ```
550
+
551
+ Example output:
552
+
553
+ ```
554
+ Total requests: 47
555
+ Completed: 45
556
+ Errors: 2
557
+ Avg duration: 234ms
558
+
559
+ By Method:
560
+ GET: 32
561
+ POST: 15
562
+
563
+ By Status:
564
+ 2xx: 43
565
+ 4xx: 2
566
+
567
+ By Domain:
568
+ api.example.com: 40
569
+ cdn.example.com: 7
570
+ ```
571
+
572
+ ## Debug Web Dashboard
573
+
574
+ The MCP server includes a built-in web dashboard for viewing logs and network requests in your browser. This is useful for real-time monitoring without using MCP tools.
575
+
576
+ ### Getting the Dashboard URL
577
+
578
+ Use the `get_debug_server` tool to find the dashboard URL:
579
+
580
+ ```
581
+ get_debug_server
582
+ ```
583
+
584
+ The server automatically finds an available port starting from 3456. Each MCP instance gets its own port, so multiple Claude Code sessions can run simultaneously.
585
+
586
+ ### Available Pages
587
+
588
+ | URL | Description |
589
+ | ---------- | ---------------------------------------------- |
590
+ | `/` | Dashboard with overview stats |
591
+ | `/logs` | Console logs with color-coded levels |
592
+ | `/network` | Network requests with expandable details |
593
+ | `/apps` | Connected React Native apps |
594
+
595
+ ### Features
596
+
597
+ - **Auto-refresh** - Pages update automatically every 3 seconds
598
+ - **Color-coded logs** - Errors (red), warnings (yellow), info (blue), debug (gray)
599
+ - **Expandable network requests** - Click any request to see full details:
600
+ - Request/response headers
601
+ - Request body (with JSON formatting)
602
+ - Timing information
603
+ - Error details
604
+ - **GraphQL support** - Shows operation name and variables in compact view:
605
+ ```
606
+ POST 200 https://api.example.com/graphql 1ms ▶
607
+ GetMeetingsBasic (timeFilter: "Future", first: 20)
608
+ ```
609
+ - **REST body preview** - Shows JSON body preview for non-GraphQL requests
610
+
611
+ ### JSON API Endpoints
612
+
613
+ For programmatic access, JSON endpoints are also available:
614
+
615
+ | URL | Description |
616
+ | -------------------- | ----------------------------- |
617
+ | `/api/status` | Server status and buffer sizes |
618
+ | `/api/logs` | All logs as JSON |
619
+ | `/api/network` | All network requests as JSON |
620
+ | `/api/bundle-errors` | Metro bundle errors as JSON |
621
+ | `/api/apps` | Connected apps as JSON |
622
+
623
+ ## App Inspection
624
+
625
+ ### Discover Debug Globals
626
+
627
+ Find what debugging objects are available in your app:
628
+
629
+ ```
630
+ list_debug_globals
631
+ ```
632
+
633
+ Example output:
634
+
635
+ ```json
636
+ {
637
+ "Apollo Client": ["__APOLLO_CLIENT__"],
638
+ "Redux": ["__REDUX_STORE__"],
639
+ "Expo": ["__EXPO_ROUTER__"],
640
+ "Reanimated": ["__reanimatedModuleProxy"]
641
+ }
642
+ ```
643
+
644
+ ### Inspect an Object
645
+
646
+ Before calling methods on an unfamiliar object, inspect it to see what's callable:
647
+
648
+ ```
649
+ inspect_global with objectName="__EXPO_ROUTER__"
650
+ ```
651
+
652
+ Example output:
653
+
654
+ ```json
655
+ {
656
+ "navigate": { "type": "function", "callable": true },
657
+ "push": { "type": "function", "callable": true },
658
+ "currentPath": { "type": "string", "callable": false, "value": "/" },
659
+ "routes": { "type": "array", "callable": false }
660
+ }
661
+ ```
662
+
663
+ ### Execute Code in App
664
+
665
+ Run simple JavaScript expressions using globals discovered via `list_debug_globals`:
666
+
667
+ ```
668
+ execute_in_app with expression="__DEV__"
669
+ // Returns: true
670
+
671
+ execute_in_app with expression="__APOLLO_CLIENT__.cache.extract()"
672
+ // Returns: Full Apollo cache contents
673
+
674
+ execute_in_app with expression="__EXPO_ROUTER__.navigate('/settings')"
675
+ // Navigates the app to /settings
676
+ ```
677
+
678
+ **Limitations (Hermes engine):**
679
+ - No `require()` or `import` — only pre-existing globals are available
680
+ - No `async/await` syntax — use simple expressions or promise chains (`.then()`)
681
+ - No emoji or non-ASCII characters in string literals — causes parse errors
682
+ - Keep expressions simple and synchronous when possible
683
+
684
+ ## React Component Inspection
685
+
686
+ Inspect React components at runtime via the React DevTools hook. These tools let you debug component state, verify layouts, and understand app structure without adding console.logs.
687
+
688
+ ### Recommended Workflow (Token-Efficient)
689
+
690
+ **Always use the 2-step approach:**
691
+
692
+ 1. **Step 1: Get focused screen overview** (~1-3KB)
693
+ ```
694
+ get_component_tree with focusedOnly=true structureOnly=true
695
+ ```
696
+
697
+ 2. **Step 2: Drill down** into specific components as needed
698
+ ```
699
+ inspect_component with componentName="HomeScreen"
700
+ # or
701
+ find_components with pattern="Button" includeLayout=true
702
+ ```
703
+
704
+ This approach uses **~10-20x fewer tokens** than getting full details upfront.
705
+
706
+ ### Token Consumption Comparison
707
+
708
+ | Approach | Tokens | Use Case |
709
+ |----------|--------|----------|
710
+ | `focusedOnly=true, structureOnly=true` | ~1-3KB | **Recommended** - active screen structure only |
711
+ | `structureOnly=true` | ~15-25KB | Full tree structure (includes navigation, overlays) |
712
+ | `inspect_component` | ~1-2KB | Deep dive into specific component |
713
+ | `find_components` | ~2-5KB | Targeted search with layout |
714
+ | `get_screen_layout` | ~20-50KB+ | Full layout (use sparingly) |
715
+
716
+ ### Focused Screen Mode (`focusedOnly`)
717
+
718
+ The `focusedOnly` parameter dramatically reduces output by returning only the active screen subtree:
719
+
720
+ - **Skips navigation wrappers** - Providers, NavigationContainers, SafeAreaProviders
721
+ - **Skips global overlays** - BottomSheet, Modal, Toast, Snackbar components
722
+ - **Returns just the focused screen** - Components matching `*Screen` or `*Page` pattern
723
+
724
+ ```
725
+ get_component_tree with focusedOnly=true structureOnly=true
726
+ ```
727
+
728
+ Output:
729
+
730
+ ```
731
+ Focused: HomeScreen
732
+
733
+ HomeScreen
734
+ Header
735
+ Logo
736
+ SearchBar
737
+ FlatList
738
+ ListItem (×12)
739
+ Footer
740
+ ```
741
+
742
+ **When to skip `focusedOnly`:**
743
+ - Debugging navigation structure itself
744
+ - Investigating which screens are mounted
745
+ - Checking global overlay state
746
+
747
+ ### Inspecting Overlays (BottomSheet, Modal, Toast)
748
+
749
+ Since `focusedOnly` skips global overlays by design, use this workflow to debug them:
750
+
751
+ 1. **Find the overlay component:**
752
+ ```
753
+ find_components with pattern="BottomSheet|Modal|Toast"
754
+ ```
755
+
756
+ 2. **Inspect its state/props:**
757
+ ```
758
+ inspect_component with componentName="MyBottomSheet"
759
+ ```
760
+
761
+ This targeted approach uses ~2-4KB vs ~20KB+ for the full tree.
762
+
763
+ ### Step 1: Get Component Tree
764
+
765
+ View the React component hierarchy with minimal data:
766
+
767
+ ```
768
+ # Focused screen only (recommended)
769
+ get_component_tree with focusedOnly=true structureOnly=true
770
+
771
+ # Full tree structure
772
+ get_component_tree with structureOnly=true
773
+ ```
774
+
775
+ Output (ultra-compact):
776
+
777
+ ```
778
+ Focused: HomeScreen
779
+
780
+ HomeScreen
781
+ Header
782
+ FlatList
783
+ Footer
784
+ ```
785
+
786
+ This gives you the focused screen structure in just 1-3KB.
787
+
788
+ ### Step 2a: Inspect Specific Component
789
+
790
+ After identifying a component in the structure, drill down:
791
+
792
+ ```
793
+ inspect_component with componentName="HomeScreen"
794
+ ```
795
+
796
+ Output:
797
+
798
+ ```json
799
+ {
800
+ "component": "HomeScreen",
801
+ "path": "... > Navigator > HomeScreen",
802
+ "props": {
803
+ "navigation": "[Object]",
804
+ "route": { "name": "Home", "key": "home-xyz" }
805
+ },
806
+ "hooks": [
807
+ { "hookIndex": 0, "value": false },
808
+ { "hookIndex": 3, "value": 42 }
809
+ ]
810
+ }
811
+ ```
812
+
813
+ Options:
814
+ - `includeChildren=true` - Include children tree
815
+ - `childrenDepth=2` - How deep to show children (1=direct only, 2+=nested tree)
816
+ - `includeState=false` - Skip hooks/state (faster)
817
+ - `index=1` - Inspect 2nd instance if multiple exist
818
+
819
+ ### Step 2b: Find Components by Pattern
820
+
821
+ Search for components and optionally get their layout:
822
+
823
+ ```
824
+ find_components with pattern="Screen$" includeLayout=true
825
+ ```
826
+
827
+ Output:
828
+
829
+ ```
830
+ pattern: Screen$
831
+ found: 5
832
+ #found{component,path,depth,key,layout}
833
+ HomeScreen|... > Navigator > HomeScreen|45|paddingHorizontal:16|
834
+ SettingsScreen|... > Navigator > SettingsScreen|45|flex:1|
835
+ ```
836
+
837
+ Options:
838
+ - `includeLayout=true` - Include flex, padding, margin values
839
+ - `summary=true` - Get counts only (e.g., "HomeScreen: 1")
840
+ - `maxResults=10` - Limit number of results
841
+
842
+ ### Full Layout (Use Sparingly)
843
+
844
+ For detailed layout of all visible components:
845
+
846
+ ```
847
+ get_screen_layout
848
+ ```
849
+
850
+ **Warning**: This returns ~20-50KB for complex screens. Use `find_components` with `includeLayout=true` instead for targeted queries.
851
+
852
+ ### Use Cases
853
+
854
+ **Figma Alignment / Layout Verification**
855
+ ```
856
+ # Step 1: See focused screen structure
857
+ get_component_tree with focusedOnly=true structureOnly=true
858
+
859
+ # Step 2: Get layout for specific components
860
+ find_components with pattern="Header|Footer|Button" includeLayout=true
861
+ ```
862
+
863
+ **Debug State Changes**
864
+ ```
865
+ # Check hook values before action
866
+ inspect_component with componentName="LoginForm"
867
+ # → hookIndex 2: false (isLoading)
868
+
869
+ # After user action, check again
870
+ inspect_component with componentName="LoginForm"
871
+ # → hookIndex 2: true (isLoading changed!)
872
+ ```
873
+
874
+ **Debug Navigation Issues**
875
+ ```
876
+ # Find which screen is currently mounted (use full tree)
877
+ get_component_tree with structureOnly=true
878
+ # or
879
+ find_components with pattern="Screen$"
880
+
881
+ # Check if a screen rendered multiple times (memory leak)
882
+ find_components with pattern="HomeScreen" summary=true
883
+ ```
884
+
885
+ **Debug Overlays (BottomSheet, Modal, Toast)**
886
+ ```
887
+ # Find and inspect overlay components
888
+ find_components with pattern="BottomSheet|Modal"
889
+
890
+ # Get overlay props/state
891
+ inspect_component with componentName="PaywallModal"
892
+ ```
893
+
894
+ **Understand Unfamiliar Codebase**
895
+ ```
896
+ # Quick focused screen overview
897
+ get_component_tree with focusedOnly=true structureOnly=true
898
+
899
+ # Full app structure (navigation, providers)
900
+ get_component_tree with structureOnly=true
901
+
902
+ # Find all button variants
903
+ find_components with pattern="Button"
904
+
905
+ # Find all context providers
906
+ find_components with pattern="Provider$"
907
+ ```
908
+
909
+ ## Device Interaction
910
+
911
+ ### Android (requires ADB)
912
+
913
+ List connected devices:
914
+
915
+ ```
916
+ list_android_devices
917
+ ```
918
+
919
+ Take a screenshot:
920
+
921
+ ```
922
+ android_screenshot
923
+ ```
924
+
925
+ Tap on screen:
926
+
927
+ ```
928
+ tap with x=540 y=960
929
+ ```
930
+
931
+ Swipe gesture:
932
+
933
+ ```
934
+ android_swipe with startX=540 startY=1500 endX=540 endY=500
935
+ ```
936
+
937
+ Type text (tap input field first):
938
+
939
+ ```
940
+ tap with x=540 y=400
941
+ android_input_text with text="hello@example.com"
942
+ ```
943
+
944
+ Send key events:
945
+
946
+ ```
947
+ android_key_event with key="BACK"
948
+ android_key_event with key="HOME"
949
+ android_key_event with key="ENTER"
950
+ ```
951
+
952
+ ### iOS Simulator (requires Xcode)
953
+
954
+ List available simulators:
955
+
956
+ ```
957
+ list_ios_simulators
958
+ ```
959
+
960
+ Boot a simulator:
961
+
962
+ ```
963
+ ios_boot_simulator with udid="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
964
+ ```
965
+
966
+ Take a screenshot:
967
+
968
+ ```
969
+ ios_screenshot
970
+ ```
971
+
972
+ Launch an app:
973
+
974
+ ```
975
+ ios_launch_app with bundleId="com.example.myapp"
976
+ ```
977
+
978
+ Open a deep link:
979
+
980
+ ```
981
+ ios_open_url with url="myapp://settings"
982
+ ```
983
+
984
+ ## UI Interaction
985
+
986
+ ### Unified `tap` Tool (Recommended)
987
+
988
+ The `tap` tool is the simplest way to interact with UI elements. It automatically tries multiple strategies and handles platform detection and coordinate conversion:
989
+
990
+ ```
991
+ # By visible text — tries fiber tree, accessibility, then OCR
992
+ tap with text="Submit"
993
+
994
+ # By testID prop
995
+ tap with testID="login-btn"
996
+
997
+ # By React component name (fiber tree only)
998
+ tap with component="HamburgerIcon"
999
+
1000
+ # By pixel coordinates from screenshot (auto-converts to points on iOS)
1001
+ tap with x=300 y=600
1002
+
1003
+ # Force a specific strategy
1004
+ tap with text="Menu" strategy="ocr"
1005
+ ```
1006
+
1007
+ **Fallback chain:** fiber tree (direct `onPress`) → accessibility tree → OCR → error with suggestion.
1008
+
1009
+ On failure, the response includes an actionable `suggestion` telling the agent exactly what to try next.
1010
+
1011
+ ### Platform-Specific Tools
1012
+
1013
+ For gestures beyond tapping, use platform-specific tools:
1014
+
1015
+ ```
1016
+ # Swipe
1017
+ ios_swipe with startX=200 startY=400 endX=200 endY=100
1018
+ android_swipe with startX=540 startY=1500 endX=540 endY=500
1019
+
1020
+ # Text input (tap input field first)
1021
+ tap with text="Email"
1022
+ ios_input_text with text="hello@example.com"
1023
+
1024
+ # Key events
1025
+ android_key_event with key="BACK"
1026
+ ios_button with button="HOME"
1027
+ ```
1028
+
1029
+ ### Wait for Screen Transitions
1030
+
1031
+ ```
1032
+ android_wait_for_element with text="Dashboard" timeoutMs=15000
1033
+ ios_wait_for_element with label="Home" timeoutMs=10000
1034
+ ```
1035
+
1036
+ ## OCR Text Extraction
1037
+
1038
+ The `ocr_screenshot` tool extracts all visible text from a screenshot with tap-ready coordinates. This is useful when accessibility labels are missing or when you need to find text that isn't exposed in the accessibility tree.
1039
+
1040
+ ### Why OCR?
1041
+
1042
+ | Approach | Pros | Cons |
1043
+ |----------|------|------|
1044
+ | Accessibility tree (`find_element`) | Fast, reliable, low token usage | Only finds elements with accessibility labels |
1045
+ | Screenshot + Vision | Visual layout understanding | High token usage, slow |
1046
+ | **OCR** | Works on ANY visible text, returns tap coordinates | Requires text to be visible, may miss small text |
1047
+
1048
+ ### Usage
1049
+
1050
+ ```
1051
+ ocr_screenshot with platform="ios"
1052
+ ```
1053
+
1054
+ Returns all visible text with tap-ready coordinates:
1055
+
1056
+ ```json
1057
+ {
1058
+ "platform": "ios",
1059
+ "engine": "easyocr",
1060
+ "processingTimeMs": 850,
1061
+ "elementCount": 24,
1062
+ "elements": [
1063
+ { "text": "Settings", "confidence": 98, "tapX": 195, "tapY": 52 },
1064
+ { "text": "Login", "confidence": 95, "tapX": 187, "tapY": 420 }
1065
+ ]
1066
+ }
1067
+ ```
1068
+
1069
+ Then tap the element:
1070
+
1071
+ ```
1072
+ tap with x=187 y=420
1073
+ ```
1074
+
1075
+ ### OCR Engine
1076
+
1077
+ The tool uses EasyOCR (Python-based) for text recognition. It provides excellent accuracy on colored backgrounds and stylized text common in mobile UIs.
1078
+
1079
+ ### EasyOCR Setup
1080
+
1081
+ EasyOCR and all its Python dependencies (PyTorch, OpenCV, etc.) are installed automatically into an isolated virtual environment by the `node-easyocr` package — no need to run `pip install` manually. The only prerequisite is having Python 3.6+ available on your system:
1082
+
1083
+ ```bash
1084
+ # macOS
1085
+ brew install python@3.11
1086
+
1087
+ # Ubuntu/Debian
1088
+ sudo apt install python3
1089
+
1090
+ # Windows
1091
+ # Download from https://www.python.org/downloads/
1092
+ ```
1093
+
1094
+ On the first OCR call, language models (~100MB for English) are downloaded automatically. This may take a moment, but subsequent calls use the cached models.
1095
+
1096
+ ### OCR Language Configuration
1097
+
1098
+ By default, OCR recognizes English text. To add more languages, set the `EASYOCR_LANGUAGES` environment variable. English is always included as a fallback.
1099
+
1100
+ ```bash
1101
+ # Add Spanish and French (English always included)
1102
+ EASYOCR_LANGUAGES=es,fr
1103
+ ```
1104
+
1105
+ Add to your MCP configuration:
1106
+
1107
+ ```json
1108
+ {
1109
+ "mcpServers": {
1110
+ "rn-debugger": {
1111
+ "command": "npx",
1112
+ "args": ["react-native-ai-devtools"],
1113
+ "env": {
1114
+ "EASYOCR_LANGUAGES": "es,fr"
1115
+ }
1116
+ }
1117
+ }
1118
+ }
1119
+ ```
1120
+
1121
+ See [EasyOCR supported languages](https://www.jaided.ai/easyocr/) for the full list of language codes.
1122
+
1123
+ ### Recommended Workflow
1124
+
1125
+ 1. **Use unified `tap`** - Handles fallback chain automatically
1126
+ 2. **Fall back to OCR** - When `tap` suggests using coordinates
1127
+ 3. **Use screenshot** - For visual debugging or layout verification
1128
+
1129
+ ```
1130
+ # Simplest approach — tap handles everything
1131
+ tap with text="Submit"
1132
+
1133
+ # If tap fails, use OCR to find coordinates
1134
+ ocr_screenshot with platform="android"
1135
+
1136
+ # Then tap using coordinates from OCR result
1137
+ tap with x=540 y=1200
1138
+ ```
1139
+
1140
+ ## Supported React Native Versions
1141
+
1142
+ | Version | Runtime | Status |
1143
+ | -------------- | ----------------------- | ---------- |
1144
+ | Expo SDK 54+ | React Native Bridgeless | ✓ |
1145
+ | RN 0.70 - 0.76 | Hermes React Native | ✓ |
1146
+ | RN < 0.70 | JSC | Not tested |
1147
+
1148
+ ## How It Works
1149
+
1150
+ 1. Fetches device list from Metro's `/json` endpoint
1151
+ 2. Connects to the main JS runtime via CDP (Chrome DevTools Protocol) WebSocket
1152
+ 3. Enables `Runtime.enable` to receive `Runtime.consoleAPICalled` events
1153
+ 4. Enables `Network.enable` to receive network request/response events
1154
+ 5. Stores logs and network requests in circular buffers for retrieval
1155
+
1156
+ ## Auto-Reconnection
1157
+
1158
+ The server automatically handles connection interruptions:
1159
+
1160
+ ### Auto-Connect on Startup
1161
+
1162
+ When the MCP server starts, it automatically scans common Metro ports (8081, 8082, 19000-19002) and connects to any running Metro bundlers. No need to manually call `scan_metro` if Metro is already running.
1163
+
1164
+ ### Reconnection on Disconnect
1165
+
1166
+ When the connection to Metro is lost (e.g., app restart, Metro restart, or network issues):
1167
+
1168
+ 1. The server automatically attempts to reconnect
1169
+ 2. Uses exponential backoff: immediate, 500ms, 1s, 2s, 4s, 8s (up to 8 attempts)
1170
+ 3. Re-fetches device list to handle new WebSocket URLs
1171
+ 4. Preserves existing log and network buffers
1172
+
1173
+ ### Connection Gap Warnings
1174
+
1175
+ If there was a recent disconnect, `get_logs` and `get_network_requests` will include a warning:
1176
+
1177
+ ```
1178
+ [WARNING] Connection was restored 5s ago. Some logs may have been missed during the 3s gap.
1179
+ ```
1180
+
1181
+ ### Monitor Connection Health
1182
+
1183
+ Use `get_connection_status` to see detailed connection information:
1184
+
1185
+ ```
1186
+ === Connection Status ===
1187
+
1188
+ --- React Native (Port 8081) ---
1189
+ Status: CONNECTED
1190
+ Connected since: 2:45:30 PM
1191
+ Uptime: 5m 23s
1192
+ Recent gaps: 1
1193
+ - 2:43:15 PM (2s): Connection closed
1194
+ ```
1195
+
1196
+ ## Troubleshooting
1197
+
1198
+ ### No devices found
1199
+
1200
+ - Make sure the app is running on a simulator/device
1201
+ - Check that Metro bundler is running (`npm start`)
1202
+
1203
+ ### Wrong device connected
1204
+
1205
+ The server prioritizes devices in this order:
1206
+
1207
+ 1. React Native Bridgeless (SDK 54+)
1208
+ 2. Hermes React Native
1209
+ 3. Any React Native (excluding Reanimated/Experimental)
1210
+
1211
+ ### Logs not appearing
1212
+
1213
+ - Ensure the app is actively running (not just Metro)
1214
+ - Try `clear_logs` then trigger some actions in the app
1215
+ - Check `get_apps` to verify connection status
1216
+
1217
+ ## Telemetry
1218
+
1219
+ This package collects anonymous usage telemetry to help improve the product. No personal information is collected.
1220
+
1221
+ ### What is collected
1222
+
1223
+ | Data | Purpose |
1224
+ |------|---------|
1225
+ | Tool names | Which MCP tools are used most |
1226
+ | Success/failure | Error rates for reliability improvements |
1227
+ | Duration (ms) | Performance monitoring |
1228
+ | Session start/end | Retention analysis |
1229
+ | Platform | macOS/Linux/Windows distribution |
1230
+ | Server version | Adoption of new versions |
1231
+
1232
+ **Not collected**: No file paths, code content, network data, or personally identifiable information.
1233
+
1234
+ ### Opt-out
1235
+
1236
+ To disable telemetry, set the environment variable:
1237
+
1238
+ ```bash
1239
+ export RN_DEBUGGER_TELEMETRY=false
1240
+ ```
1241
+
1242
+ Or inline:
1243
+
1244
+ ```bash
1245
+ RN_DEBUGGER_TELEMETRY=false npx react-native-ai-devtools
1246
+ ```
1247
+
1248
+ ## License
1249
+
1250
+ MIT