Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 62 additions & 62 deletions src/content/reference/dev-tools/react-devtools-cdt-mcp.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: React DevTools for agents
title: 에이전트를 위한 React DevTools
version: experimental
---

<Experimental>

**`react-devtools-cdt-mcp` is experimental.** It is built on the [experimental third-party developer tools API](https://developer.chrome.com/blog/devtools-for-agents-3p-tools) in [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp), and both its tools and their output may change between releases.
**`react-devtools-cdt-mcp`는 실험적 기능입니다.** [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp)의 [실험적인 서드 파티 개발자 도구 API](https://developer.chrome.com/blog/devtools-for-agents-3p-tools)를 기반으로 만들어졌으며, 도구와 그 출력은 릴리스마다 바뀔 수 있습니다.

</Experimental>

<Intro>

`react-devtools-cdt-mcp` gives AI coding agents the same view of your app that React DevTools gives you: the component tree, props, hooks, owners, source locations, and render timing.
`react-devtools-cdt-mcp`는 React DevTools가 개발자에게 보여주는 앱의 모습을 AI 코딩 에이전트에게도 똑같이 보여줍니다. 컴포넌트 트리, Props, Hook, Owner, 소스 위치, 렌더링 시간을 볼 수 있습니다.

```js
import 'react-devtools-cdt-mcp/register';
Expand All @@ -23,33 +23,33 @@ import 'react-devtools-cdt-mcp/register';

---

## Overview {/*overview*/}
## 개요 {/*overview*/}

Coding agents that drive a browser through [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) can click, take snapshots, and read the DOM, but the DOM doesn't tell them which component rendered a button, what state it holds, or why an interaction was slow.
[Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp)로 브라우저를 조작하는 코딩 에이전트는 클릭하고, 스냅숏을 찍고, DOM을 읽을 수 있습니다. 하지만 DOM만으로는 어떤 컴포넌트가 버튼을 렌더링했는지, 어떤 State를 가지고 있는지, 상호작용이 왜 느렸는지 알 수 없습니다.

`react-devtools-cdt-mcp` is a small browser library that you import into the page you're debugging. It registers a group of React tools with the page. When Chrome DevTools MCP connects to that page, it discovers the tools automatically, and your agent can call them like any other MCP tool.
`react-devtools-cdt-mcp`는 디버깅하려는 페이지에 불러오는 작은 브라우저 라이브러리입니다. 이 라이브러리는 페이지에 React 도구 그룹을 등록합니다. Chrome DevTools MCP가 해당 페이지에 연결되면 도구를 자동으로 찾아내고, 에이전트는 다른 MCP 도구처럼 이 도구를 호출할 수 있습니다.

<Note>

`react-devtools-cdt-mcp` is **not** an MCP server, and it doesn't go in your MCP client config. It runs inside your page. The only MCP server you configure is Chrome DevTools MCP.
`react-devtools-cdt-mcp`는 MCP 서버가 **아니며**, MCP 클라이언트 설정에 추가하지 않습니다. 페이지 안에서 실행됩니다. 설정해야 하는 MCP 서버는 Chrome DevTools MCP 하나뿐입니다.

</Note>

---

## Setup {/*setup*/}
## 설정 {/*setup*/}

#### Install the package {/*install-the-package*/}
#### 패키지 설치하기 {/*install-the-package*/}

<TerminalBlock>

npm install --save-dev react-devtools-cdt-mcp

</TerminalBlock>

#### Import it before React {/*import-it-before-react*/}
#### React보다 먼저 불러오기 {/*import-it-before-react*/}

Import the `register` entry point at the very top of your app's entry file, **before** anything imports `react-dom`:
앱의 진입 파일 맨 위, 즉 어떤 코드보다도 `react-dom`을 불러오기 **전에** `register` 진입점을 불러오세요.

```js {1}
import 'react-devtools-cdt-mcp/register';
Expand All @@ -60,31 +60,31 @@ import App from './App';
createRoot(document.getElementById('root')).render(<App />);
```

`react-devtools-cdt-mcp` has to load before React does. If you import it after React, the tools won't see your components.
`react-devtools-cdt-mcp`는 React보다 먼저 로드되어야 합니다. React 다음에 불러오면 도구가 컴포넌트를 찾지 못합니다.

<Pitfall>

`react-devtools-cdt-mcp` connects to React the same way the React DevTools extension does, and makes React report every commit to it. This slows down your app, so only include it in development builds.
`react-devtools-cdt-mcp`는 React DevTools 확장 프로그램과 같은 방식으로 React에 연결되며, React가 모든 커밋을 자신에게 보고하도록 합니다. 이 때문에 앱이 느려지므로 개발 빌드에만 포함하세요.

</Pitfall>

#### Set up Chrome DevTools MCP {/*set-up-chrome-devtools-mcp*/}
#### Chrome DevTools MCP 설정하기 {/*set-up-chrome-devtools-mcp*/}

Your agent needs [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) with [third-party developer tools](https://developer.chrome.com/blog/devtools-for-agents-3p-tools) enabled. Follow the [Chrome DevTools MCP docs](https://github.com/ChromeDevTools/chrome-devtools-mcp#getting-started) to set it up. Once your agent opens a page that imports `react-devtools-cdt-mcp/register`, it can list and call the React tools.
에이전트에는 [서드 파티 개발자 도구](https://developer.chrome.com/blog/devtools-for-agents-3p-tools)가 활성화된 [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp)가 필요합니다. [Chrome DevTools MCP 문서](https://github.com/ChromeDevTools/chrome-devtools-mcp#getting-started)를 따라 설정하세요. 에이전트가 `react-devtools-cdt-mcp/register`를 불러오는 페이지를 열면 React 도구 목록을 확인하고 호출할 수 있습니다.

---

## Try it {/*try-it*/}
## 직접 해보기 {/*try-it*/}

You don't need an agent to see what the tools return. The sandbox below imports `react-devtools-cdt-mcp/register` exactly as you would in your app, and adds a small **tool console** under the app. The console discovers the React tools the same way Chrome DevTools MCP does, by dispatching the `devtoolstooldiscovery` event, and lets you call them by hand.
도구가 무엇을 반환하는지 보는 데 에이전트가 꼭 필요하지는 않습니다. 아래 샌드박스는 앱에서와 똑같이 `react-devtools-cdt-mcp/register`를 불러오고, 앱 아래에 작은 **도구 콘솔**을 추가합니다. 이 콘솔은 Chrome DevTools MCP와 같은 방식, 즉 `devtoolstooldiscovery` 이벤트를 디스패치하는 방식으로 React 도구를 찾아내고 직접 호출할 수 있게 해줍니다.

Pick a tool, edit the JSON parameters, and press **Run tool**. Here's a debugging session to follow, playing the agent's part:
도구를 고르고 JSON 매개변수를 수정한 다음 **Run tool**을 누르세요. 에이전트 역할을 맡아 따라 해볼 수 있는 디버깅 과정은 다음과 같습니다.

1. **Find a component.** Run `react_find_components` with `{"name": "Row"}`. Each result has a `uid`, like `"r12"`, that the other tools accept.
2. **Inspect it.** Run `react_get_component_by_uid` with one of those uids and `"includeHooks": true` to see its props and hooks.
3. **Start from the screen.** Choose `react_get_component_by_dom_element`, press **Pick element**, and click a product in the list to get the host component that rendered it.
4. **Profile an interaction.** Run `react_start_profiling`, click **Add to cart** in the app, then run `react_stop_profiling`.
5. **See what rendered.** Run `react_get_trace_overview`, then `react_get_commit_report` for commit `0` to see which components rendered in that commit and how long each one took.
1. **컴포넌트 찾기.** `{"name": "Row"}`로 `react_find_components`를 실행하세요. 각 결과에는 `"r12"` 같은 `uid`가 있으며, 다른 도구에서도 이 값을 사용할 수 있습니다.
2. **살펴보기.** 그중 하나의 uid와 `"includeHooks": true`로 `react_get_component_by_uid`를 실행해 Props와 Hook을 확인하세요.
3. **화면에서 시작하기.** `react_get_component_by_dom_element`를 선택하고 **Pick element**를 누른 다음, 목록에서 상품 하나를 클릭해 그 상품을 렌더링한 호스트 컴포넌트를 가져오세요.
4. **상호작용 프로파일링하기.** `react_start_profiling`을 실행하고 앱에서 **Add to cart**를 클릭한 다음 `react_stop_profiling`을 실행하세요.
5. **렌더링된 것 확인하기.** `react_get_trace_overview`를 실행한 다음 커밋 `0`에 대해 `react_get_commit_report`를 실행해 해당 커밋에서 어떤 컴포넌트가 렌더링되었고 각각 얼마나 걸렸는지 확인하세요.

<Sandpack>

Expand Down Expand Up @@ -325,83 +325,83 @@ ul { padding-left: 20px; max-height: 160px; overflow: auto; }

<Note>

The tool console in this sandbox stands in for Chrome DevTools MCP so you can try the tools on this page. In your own app, you don't write any of this code: Chrome DevTools MCP discovers the tools and your agent decides which ones to call.
이 샌드박스의 도구 콘솔은 이 페이지에서 도구를 직접 써볼 수 있도록 Chrome DevTools MCP를 대신합니다. 실제 앱에서는 이런 코드를 작성할 필요가 없습니다. Chrome DevTools MCP가 도구를 찾아내고, 어떤 도구를 호출할지는 에이전트가 결정합니다.

</Note>

---

## Reference {/*reference*/}
## 레퍼런스 {/*reference*/}

### Tools {/*tools*/}
### 도구 {/*tools*/}

`react-devtools-cdt-mcp` registers a tool group called `react`. Your agent calls these tools through Chrome DevTools MCP.
`react-devtools-cdt-mcp`는 `react`라는 도구 그룹을 등록합니다. 에이전트는 Chrome DevTools MCP를 통해 이 도구를 호출합니다.

* `react_get_component_tree`: Returns a snapshot of the component tree.
* `react_find_components`: Finds components by name.
* `react_get_component_by_uid`: Returns a component's props and Hooks.
* `react_get_component_by_dom_element`: Returns the React host component for a DOM element.
* `react_get_parent_stack`: Returns where a component is mounted in the tree.
* `react_get_owner_stack`: Returns the components that created a component in their JSX.
* `react_get_owner_stack_trace`: Returns the owner stack of a component as a stack trace.
* `react_get_component_source`: Returns where a component is defined.
* `react_start_profiling`: Starts recording render timing.
* `react_stop_profiling`: Stops recording render timing.
* `react_get_trace_overview`: Returns a summary of every commit in a recording.
* `react_get_commit_report`: Returns which components rendered in a commit and how long each took.
* `react_get_component_tree`: 컴포넌트 트리의 스냅숏을 반환합니다.
* `react_find_components`: 이름으로 컴포넌트를 찾습니다.
* `react_get_component_by_uid`: 컴포넌트의 Props와 Hook을 반환합니다.
* `react_get_component_by_dom_element`: DOM 엘리먼트에 해당하는 React 호스트 컴포넌트를 반환합니다.
* `react_get_parent_stack`: 컴포넌트가 트리의 어디에 마운트되어 있는지 반환합니다.
* `react_get_owner_stack`: JSX에서 해당 컴포넌트를 만든 컴포넌트들을 반환합니다.
* `react_get_owner_stack_trace`: 컴포넌트의 Owner 스택을 스택 트레이스 형태로 반환합니다.
* `react_get_component_source`: 컴포넌트가 정의된 위치를 반환합니다.
* `react_start_profiling`: 렌더링 시간 기록을 시작합니다.
* `react_stop_profiling`: 렌더링 시간 기록을 멈춥니다.
* `react_get_trace_overview`: 기록에 포함된 모든 커밋의 요약을 반환합니다.
* `react_get_commit_report`: 커밋에서 어떤 컴포넌트가 렌더링되었고 각각 얼마나 걸렸는지 반환합니다.

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.
컴포넌트는 `"r5"` 같은 짧고 안정적인 uid로 식별됩니다. uid는 모든 도구와 리렌더링에 걸쳐 유지되지만, 페이지를 새로 고치면 바뀝니다.

Every tool returns a plain, serializable object. If a tool fails, it returns an object with an `error` message instead.
모든 도구는 직렬화 가능한 일반 객체를 반환합니다. 도구가 실패하면 대신 `error` 메시지가 담긴 객체를 반환합니다.

---

### `register(target?)` {/*register*/}

Call `register` to install the React DevTools hook and register the React tools with Chrome DevTools MCP yourself, instead of importing `react-devtools-cdt-mcp/register`.
`react-devtools-cdt-mcp/register`를 불러오는 대신 직접 `register`를 호출해 React DevTools Hook을 설치하고 Chrome DevTools MCP에 React 도구를 등록할 수 있습니다.

```js
import { register } from 'react-devtools-cdt-mcp';

register();
```

#### Parameters {/*register-parameters*/}
#### 매개변수 {/*register-parameters*/}

* **optional** `target`: The global object to install the hook on. Defaults to `globalThis`.
* **선택 사항** `target`: Hook을 설치할 전역 객체입니다. 기본값은 `globalThis`입니다.

#### Returns {/*register-returns*/}
#### 반환값 {/*register-returns*/}

`register` returns an object with two properties:
`register`는 두 개의 프로퍼티를 가진 객체를 반환합니다.

* `facade`: The installed React DevTools hook and the state the tools read from.
* `unregister`: A function that stops registering the React tools with Chrome DevTools MCP.
* `facade`: 설치된 React DevTools Hook과 도구가 읽는 상태입니다.
* `unregister`: Chrome DevTools MCP에 React 도구를 등록하는 것을 멈추는 함수입니다.

#### Caveats {/*register-caveats*/}
#### 주의 사항 {/*register-caveats*/}

* Call `register` before React initializes, or React won't connect to the hook.
* Calling `register` again for the same `target` returns the existing registration.
* React가 초기화되기 전에 `register`를 호출하세요. 그렇지 않으면 React가 Hook에 연결되지 않습니다.
* 같은 `target`에 대해 `register`를 다시 호출하면 기존 등록을 반환합니다.

---

## Troubleshooting {/*troubleshooting*/}
## 문제 해결 {/*troubleshooting*/}

#### My agent doesn't see any React tools {/*my-agent-doesnt-see-any-react-tools*/}
#### 에이전트가 React 도구를 찾지 못합니다 {/*my-agent-doesnt-see-any-react-tools*/}

Check that [third-party developer tools](https://developer.chrome.com/blog/devtools-for-agents-3p-tools) are enabled in your Chrome DevTools MCP setup. Then check that the page selected in Chrome DevTools MCP imports `react-devtools-cdt-mcp/register`. The tools are discovered per page, when the page loads or is selected.
Chrome DevTools MCP 설정에서 [서드 파티 개발자 도구](https://developer.chrome.com/blog/devtools-for-agents-3p-tools)가 활성화되어 있는지 확인하세요. 그다음 Chrome DevTools MCP에서 선택한 페이지가 `react-devtools-cdt-mcp/register`를 불러오는지 확인하세요. 도구는 페이지가 로드되거나 선택될 때 페이지별로 탐색됩니다.

#### The component tree is empty {/*the-component-tree-is-empty*/}
#### 컴포넌트 트리가 비어 있습니다 {/*the-component-tree-is-empty*/}

`react-devtools-cdt-mcp/register` was imported after React initialized. Move the import to the very first line of your entry file, before any import that loads `react-dom`.
React가 초기화된 후에 `react-devtools-cdt-mcp/register`를 불러온 경우입니다. `react-dom`을 불러오는 어떤 import보다도 앞서도록 진입 파일의 맨 첫 줄로 import를 옮기세요.

#### I'm getting an error about a browser-like environment {/*im-getting-an-error-about-a-browser-like-environment*/}
#### 브라우저와 유사한 환경에 관한 오류가 발생합니다 {/*im-getting-an-error-about-a-browser-like-environment*/}

`react-devtools-cdt-mcp/register` throws if it's imported outside a browser, for example during server rendering or in tests. Import it only from client-side code, or call `register()` from the package root yourself where it's safe.
`react-devtools-cdt-mcp/register`는 서버 렌더링 중이나 테스트처럼 브라우저 밖에서 불러오면 오류를 던집니다. 클라이언트 측 코드에서만 불러오거나, 안전한 곳에서 패키지 루트의 `register()`를 직접 호출하세요.

#### Source locations and owner stacks are empty {/*source-locations-and-owner-stacks-are-empty*/}
#### 소스 위치와 Owner 스택이 비어 있습니다 {/*source-locations-and-owner-stacks-are-empty*/}

This data only exists in development builds of React. Make sure you're running your app's development server rather than a production build.
이 데이터는 React의 개발 빌드에만 존재합니다. 프로덕션 빌드가 아닌 앱의 개발 서버를 실행하고 있는지 확인하세요.

#### A uid stopped working {/*a-uid-stopped-working*/}
#### uid가 더 이상 동작하지 않습니다 {/*a-uid-stopped-working*/}

Uids don't survive page reloads. After a reload, get fresh uids with `react_get_component_tree` or `react_find_components`.
uid는 페이지를 새로 고치면 유지되지 않습니다. 새로 고친 후에는 `react_get_component_tree`나 `react_find_components`로 새 uid를 가져오세요.
2 changes: 1 addition & 1 deletion src/sidebarReference.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
"path": "/reference/dev-tools/react-performance-tracks"
},
{
"title": "React DevTools for agents",
"title": "에이전트를 위한 React DevTools",
"path": "/reference/dev-tools/react-devtools-cdt-mcp",
"version": "experimental"
},
Expand Down