Skip to main content
Glama

inspect_dom

Read-only

Progressive DOM inspection that reveals parent-child relationships, centering issues, spacing gaps, and scrollable containers. Start here for layout debugging.

Instructions

🔍 PRIMARY INSPECTION TOOL - START HERE FOR LAYOUT DEBUGGING: Progressive DOM inspection that shows parent-child relationships, centering issues, spacing gaps, and scrollable containers. Skips wrapper divs and shows only semantic elements (header, nav, main, form, button, elements with test IDs, ARIA roles, etc.).

WORKFLOW: Call without selector for page overview, then drill down by calling with child's selector.

DETECTS: Scrollable containers (shows "scrollable ↕️ 36px" when scrollHeight > clientHeight), parent-relative positioning, vertical/horizontal centering, sibling spacing gaps, layout patterns.

OUTPUT FORMAT:

[0] <button data-testid="menu">
    @ (16,8) 40×40px                         ← Absolute viewport position (x,y) and size
    from edges: ←16px →1144px ↑8px ↓8px      ← Distance from parent edges (↑8px = ↓8px means vertically centered)
    "Menu"
    ✓ visible, ⚡ interactive

[1] <div data-testid="title">
    @ (260,2) 131×28px
    from edges: ←244px →244px ↑2px ↓42px     ← Equal left/right (244px) = horizontally centered, unequal top/bottom = NOT vertically centered
    gap from [0]: →16px                      ← Spacing between siblings
    "Title"
    ✓ visible, 2 children

SYMBOLS: ✓=visible, ✗=hidden, ⚡=interactive, ←→=horizontal edges, ↑↓=vertical edges, ↕️=vertical scroll, ↔️=horizontal scroll CENTERING: Equal left/right distances = horizontally centered, equal top/bottom = vertically centered SCROLL DETECTION: Automatically detects scrollable containers and shows overflow amount (e.g., "scrollable ↕️ 397px" means 397px of hidden content). No need to use evaluate() to compare scrollHeight/clientHeight.

RELATED TOOLS: For comparing TWO elements' alignment (not parent-child), use compare_element_alignment(). For box model (padding/margin), use measure_element().

⚠️ More efficient than get_html() or evaluate() for structural analysis. Use BEFORE visual tools (screenshot) or evaluate(). Supports testid shortcuts.

NOTE: Dropdowns, listboxes, dialogs, and popovers (especially in react-aria/headless UI/Radix) are commonly portaled to document.body — when a combobox or menu is open, query at the root level (e.g. [role="listbox"], [role="dialog"]) rather than inside the trigger's subtree.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorNoCSS selector, text selector, or testid shorthand to inspect. Omit for page overview (defaults to body). Use 'testid:login-form', '#main', etc.
includeHiddenNoInclude hidden elements in results (default: false)
maxChildrenNoMaximum number of children to show (default: 20)
maxDepthNoMaximum depth to drill through non-semantic wrapper elements when looking for semantic children (default: 5). Increase for extremely deeply nested components, decrease to 1 to see only immediate children without drilling.
Behavior5/5

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

Annotations already declare readOnlyHint=true, matching the read-only inspection nature. Description adds rich behavioral details: skips wrapper divs, detects scrollable containers, identifies centering, explains portal behavior for dropdowns. No contradiction with annotations.

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?

Description is well-structured with clear sections (WORKFLOW, DETECTS, OUTPUT FORMAT, etc.) and front-loaded with the primary purpose. However, it is somewhat verbose; some details (symbols, full output format) could be shortened or moved to docs. Still, it earns its content.

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?

Given the complexity of the tool (progressive inspection, centering, scroll detection, portals) and no output schema, the description thoroughly explains behavior, output format, symbols, and special cases. Combined with good annotations and schema, it provides complete context for an AI agent.

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

Parameters4/5

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

Input schema has 100% description coverage. Description adds workflow context (default behavior without selector, testid shortcuts) and clarifies maxDepth usage. While schema already explains parameters, description adds value beyond schema for some parameters (e.g., maxDepth explanation), justifying a 4.

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?

Description clearly states it is the primary inspection tool for layout debugging, with specific verb 'inspect DOM' and resource 'DOM elements'. It distinguishes itself from siblings like compare_element_alignment and measure_element by describing its scope (parent-child relationships, centering, spacing gaps).

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?

Explicitly instructs to call without selector for overview and drill down with child's selector. Names alternative tools for alignment comparison and box model. Recommends using this before visual tools or evaluate(). Provides clear when-to-use and when-not-to-use guidance.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/antonzherdev/mcp-web-inspector'

If you have feedback or need assistance with the MCP directory API, please join our Discord server