Skip to content

feat: add get_css_style tool - #2612

Merged
samiyac merged 1 commit into
mainfrom
investigating-styles
Sep 11, 2026
Merged

samiyac merged 1 commit into
mainfrom
investigating-styles

Conversation

@samiyac

@samiyac samiyac commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Add get_css_styles tool which exposes matched styles and the CSS cascade to empower accurate CSS debugging workflows.

It integrates CssFormatter into McpPage and McpResponse, adding container query resolution and rule pagination support.

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left a few comments on the overall approach.

Comment thread src/tools/css.ts Outdated
Comment thread src/tools/css.ts Outdated
Comment thread src/McpPage.ts Outdated
Comment thread src/McpPage.ts Outdated
Comment thread src/McpPage.ts Outdated
Comment thread src/McpPage.ts Outdated
@samiyac
samiyac marked this pull request as draft August 25, 2026 11:26
@samiyac
samiyac force-pushed the investigating-styles branch from 7cb36c4 to 10b738d Compare September 1, 2026 17:47
@samiyac samiyac changed the title draft feat: get_css_style tool feat: get_css_style tool Sep 1, 2026
@samiyac
samiyac force-pushed the investigating-styles branch 2 times, most recently from c8c85cf to 05a29ca Compare September 1, 2026 21:15
@samiyac
samiyac marked this pull request as ready for review September 1, 2026 21:15
Comment thread src/formatters/CssFormatter.ts Outdated
Comment thread src/formatters/CssFormatter.ts Outdated
Comment thread tests/formatters/CssFormatter.test.ts Outdated
Comment thread tests/tools/css.test.ts Outdated
@samiyac
samiyac force-pushed the investigating-styles branch 2 times, most recently from 05a29ca to 77bd916 Compare September 2, 2026 11:12
Comment thread src/formatters/CssFormatter.ts Outdated
@samiyac
samiyac force-pushed the investigating-styles branch 2 times, most recently from cd9dfe1 to e04d2ba Compare September 7, 2026 13:28
Comment thread tests/tools/css.test.ts Outdated
@samiyac
samiyac force-pushed the investigating-styles branch 2 times, most recently from 188bbba to 445b4d2 Compare September 8, 2026 07:06
@OrKoN

OrKoN commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

A few comments from AI-review:

Code Style & Guidelines Compliance (AGENTS.md)

1. TypeScript Rules: as Keyword Usage

AGENTS.md specifies:

│ • Do not use as keyword for type casting.

In CssFormatter.test.ts, as unknown as ... is used repeatedly:

• createMockNode: as unknown as DevTools.DOMModel.DOMNode
• createMockProperty: as unknown as StyleProperty
• createMockStyle: as unknown as NodeStyle
• createMockMatchedStyles: as unknown as MatchedStyles

2. Mocking Guidelines

AGENTS.md specifies:

│
│ • Use sinon.createStubInstance(Class): Do not hand-roll mock objects or define custom mock interfaces.
│ • Centralize mocks in tests/mocks.ts.

In CssFormatter.test.ts, mock factories (createMockMatchedStyles, createMockRule, createMockStyle, createMockProperty) are hand-rolled using Object.create(Prototype) and contain simulated state logic (e.g.
isInherited: (style) => inheritedStylesSet.has(style)). They should leverage sinon.createStubInstance().
──────

Test Suite Performance

In McpPage.test.ts:

• There are 4 separate withMcpContext tests:
1. retrieves matched styles for a page element
2. retrieves matched styles for nodes inside open shadow roots
3. retrieves matched styles for nodes inside closed shadow roots
4. retrieves matched styles for nodes inside iframes
• Each test launches a separate Chromium process, opens a route, and creates a snapshot.
• Suggestion: Combine these test cases into a single HTML route (containing regular elements, open shadow root, closed shadow root, and an iframe). Testing all 4 scenarios in one browser session could save
multiple seconds on test execution.

@samiyac
samiyac force-pushed the investigating-styles branch 2 times, most recently from 5a56b96 to 8bfe09a Compare September 8, 2026 14:48
@samiyac
samiyac force-pushed the investigating-styles branch from 8bfe09a to f5ea9d3 Compare September 10, 2026 09:12
@samiyac
samiyac changed the base branch from main to css-formatter-pt6 September 10, 2026 09:12
@samiyac
samiyac added this pull request to stack #2714 September 10, 2026 09:12
@samiyac samiyac changed the title feat: get_css_style tool feat: add get_css_style tool Sep 10, 2026
@samiyac
samiyac force-pushed the investigating-styles branch from f5ea9d3 to ef9a7d8 Compare September 10, 2026 09:40
Base automatically changed from css-formatter-pt6 to main September 10, 2026 21:16
@samiyac
samiyac force-pushed the investigating-styles branch from ef9a7d8 to 92fffe2 Compare September 10, 2026 21:41
@samiyac
samiyac added this pull request to the merge queue Sep 11, 2026
Merged via the queue into main with commit 4454ae0 Sep 11, 2026
23 checks passed
@samiyac
samiyac deleted the investigating-styles branch September 11, 2026 08:14
pull Bot pushed a commit to oogalieboogalie/chrome-devtools-mcp that referenced this pull request Sep 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.10.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.9.0...chrome-devtools-mcp-v1.10.0)
(2026-09-23)


### 🎉 Features

