Repository navigation
Closed
Description
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.”
Reacted by Alex Rudenko, Jon Ludwig, Stanislav Publika, KIRK Axel, Rami, Uladzimir Palkhouski, Vincent Riemer and jitterbox
Activity
OrKoN commentedon Sep 24, 2025
Thanks for the feature request! I think it is useful to have dedicated tools to debug styles but first we need to think about a general mechanism for inspecting DOM and how it would interact with text snapshot.
Note that the current MCP version is able to inspect computed styles, box models and visibility by using the
evaluate_scripttool. Have you tried that? Did the example use cases no work for you?While we consider how to add these functions in the best way we are interesting in getting feedback from other users as well.
Munawwar commentedon Sep 24, 2025
Hi all. I am going to throw in a superset idea (or maybe it needs to be separate tools, idk). I built a fork of BrowserTools MCP with feature like this called
inspectElementsBySelector(with optional props). It gave a few things in one tool call.For each element it finds it sends:
outerHTML and bounding box dimensions (https://github.com/Munawwar/browser-tools-mcp/blob/main/chrome-extension/devtools.js#L1106). I should have added scroll dimensions (could be an option)
CSS rules that affects the element (https://github.com/Munawwar/browser-tools-mcp/blob/main/chrome-extension/devtools.js#L1271). The idea was to give the same view as the Elements > Styles tab of chrome dev tools (I was aiming exactly what a human would see .. I didnt 100% achieve it, but got close)
Optionally specific computed styles. i.e only if the tool call asks for specific computed style, else it doesn't send them back to reduce token usage (a single element can have a lot of computed styles)
Maybe I overdid it, but listing all the cascaded CSS rules that affects an element was the most useful for me personally to let LLMs debug issues. Outer HTML also helped in a few cases for LLM to figure out where elements are and what CSS classes was dynamically added by JS which wasn't obvious from code. And to a lesser extent specific computed styles.
$0was a special selector so that I could tell the LLM "debug on the element I have selected"jitterbox commentedon Sep 24, 2025
I've been using Playwright MCP's
browser_evaluate(same) for months... but it requires AI to repeatedly build generalized, DOM-walking one-off code like this on each tool call when troubleshooting style-related UI issues:Purpose-built endpoints would reduce token usage, resources, I/O, and allow simpler troubleshooting and comparisons just by reusing a
nodeIdacross tool requests within session state.A few examples... AI agents would discover and use these calls instead (much simpler)...
Single element triage:
Core facts in parallel:
Batch related nodes (target + context):
Rule origins for suspect properties:
Deterministic diffs (before/after state change):
Please check out PR #93, which implements the proposed tools.
OrKoN commentedon Sep 24, 2025
Thanks for the detailed feedback! Did you encounter any issues related to the fact that the MCP server does not expose the actual DOM tree to the client (and only the a11y tree)? Is it sufficient for your use case? And thanks for the PR. We have seen it and we will review the PR once we decide which direction we will go for this (generally though we would want to re-use code from the chrome-devtools-frontend dependency instead of re-implementing it again with direct CDP calls).
jitterbox commentedon Sep 24, 2025
The a11y tree alone works for our initial use cases, although having access to pseudo-elements, etc. will sometimes be important. Using chrome-devtools-frontend directly makes sense. Thanks for providing this!
kaladron commentedon Sep 25, 2025
Hi! In my case I'm trying to troubleshoot why some Angular styles aren't applying correctly. Gemini asked for this:
So the computed styles isn't enough. We need to see which styles aren't applied, and what order they're being evaluated in, etc.
Thanks!
jcludwig commentedon Oct 7, 2025
It would be great to get some structured information that appears to be available to devtools, but (AFAIK) is not available through JS. For example:
b10902118 commentedon Nov 22, 2025
I hacked CDP myself to build my mcp supporting DOM nodes, CSS rules, and computed style. In fact, I have been building library to handle CDP for months. Would like to discuss about this.
mcp: https://github.com/devtoolcss/chrome-inspector-mcp
CDP's DOM & CSS wrapper: https://github.com/devtoolcss/chrome-inspector
Yeah in theory this mcp can just run another DevTools core, but you'll be dealing with something more complicated than CDP. That's why I would rather build my own library. I also have seen this project started adopting raw CDP calls. Hope to learn about current direction.
betson-g commentedon Mar 13, 2026
Built a standalone MCP server that implements this — browser_inspect with a styles action uses CSS.getMatchedStylesForNode to return the full matched rules, source attribution, and computed values in a format shaped for LLM consumption.
Zero setup, works via npx. In case it's useful, while this gets prioritized: https://github.com/betson-uni/browser-inspector-mcp
feat: include computed styles in get_css_styles (ChromeDevTools#3538)
samiyac commentedon Nov 23, 2026
Marking this as fixed as the
get_css_stylestool returns matched styles and computed styles.