Element Query
Tools for finding elements in the React Native component tree and executing JavaScript in the app or WebView context.
query_selector
Find the first element matching a selector in the React Fiber tree. Returns compact text with UID, type, and position (pageX, pageY, width, height).
Parameters
Example
Tips
- This is the entry point for most interaction workflows:
query_selector→ get coordinates →tap. - Tap the center of an element:
x = pageX + width/2,y = pageY + height/2. - UIDs are not known ahead of time — always call
query_selectorfirst to discover them. - Compact output: Significant token savings compared to JSON. Each attribute uses explicit
key=valueformat.
query_selector_all
Find all elements matching a selector. Returns an array with measurements.
Parameters
Example
Tips
- Prefer
query_selectorwhen you only need one element. - Use this to enumerate lists, count visible items, or iterate over multiple matches.
evaluate_script
Run JavaScript in the app's runtime context. Use measureView(uid) to get tap/swipe coordinates.
Parameters
Example
Tips
measureView(uid)returns{ pageX, pageY, width, height }— useful for computing tap targets.require()is not available. Only access globals and the built-in MCP helpers.- The function is wrapped in a try-catch and executed via WebSocket.
webview_evaluate_script
Run JavaScript inside an in-app WebView. Useful for DOM manipulation, form filling, or reading web content.
Parameters
Example
Tips
- Prefer this over
tapfor WebView DOM interactions — it's faster and more reliable. - WebViews are auto-registered by the babel plugin. Use
getRegisteredWebViewIds()to discover available IDs. - The script must evaluate to a value to return a result. End with a string or expression.
get_component_source
Resolve a component to its source location (file path, line, column) using React's _debugStack and the Metro source map. Use a selector or a uid from take_snapshot. Useful for "open this component in the editor" or token-efficient code navigation.
Parameters
Example
Tips
- App source is preferred: frames from
node_modules/react,node_modules/react-native, or the runtime are skipped when an app file is available. - Use this to jump to the right file and line when an AI or user asks to "edit this component" without searching the codebase.