Skip to main content
Glama

query_selector

Find elements by CSS selector or XPath and return up to 50 labeled refs for other tools to act on, including inside open shadow roots and same-origin iframes via >> chains.

Instructions

The elements a CSS selector or an XPath matches, as refs any other tool can act on, fifty at a time, each with a short label. A chain a >> b enters open shadow roots and same-origin iframes.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "query_selector"
  }
}

Input Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.2.1

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations, the description carries the full disclosure burden. It does add real behavior (refs other tools consume, batching fifty at a time, `a >> b` traversal into open shadow roots and same-origin iframes), but it never says how the selector itself is supplied, what happens on zero matches, whether results are ordered, or how one reaches the second batch of fifty given zero parameters.

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?

One dense sentence that front-loads the return content and then the batching and traversal caveats; no filler. The trailing shadow-DOM sentence is terse and earns its place, though the opening noun phrase reads slightly awkwardly as a definition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool whose result set is described and whose schema is empty, most of what an agent needs is present, and no output schema means return values are fairly well covered. The critical gap is that a selector-matching tool with zero parameters never explains how the selector or XPath reaches it, which blocks confident invocation.

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?

There are no input parameters, so the baseline is 4. The only semantic the description could add is how the CSS selector or XPath is conveyed to the tool, and it leaves that unstated, but with an empty schema there is nothing further to document.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names the resource precisely (elements matched by a CSS selector or XPath) and the return shape (refs plus a short label each), which separates it from the inverse-looking sibling selector_for. It stops short of an explicit verb and never names a sibling, so it is clear but not fully differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied: 'refs any other tool can act on' hints that this is the entry point before click/interact-style tools, and the shadow-DOM/iframe note hints when the `>>` chain syntax is needed. There is no explicit when-to-use vs. when-not, and no stated alternative for getting at page elements.

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