Skip to content

Feature Request: Support for computed styles #86

@jitterbox

Description

@jitterbox

Summary

Please add first-class support for retrieving computed CSS styles through the Chrome DevTools MCP server. Today the MCP surface lets an AI agent inspect DOM/attributes and take screenshots, but it cannot read the browser’s computed styles, which are essential for reliable layout/debugging automation.

Why this matters

  • LLMs need ground-truth layout data (final box model, visibility, z-index, display/position, resolved colors/margins/paddings) to diagnose “element not visible,” overlap, off-screen placement, or cascade/specificity issues.
  • Visual diffs alone miss subtle regressions (1–2px shifts, collapsed margins, inherited font changes).
  • Computed styles enable deterministic before/after comparisons during HMR or CI visual checks.

Requested capabilities (minimum viable)

  • Get computed styles for a node: resolved values for all properties (option to filter list).
  • Get box model metrics: content/padding/border/margin, client/offset/bounding rect, device-pixel-rounded values.
  • Visibility diagnostics: isVisible (accounting for display/visibility/opacity/clip/path, 0×0, off-viewport, overflow hidden).
  • Inheritance/precedence hints: which rule “wins” (selector + stylesheet URL/line), optional list of overridden declarations.
  • Batch mode: request multiple node IDs in one call for perf.
  • Diff helper (optional): server returns changed computed properties between two snapshots.

Sketch of API (illustrative)

  • dom.getComputedStyles({ nodeId, properties?: string[] }) -> { computed: Record<string,string>, sourceMap?: RuleOrigin[] }
  • dom.getBoxModel({ nodeId }) -> { content, padding, border, margin, clientRect, boundingRect }
  • dom.getVisibility({ nodeId }) -> { isVisible, reasons: string[] }
  • dom.getComputedStylesBatch({ nodeIds: string[] }) -> {...}

Example use cases

  • Verify a fix: “Confirm the button’s clickable area is ≥44×44 CSS px and vertically centered in its parent.”
  • Root-cause: “Why is .toast not visible after CSS changes?” (visibility + winning rule).
  • Regression diff in CI: “List computed properties that changed for #header vs. previous build.”

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions