Skip to main content
Glama

Selectors for an element

collect_selectors
Read-only

Finds every CSS selector that can reach a target element from a hint, text, accessible name, or annotation, ranks them by redeploy survival, and checks live matches for uniqueness.

Instructions

Given a description or a CSS hint, returns every selector that could reach the element, ranked by how likely it is to survive a redeploy and checked against the live page so you know whether it matches one element or several. Prefer the top result. A selector built on a generated class such as css-1x2y3z is scored down because it changes whenever the bundler runs.

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": "collect_selectors"
  }
}

Input Schema

NameRequiredDescriptionDefault
hintNoA CSS selector, visible text, or an accessible name identifying the element.
elementNoA number from the most recent annotate_interactive on this tab. Easier and safer than retyping a selector.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.3

TDQS

A3.9/5.0
Behavior4/5

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

Annotations only declare readOnlyHint and openWorldHint; the description adds real behavioral detail — results are validated against the live page, it reports whether a selector matches one or several elements, and generated classes like css-1x2y3z are scored down. It does not discuss cost, latency, or what happens when no selector is found.

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?

Three sentences, front-loaded with the outcome and the ranking rule, followed by the actionable 'prefer the top result' and a rationale for the scoring. The generated-class sentence is slightly long but earns its place by explaining the ranking.

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

Completeness4/5

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

With no output schema, the description carries the burden of describing the return value, and it does: a ranked set of selectors plus a single-vs-multiple match signal. For a 2-parameter read-only tool this is close to complete, missing only failure/empty-result behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description loosely echoes the hint parameter ('a description or a CSS hint') but says nothing about the element parameter, which the schema itself explains as an index from annotate_interactive.

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 states a specific verb and resource: it returns every selector that can reach a given element, ranked by redeploy-survival likelihood. That is far more specific than the title 'Selectors for an element', though it never names a sibling (e.g. verify_selectors) to sharpen the boundary.

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

Usage Guidelines4/5

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

It gives actionable consumption guidance ('Prefer the top result') and explains the ranking heuristic, so an agent knows how to act on the output. It stops short of explicit when-to-use-this-vs-alternatives guidance against verify_selectors or inspect_element.

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