Skip to main content
Glama

debugger-component-tree

Read-only

Fetches a running React Native app's current screen as a compact component tree with names, text, testIDs, and tap coordinates, helping debug UI structure and build selectors.

Instructions

Fetch the current screen of a running React Native app as a compact tree of React components. Each on-screen component is listed with its name, its text (or accessibilityLabel when it has no text), [testID=…] and its center as (tap: x,y) fractions of the screen. Full-screen transparent wrappers and implementation-detail components are pruned. Wrappers the size of their parent are pruned too, so a missing name proves nothing: check with debugger-inspect-element.

Use when you need what describe does not show: a testID for a selector (on Android, describe omits the testID of a view that has no label and is not tappable), or the component names and nesting behind the screen before editing code. To find what to tap, use describe.

Returns a compact text tree; call again after navigation. Fails if the Metro debugger is disconnected.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "device_id": "<device_id>"
    },
    "name": "debugger-component-tree"
  }
}

Input Schema

NameRequiredDescriptionDefault
portNoMetro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. Range: 1 to 65535.
maxNodesNoMaximum total nodes to include. When exceeded, intermediate single-child wrapper chains are collapsed to preserve both root structure and leaf elements. Default: no limit.
device_idYesDevice id used with debugger-connect.
onScreenOnlyNoWhen true, only components visible on screen are returned. Set to false to include all mounted components, including those scrolled off-screen, e.g. to understand the full page structure. Default: true.
includeSkippedNoWhen true, appends a summary of all filtered components: total fiber count and skip counts by component name and by filter. Default: false.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changed
    • changedInput schema / properties / device_id / description
      Previous value: -"Device id from list-devices — the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial)."New value: +"Device id used with debugger-connect."
    • changedInput schema / properties / includeSkipped / description
      Previous value: -"When true, appends a summary of all filtered components: total fiber count, JS-side skip counts by name, and TS-side filter pass removals. Useful for understanding what was pruned from the tree."New value: +"When true, appends a summary of all filtered components: total fiber count and skip counts by component name and by filter. Default: false."
    • changedInput schema / properties / onScreenOnly / description
      Previous value: -"When true (default), only components visible on screen are returned. Set to false to include all mounted components including those scrolled off-screen. Useful when you need to understand the full page structure."New value: +"When true, only components visible on screen are returned. Set to false to include all mounted components, including those scrolled off-screen, e.g. to understand the full page structure. Default: true."
    • changedInput schema / properties / port / description
      Previous value: -"Metro server port. Optional — omit it to use this device's port, 8081 by default. Ignored for Chromium, whose CDP port is encoded in device_id."New value: +"Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. Range: 1 to 65535."
    • removedInput schema / properties / udid
      Removed value: -{
      -  "description": "iOS simulator UDID from list-devices. Pass it when device_id is a logicalDeviceId (two or more devices share one Metro), so that the tap coordinates of a landscape UI are on the screen's axes. Give the UDID of the simulator that shows the app.",
      -  "type": "string"
      -}
  2. Changed1 schema field changedv0.27.0
    • changedInput schema / properties / udid / description
      Previous value: -"iOS simulator UDID from list-devices. Pass it when device_id is a logicalDeviceId (two or more devices share one Metro), so that the tap coordinates of a landscape UI are on the screen's axes."New value: +"iOS simulator UDID from list-devices. Pass it when device_id is a logicalDeviceId (two or more devices share one Metro), so that the tap coordinates of a landscape UI are on the screen's axes. Give the UDID of the simulator that shows the app."
  3. Changed1 schema field changedv0.26.0
    • addedInput schema / properties / udid
      Added value: +{
      +  "description": "iOS simulator UDID from list-devices. Pass it when device_id is a logicalDeviceId (two or more devices share one Metro), so that the tap coordinates of a landscape UI are on the screen's axes.",
      +  "type": "string"
      +}
  4. Changed5 schema fields changedv0.25.0
    • removedInput schema / properties / port / default
      Removed value: -8081
    • changedInput schema / properties / port / description
      Previous value: -"Metro server port"New value: +"Metro server port. Optional — omit it to use this device's port, 8081 by default. Ignored for Chromium, whose CDP port is encoded in device_id."
    • addedInput schema / properties / port / maximum
      Added value: +65535
    • addedInput schema / properties / port / minimum
      Added value: +1
    • changedInput schema / properties / port / type
      Previous value: -"number"New value: +"integer"
  5. Changed1 schema field changedv0.17.0
    • changedInput schema / properties / device_id / description
      Previous value: -"Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."New value: +"Device id from list-devices — the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial)."
  6. First observedv0.15.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnlyHint=true; the description adds substantial behavior beyond that: pruning rules for full-screen transparent wrappers, same-size-as-parent wrappers, and implementation-detail components, plus the important caveat that a missing name proves nothing. It also discloses the return shape, the need to re-call after navigation, and the failure condition when Metro is disconnected.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action and node format, then usage, then return/failure behavior — a sensible information order with no filler. It is on the longer side for a fetch tool, but nearly every clause carries operational information; only the pruning caveat is stated at slightly more length than strictly needed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by describing the returned compact text tree field-by-field and noting it must be re-fetched after navigation. Given a 5-parameter tool with full schema coverage and a read-only annotation, nothing an agent needs to invoke or interpret the result is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so port, maxNodes, onScreenOnly, includeSkipped, and device_id are already fully documented in the schema; that sets the baseline at 3. The description adds no parameter-level meaning (it never references onScreenOnly or includeSkipped despite describing pruning), so it neither compensates nor detracts.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Fetch the current screen of a running React Native app as a compact tree of React components', and immediately enumerates what each node contains (name, text/accessibilityLabel, testID, tap coordinates). It explicitly distinguishes itself from siblings describe and debugger-inspect-element, so an agent can route correctly without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit when-to-use: 'Use when you need what describe does not show', with a concrete motivating case (missing testID on Android for unlabeled, non-tappable views) and a pre-edit-code use case. It also states when NOT to use it ('To find what to tap, use describe') and where to go when the tree is pruned ('check with debugger-inspect-element').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.