Skip to content

A tool to "Select an element in the page to inspect it" #268

Description

@jjkavalam

Is your feature request related to a problem? Please describe.

Select an element in the page to inspect it could arguably be the most used Chrome Dev Tools "tool".

This allows the (human) programmer to focus on just that part of the DOM he is interested in. On the other hand, most tools we put in the hands of AI agents today always give back the full DOM. The AI is then forced to first filter out all the irrelevant parts leading to the context window filling up extremely fast, and the agent loop slowing down a lot.

Describe the solution you'd like

If this MCP server could implement something like Select an element in the page to inspect it, we can give the AI agents the same efficient method of inspecting the DOM.

I would imagine the AI can send an annotated screenshot as input; with a suitably coloured bounding box to indicate the region of the page the AI hopes to inspect.

Describe alternatives you've considered

Alternative solutions include a tool that allows the AI to specify a CSS selector, and the tool will return the DOM rooted at the corresponding element (instead of the whole page). But this does mean the selector be identified somehow first, which may not be easy. Working with a screenshot and placing a bounding box on the region of interest could be markedly more easy in certain cases.

Additional context

The Select an element in the page to inspect it tool in Chrome Dev Tools: Image

Activity

  1. natorion commented on Oct 6, 2025

    @natorion
    Contributor

    Do you mean that you can select an element/artifact in Chrome DevTools and use it as context in your MCP client?

  2. jjkavalam commented on Oct 6, 2025

    @jjkavalam
    Author

    Do you mean that you can select an element/artifact in Chrome DevTools and use it as context in your MCP client?

    @natorion No, i didn't mean, me, as a human user selecting. I meant giving the AI agent the ability to select DOM elements by position (as opposed to by a css selector).

  3. natorion commented on Oct 6, 2025

    @natorion
    Contributor

    Understood, so the human would then use the selected element to continue debugging on their own in DevTools?

  4. jjkavalam commented on Oct 6, 2025

    @jjkavalam
    Author

    Understood, so the human would then use the selected element to continue debugging on their own in DevTools?

    @natorion No, the idea is, this way, the AI agent can use its vision to select the part of the DOM it is interested in.

    What we have today is the AI agent first reading the DOM structure of the entire page (this can be massive and could use a lot of tokens very quickly) and then trying to figure out the subtree of interest.

    But, that is not how a human would debug typically. Because the human can use his vision and the Select an element in the page to inspect it in ChromeDevTools to quickly inspect just the part of the page he is interested in. The request here is to give the AI agents the same capabilities so that they can be more effective (in autonomous operation).

  5. jjkavalam commented on Oct 6, 2025

    @jjkavalam
    Author

    @natorion I see the confusion here. When i say, Select an element in the page to inspect it tool, i do NOT mean the AI agent interacting with the Chrome Dev Tools front end to select a DOM element for the human.

    What i mean is: What if we gave the AI agent a "virtual mouse pointer", if you will, so that it can use its vision to select DOM elements.

    Hope it clarifies the intent here.

  6. natorion commented on Oct 6, 2025

    @natorion
    Contributor

    Hmmm, in what prompts would you expect your MCP client make use of let's say select_element_visually(imageData, position) function?

  7. jjkavalam commented on Oct 6, 2025

    @jjkavalam
    Author

    Hmmm, in what prompts would you expect your MCP client make use of let's say select_element_visually(imageData, position) function?

    Consider,

    The "Delete" button is not aligned correctly on http://localhost:3000/my-complex-page. Could you fix it?
    

    The agent is likely to first attempt to "look" at the page, issuing some command that returns a dump of the page's DOM. But this could result in a lot of token usage (and potentially the context window filling up).

    So, instead if i could,

    The "Delete" button is not aligned correctly on http://localhost:3000/my-complex-page. Could you fix it?
    
    The page is complex and you might want to select the button's container visually to inspect its DOM.
    

    With this, the agent will hopefully take the cue and "look" at the page, issuing a screenshot command, leveraging its vision capability. And then following it up with "select_element_visually".

    To summarise, in cases where the page is large in terms of the number of DOM nodes, vision based selection, could give the agent a method that can scale irrespective of the DOM level complexity.

  8. natorion commented on Oct 6, 2025

    @natorion
    Contributor

    In this case you still would need to match the (marked) screenshot to the actual page, which could very well have changed visually in the meantime (consider elements slightly shading or flickering, or a video element, or a autoscrollig carousel.

    The IDs we generated or the A11y tree should be more resilient.

    Assuming the visual representation of the page is relevant and take_snapshot is not enough it might be more useful to be a good MCP server and help the client to make the decision: Add another parameter to take_screenshot called "overlayUIDs", which overlays UIDs visually like a map over the screenshot. This way the MCP client has the information where stuff on the page is located. I have no clue though, if MCP clients nowadays are smart enough to figure it out and what resolution you would need to provide a good enough map.

  9. jjkavalam commented on Oct 6, 2025

    @jjkavalam
    Author

    Actually, the overlay idea is a good alternative — it reminds me of the well-known Set-of-Marks prompting method.

    Staying on topic, though: I hadn't really thought through how the client could communicate to the Chrome DevTools MCP which element it wants to select.

    I'm curious how the "Select an element in the page to inspect it" feature in Chrome DevTools actually works. What's involved in translating the mouse pointer's position into the corresponding DOM element?

    My thinking is that, in all scenarios where a human benefits from inspecting the DOM with that tool, an AI agent could potentially benefit as well.

  10. natorion commented on Oct 6, 2025

    @natorion
    Contributor

    My thinking is that, in all scenarios where a human benefits from inspecting the DOM with that tool, an AI agent could potentially benefit as well.

    I think this is an example of difference in behavior between humans and AI agents. A human is a very visual entity, that will react timely to something on a screen.
    A typical MCP client will use a model that is not optimized for speed and image processing and will have a harder time figuring out stuff on the screen in a timely manner. Converting visual information to structured information that is less time-dependent (the map proposal above) would actually be a better input mechanism.

    This is just mental gymnastics at this point though, no clue if its actually useful.

  11. jjkavalam commented on Oct 6, 2025

    @jjkavalam
    Author

    @natorion Really appreciate you looking into this. Am glad I got a chance to explain my thinking too.

  12. natorion commented on Oct 9, 2025

    @natorion
    Contributor

    In this case you still would need to match the (marked) screenshot to the actual page, which could very well have changed visually in the meantime (consider elements slightly shading or flickering, or a video element, or a autoscrollig carousel.

    The IDs we generated or the A11y tree should be more resilient.

    Assuming the visual representation of the page is relevant and take_snapshot is not enough it might be more useful to be a good MCP server and help the client to make the decision: Add another parameter to take_screenshot called "overlayUIDs", which overlays UIDs visually like a map over the screenshot. This way the MCP client has the information where stuff on the page is located. I have no clue though, if MCP clients nowadays are smart enough to figure it out and what resolution you would need to provide a good enough map.

    Let's collect feedback if something like this would be useful for more people.

  13. jformio commented on Oct 11, 2025

    @jformio

    I would just add my use case to this ticket as well - coming more from a design -, than engineering, perspective (knowledge wise).

    Using a prompts like

    Check my current selection in the browser, help me replace that with my current selection in Figma

    or

    Help me change the background color of the current selection in the browser

    would help a lot where my CSS skills fails to help me convey the exact thing I want to change.

    My current workaround is to use the MCP, make the changes in the DevTools with the help of the built in AI Assistant in DevTools, then ask Cursor to inspect the changes made and implement them. But this approach is a lot of back and forth, I would just like to work 100% in Cursor and use the MCPs for it instead.

  14. 8 remaining items

  15. natorion commented on Nov 20, 2025

    @natorion
    Contributor

    We are actually working on sharing context in DevTools with the MCP client :-). See #129

    #129 would work as well, but as the title of this issue says, using the already existing tool "Select an element in the page to inspect it" would be the my go to.

    It's the same, can you elaborate what is missing for you?

  16. b10902118 commented on Nov 22, 2025

    @b10902118

    For inspection I think this is related to #268. I just commented there about my work on providing DOM, CSS rules, computed style.

    For selecting an element, I still believe evaluating DOM methods like .querySelector, .children, .parentNode is the best way for models. They cannot really understand image at pixel level because everything is tokenized.

  17. added theissue type on Feb 3, 2026
  18. removed their assignment
    on Feb 3, 2026
  19. ithiria894 commented on Mar 21, 2026

    @ithiria894

    The overlayUIDs / Set-of-Marks approach discussed here is exactly what we're building as a standalone MCP server. Instead of modifying chrome-devtools-mcp, it runs a lightweight reverse proxy that injects hover labels onto interactive and labeled elements (buttons, links, inputs, anything with id/class/aria-label). The AI calls get_elements to get a structured list of element names, selectors, and positions, and highlight_element to flash a specific element for visual confirmation.

    It's complementary to Chrome DevTools MCP — works with any browser, no DevTools dependency needed. The tradeoff is it only labels elements that have id/class/aria-label (not every pixel on the page), but it covers the most commonly referenced elements without burning tokens on a full DOM dump.

    Still early and actively improving coverage — would love people to try it and report what gets missed. Give us a ⭐ to follow along: https://github.com/mcpware/ui-annotator-mcp

  20. medyas commented on May 8, 2026

    @medyas

    Opened a PR with a working implementation: #2021

    Two commits on the branch — initial feat: and a fix: addressing internal review findings (closed/open shadow flag
    inversion, iframe-context bug in the matched-CSS path, dead crossOriginFrame field, validation for the computed-full
    size case).

    The shape I went with — a coordinate-driven get_element_at(x, y) rather than annotated screenshots — is the simpler
    half of what this issue proposed. The annotated-screenshot path can land separately if useful.

    Schema:

    {
      x: number,
      y: number,
      mode: 'auto' | 'schema' | 'raw' | 'selector-only' = 'auto',
      css:  'none' | 'matched' | 'computed-visual' | 'computed-full' = 'none',
      pierceShadow?: boolean = true,
      filePath?: string,
    }

    Default output is a compact markdown descriptor (~200–600 tokens for a typical element). outerHTML only on mode='raw',
    with a 50KB → temp-file fallback. computed-full requires filePath.

    Gated by the existing --experimentalVision flag (same as click_at). Three open questions in the PR body that I'd like
    your steer on before this is reviewable: flag reuse vs new flag, matched-CSS path in V1 vs defer (it's the first tool
    to use raw CDP in a handler — scoped to a single CSS query, session always detached in finally), and the tool name.

  21. cmaftuleac commented on May 11, 2026

    @cmaftuleac

    The "screenshot with bounding box + scoped subtree" output you're describing is essentially what an element picker produces. For anyone who already runs Claude Code locally and doesn't want to wait on this MCP, I built Claude Code Browser
    https://chromewebstore.google.com/detail/claude-code-browser/mnibceaaapcppokpnnljohdlmojjgbkf - Chrome side panel, picker emits DOM + computed CSS + screenshot, native-messages straight to your Claude Code — no MCP server, no API key.

  22. nickchomey commented on Oct 24, 2026

    @nickchomey

    This is standard in many IDEs and other tools. For example:

    https://code.visualstudio.com/docs/debugtest/integrated-browser
    https://cursor.com/docs/agent/design-mode

    It would be fantastic if we could have similar capabilities when using chrome mcp, as we would not be tethered to tools like those

  23. OrKoN commented on Nov 3, 2026

    @OrKoN
    Collaborator

    Note that it is already possible for a while to use DevTools UI and select the element using DevTools picker. The MCP server then reports to the agent in the take_snapshot output the element you are focusing on. There will be some new features around that coming soon. cc @natorion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions