Skip to main content
Glama

a11y-toolkit: Locate element by accessible name

a11y_locate
Read-onlyIdempotent

Find an element by its accessible name and return its deterministic route selector for code edits and panel deep-links; ambiguous names return candidate lists instead of guesses.

Instructions

Find an element by its accessible name and get its deterministic route selector (the same tag:nth-of-type identity annotate() uses): controls, headings, images with alt, iframes with title, fields with an explicit name. High confidence only on exact unique matches; when several elements share the name it refuses to pick one and returns the full candidate list (ambiguous) — a match is never invented. Feeds agents that edit code by selector and panel deep-links.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "html": "<html>",
      "query": "<query>"
    },
    "name": "a11y_locate"
  }
}

Input Schema

NameRequiredDescriptionDefault
htmlYesraw HTML to search
langNooutput language (en default)
roleNofilter by role: button, link, textbox, checkbox, radio, combobox, heading, h1-h6, image…
queryYesaccessible name to find (e.g. "Submit")
multipleNolist every exact match instead of refusing (default false)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv5.27.0

TDQS

A3.6/5.0
Behavior4/5

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

Annotations cover the safety profile (readOnly, idempotent, non-destructive, open world). The description still adds real behavior beyond them: confidence is limited to exact unique matches, ambiguity is refused rather than guessed, the full candidate list is returned instead, and a match is 'never invented.' The determinism claim (same identity annotate() uses) is useful contract information. Missing only details on output shape/ordering of the candidate list.

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?

Front-loaded with the core action and its result, then the ambiguity rule, then the consumer. Two dense sentences with no filler. Minor cost: jargon such as 'deterministic route selector' and 'panel deep-links' is undefined and slightly slows comprehension.

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?

No output schema exists, and the description does cover the important return-mode distinction (selector on unique match vs candidate list on ambiguity). It does not describe the selector string format or what a candidate entry looks like, which for a tool whose entire value is the returned selector is a modest but real gap.

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 reinforces the role filter scope and the refusal-vs-list behavior that maps to the `multiple` parameter, but the schema already states 'list every exact match instead of refusing,' so no genuinely new parameter meaning is added.

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?

Specific verb and resource: 'Find an element by its accessible name and get its deterministic route selector.' It enumerates the searchable element classes (controls, headings, images with alt, iframes with title, fields with explicit name), which tells an agent exactly what it covers. Sibling differentiation is only indirect — the mention of annotate() and route selectors implies a relationship to a11y_route/a11y_snapshot, but no sibling is named as an alternative.

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 context is stated ('Feeds agents that edit code by selector and panel deep-links'), so an agent can infer it is a lookup primitive rather than an audit. It also explains what happens in the ambiguous case. However, no explicit when-not or named alternative (e.g. a11y_route, a11y_snapshot) is offered, so the choice between siblings is left to inference.

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