AI-powered React debugging with Playwright and MCP
View the Project on GitHub Lars-Albinsson/playwright-react-debug-mcp
Tools for examining page structure and element details.
Get a summarized DOM tree with selective depth traversal. Useful for understanding page structure without overwhelming output.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
selector |
string | No | Root element selector (default: body) |
maxDepth |
number | No | Maximum tree depth (default: 5) |
Response:
{
"tree": {
"tag": "body",
"children": [
{
"tag": "header",
"class": "site-header",
"children": [...]
},
{
"tag": "main",
"id": "content",
"children": [...]
}
]
}
}
Example:
Get the DOM tree for the main content area
Show me the structure of the navigation menu
Get detailed information about a specific element including computed styles, bounding box, and attributes.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
selector |
string | Yes | Element selector |
Response:
{
"tag": "button",
"id": "submit-btn",
"class": "btn btn-primary",
"text": "Submit",
"attributes": {
"type": "submit",
"disabled": "false",
"data-testid": "submit-button"
},
"boundingBox": {
"x": 100,
"y": 200,
"width": 120,
"height": 40
},
"computedStyles": {
"display": "inline-flex",
"backgroundColor": "rgb(59, 130, 246)",
"color": "rgb(255, 255, 255)",
"fontSize": "14px"
},
"isVisible": true,
"isEnabled": true
}
Example:
Get details about the submit button
What styles are applied to the error message?
Is the login button visible and enabled?
Extract visible text from elements matching a selector. Useful for verifying content or extracting data.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
selector |
string | Yes | Element selector |
all |
boolean | No | Get text from all matches (default: false) |
Response:
{
"text": "Welcome, John Doe",
"count": 1
}
Or with all: true:
{
"texts": [
"Item 1",
"Item 2",
"Item 3"
],
"count": 3
}
Example:
Get the text from all error messages on the page
What does the welcome message say?
Extract all list items from the sidebar
Get the DOM tree to understand the page layout
Returns a hierarchical view of elements, helping identify the structure without looking at raw HTML.
Get element details for the header to check its styles
Shows computed styles, making it easy to debug why elements don’t appear as expected.
Get the text content of all validation error messages
Extracts visible text to verify error messages, labels, or dynamic content.
Get the DOM tree for the form to find the right selectors
Helps identify the correct selectors for subsequent interactions.
Large pages can produce overwhelming output. Use maxDepth to limit:
Get the DOM tree with maxDepth 3 to see the high-level structure
Start from a specific container to reduce noise:
Get the DOM tree starting from the #sidebar element
Use get_element to verify if elements are visible and enabled before interaction:
Check if the submit button is visible and enabled