You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 21a46eb
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -335,16 +335,35 @@ The tool console in this sandbox stands in for Chrome DevTools MCP so you can tr
335
335
336
336
### Tools {/*tools*/}
337
337
338
-
`react-devtools-cdt-mcp` registers a tool group called `react` with the following tools. Your agent calls them through Chrome DevTools MCP.
338
+
`react-devtools-cdt-mcp` registers a tool group called `react`. Your agent calls these tools through Chrome DevTools MCP.
339
339
340
-
Components are identified by short, stable uids like `"r5"`. A uid stays the same across every tool and across re-renders, but not across page reloads. Get uids from [`react_get_component_tree`](#react_get_component_tree) or [`react_find_components`](#react_find_components).
340
+
Components are identified by short, stable uids like `"r5"`. A uid stays the same across every tool and across re-renders, but not across page reloads. Every tool returns a plain, serializable value described in [Types](#types), or a [`ToolError`](#types) if it fails.
341
341
342
-
Every tool returns a plain, serializable value. If a tool fails, it returns a `ToolError` instead. The return types below use these shared types:
342
+
These tools find components and read their data:
343
+
344
+
* <span id="react_get_component_tree" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_component_tree`: Returns a snapshot of the component tree of every mounted root as a [`ComponentTree`](#types). Takes an optional `depth` (defaults to `20`) and an optional `rootUid` to start from a specific component.
345
+
* <span id="react_find_components" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_find_components`: Finds components whose name contains `name`, ignoring case, and returns a paginated [`FindComponentsResult`](#types). Takes an optional `rootUid` to search only a subtree, `page` (defaults to `1`), and `pageSize` (defaults to `10`).
346
+
* <span id="react_get_component_by_uid" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_component_by_uid`: Returns the props of the component with the given `uid` as a [`ComponentDetails`](#types). Pass `includeHooks: true` to also inspect the Hooks of function, `forwardRef`, and `memo` components. To read Hook values, React DevTools calls the component's render function again, so keep your [components pure](/learn/keeping-components-pure).
347
+
* <span id="react_get_component_by_dom_element" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_component_by_dom_element`: Returns the host component, like a `<button>`, that React rendered for a DOM `element` as a [`ComponentDetails`](#types). Chrome DevTools MCP clients pass `element` as `{uid}`, using an element uid from the page snapshot.
348
+
349
+
These tools explain where a component is mounted and which code created it. The **parent** of a component is where it's mounted in the tree. The **owner** is the component that created it in its JSX. For example, in `<Card><Avatar /></Card>` written inside `Profile`, `Avatar`'s parent is `Card` but its owner is `Profile`.
350
+
351
+
* <span id="react_get_parent_stack" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_parent_stack`: Returns the parents of the component with the given `uid`, from its immediate parent up to the root, as an array of [`ComponentBranchEntry`](#types). Parents can include host components and the root.
352
+
* <span id="react_get_owner_stack" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_owner_stack`: Returns the owners of the component with the given `uid`, from its immediate owner up to the root owner, as an array of [`ComponentBranchEntry`](#types). The array is empty in production builds.
353
+
* <span id="react_get_owner_stack_trace" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_owner_stack_trace`: Returns the [owner stack](/reference/react/captureOwnerStack) of the component with the given `uid` as an [`OwnerStackTrace`](#types): the JSX call sites that created it, in the same format as an `Error` stack. The stack is empty in production builds.
354
+
* <span id="react_get_component_source" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_component_source`: Returns where the component with the given `uid` is defined as a [`ComponentSource`](#types). The location is `null` for host components and in production builds, and may need source maps to map back to your files.
355
+
356
+
These tools record render timing, like the Profiler tab in React DevTools:
357
+
358
+
* <span id="react_start_profiling" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_start_profiling`: Starts recording render timing for every commit and returns a [`ProfilingStatus`](#types). Takes an optional `traceName`. Returns a `ToolError` if a profiling session is already running.
359
+
* <span id="react_stop_profiling" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_stop_profiling`: Stops the running profiling session and returns a [`ProfilingStatus`](#types) with the number of recorded commits. Returns a `ToolError` if no profiling session is running.
360
+
* <span id="react_get_trace_overview" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_trace_overview`: Returns one [`CommitSummary`](#types) per commit in the trace named `traceName`.
361
+
* <span id="react_get_commit_report" style={{scrollMarginTop: 'calc(4rem + 20px)'}} />`react_get_commit_report`: Returns the components that rendered in commit `commitIndex` of the trace named `traceName`, and how long each took, as a [`CommitReport`](#types). Commit indexes start from `0`.
*`hooks` is only returned for function, `forwardRef`, and `memo` components.
445
-
* Prop and Hook values are normalized so they can be serialized.
446
-
* To read Hook values, React DevTools calls the component's render function again. Effects don't run, but side effects in the render body itself do. This is one more reason to keep [components pure](/learn/keeping-components-pure).
Returns the React host component for a DOM element, for example the `<button>` that React rendered. To find the component that rendered it, pass the returned `uid` to [`react_get_owner_stack`](#react_get_owner_stack).
*`element`: A DOM element in the page. Chrome DevTools MCP clients pass `{uid}`, using an element uid from the page snapshot, and Chrome DevTools MCP resolves it to the element.
Returns where a component is mounted in the rendered tree, from its immediate parent up to the root. Parents can include host components and the root itself.
Returns the components that created this one through JSX, from its immediate owner up to the root owner.
487
-
488
-
<Note>
489
-
490
-
The **parent** of a component is where it's mounted in the tree. The **owner** is the component that created it in its JSX. For example, in `<Card><Avatar /></Card>` written inside `Profile`, `Avatar`'s parent is `Card` but its owner is `Profile`.
`source` is `null` for host components and in production builds. The location points at the code the browser loaded, so it may need source maps to map back to your files.
Starts recording render timing for every commit, like the Profiler tab in React DevTools. Stop recording with [`react_stop_profiling`](#react_stop_profiling).
0 commit comments