* add css formatter class
([ChromeDevTools#2707](ChromeDevTools#2707))
([f0b5fa4](ChromeDevTools@f0b5fa4))
* add get_css_style tool
([ChromeDevTools#2612](ChromeDevTools#2612))
([4454ae0](ChromeDevTools@4454ae0))
* **performance:** chunked trace buffer parser for large recordings
([ChromeDevTools#2721](ChromeDevTools#2721))
([23b9a48](ChromeDevTools@23b9a48))
* set default pageSize and pageIdx for get_css_styles tool
([ChromeDevTools#2799](ChromeDevTools#2799))
([dc9d14d](ChromeDevTools@dc9d14d))
* support config file
([ChromeDevTools#2661](ChromeDevTools#2661))
([314a5fa](ChromeDevTools@314a5fa))
* **telemetry:** persist date of the last tool call.
([ChromeDevTools#2705](ChromeDevTools#2705))
([c54a493](ChromeDevTools@c54a493))
* **telemetry:** recording a sanitized version of the client name
([ChromeDevTools#2757](ChromeDevTools#2757))
([55fbc57](ChromeDevTools@55fbc57))
* **telemetry:** report hermes client usage.
([ChromeDevTools#2703](ChromeDevTools#2703))
([fb47e6c](ChromeDevTools@fb47e6c))
* update css formatter class to add AtRule, PositionTryRule,
PropertyRule, FunctionRule
([ChromeDevTools#2717](ChromeDevTools#2717))
([d4a0620](ChromeDevTools@d4a0620))
* update css formatter class to add inherited rules
([ChromeDevTools#2715](ChromeDevTools#2715))
([3d7e7bb](ChromeDevTools@3d7e7bb))
* update css formatter class to add matched rules
([ChromeDevTools#2713](ChromeDevTools#2713))
([8c8616f](ChromeDevTools@8c8616f))
* update css formatter class to add pseudo element
([ChromeDevTools#2716](ChromeDevTools#2716))
([df1469a](ChromeDevTools@df1469a))
* update css formatter to add keyframes rules
([ChromeDevTools#2718](ChromeDevTools#2718))
([cdc365c](ChromeDevTools@cdc365c))


### 🛠️ Fixes

* bound ConsoleCollector retention per navigation
([ChromeDevTools#2773](ChromeDevTools#2773))
([e98a3ca](ChromeDevTools@e98a3ca))
* **cli:** forward explicit false options on start
([ChromeDevTools#2702](ChromeDevTools#2702))
([d9a8cb6](ChromeDevTools@d9a8cb6))
* **config:** preserve raw values for config coercion
([ChromeDevTools#2747](ChromeDevTools#2747))
([906c83b](ChromeDevTools@906c83b))
* don't log Puppeteer logs to file unless requested
([ChromeDevTools#2743](ChromeDevTools#2743))
([4fbfbc4](ChromeDevTools@4fbfbc4))
* explain launch failures caused by running as root
([ChromeDevTools#2634](ChromeDevTools#2634))
([9d29223](ChromeDevTools@9d29223))
* handle JavaScript dialogs opened during input tool actions
([ChromeDevTools#2794](ChromeDevTools#2794))
([266112b](ChromeDevTools@266112b))
* **performance:** prevent memory leak by scoping trace engine model per
parse
([ChromeDevTools#2720](ChromeDevTools#2720))
([d05cbc0](ChromeDevTools@d05cbc0))
* preserve console history across same-document navigations
([ChromeDevTools#2676](ChromeDevTools#2676))
([aa25562](ChromeDevTools@aa25562))
* preserve underlying error message in input tool actions
([ChromeDevTools#2792](ChromeDevTools#2792))
([6e47dbb](ChromeDevTools@6e47dbb))
* set emulatedUserAgent and use finalDisplayedUrl in lighthouse_audit
([ChromeDevTools#2795](ChromeDevTools#2795))
([941f82a](ChromeDevTools@941f82a))
* timout in WaitForHelper.ts
([ChromeDevTools#2772](ChromeDevTools#2772))
([dc1d055](ChromeDevTools@dc1d055))


### 📄 Documentation

* add FLUJO client configuration
([ChromeDevTools#2690](ChromeDevTools#2690))
([65a679e](ChromeDevTools@65a679e))
* fix categories not being configured correclty
([ChromeDevTools#2807](ChromeDevTools#2807))
([2250cdc](ChromeDevTools@2250cdc))
* fix defaults for non-boolean values
([ChromeDevTools#2744](ChromeDevTools#2744))
([342d243](ChromeDevTools@342d243))
* update page routing option name
([ChromeDevTools#2748](ChromeDevTools#2748))
([8939965](ChromeDevTools@8939965))
* update SKILL for chrome-devtools to use get_css_styles tool
([ChromeDevTools#2760](ChromeDevTools#2760))
([421011e](ChromeDevTools@421011e))


### 🏗️ Refactor

* disable tools instead of not registering them
([ChromeDevTools#2636](ChromeDevTools#2636))
([b455469](ChromeDevTools@b455469))
* extract browser in a BrowserManager class
([ChromeDevTools#2787](ChromeDevTools#2787))
([3228f44](ChromeDevTools@3228f44))
* migrate the MCP SDK to v2
([ChromeDevTools#2408](ChromeDevTools#2408))
([da3c406](ChromeDevTools@da3c406))
* move comments formatting to CommentFormatter class
([ChromeDevTools#2719](ChromeDevTools#2719))
([e3cded0](ChromeDevTools@e3cded0))
* prepare for SDK v2
([ChromeDevTools#2771](ChromeDevTools#2771))
([61780c7](ChromeDevTools@61780c7))
* simplify our gen scritps
([ChromeDevTools#2793](ChromeDevTools#2793))
([5068584](ChromeDevTools@5068584))
* unify call type and ensure typesafety
([ChromeDevTools#2659](ChromeDevTools#2659))
([882f93e](ChromeDevTools@882f93e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants