Skip to main content
Glama

Interactive elements

get_interaction_tree
Read-only

Lists a page's interactive elements—buttons, links, and inputs, including shadow DOM—assigning numeric IDs usable by click and type tools instead of CSS selectors.

Instructions

List the page's interactive elements, each with a short numeric id.

The cheapest way to see what can be clicked or typed into: it walks the DOM including shadow roots for buttons, links, and inputs. The numeric ids it assigns are accepted directly by click, type_text, and the other element tools in place of a CSS selector. An id stays valid while its element exists, survives later walks, and expires on navigation; an expired one fails with stale_id. The walk runs in an isolated world and leaves no trace in the page. Returns the elements (capped at limit), the total, and whether the cap cut the list short.

Pass links=true to get each link's target as h — a path when it is same-origin, a full URL otherwise. Following a link then means a navigate instead of a click-and-hope, which matters when the link text is unhelpful or missing. It is off by default because it roughly doubles the output; measured at +116% on a 125-link search page. Nothing is emitted for javascript: handlers, bare "#" anchors, or links back to the current page, none of which can take you anywhere.

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

Input Schema

NameRequiredDescriptionDefault
tabNoTab id from list_tabs or new_tab to act on, instead of the active tab. The active tab does not change. Omit to use the active tab. Example: 'tab_2'
limitNoMaximum number of interactive elements to return. Raise it on dense pages; a note reports when the cap was hit. Example: 150
linksNoInclude each link's target as 'h' (a path when same-origin). Off by default because it roughly doubles the output; turn it on when you need to follow or identify a link. Example: true

Output Schema

NameRequiredDescriptionDefault
totalYesHow many interactive elements the page has.
summaryYesOne line saying what happened.
elementsYesInteractive elements: id (pass to click/type_text), t type (btn, link, in, chk, rad, sel, tab, mnu, el), l label, r region (hdr, nav, main, side, ftr, dlg), and when relevant h link target, it input type, v value, ck checked, dis disabled, off offscreen.
truncatedYesWhether `limit` cut the list short.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true, but the description adds substantial behavior beyond them: the walk includes shadow roots, runs in an isolated world and leaves no trace, ids survive later walks but expire on navigation with a stale_id failure, and results are capped at limit with a truncation note. That id-lifecycle and failure-mode disclosure is exactly what an agent needs before relying on ids across calls.

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 purpose and the id contract, then the optional parameter detail in its own paragraph; every sentence carries information. The measured '+116% on a 125-link search page' is slightly more evidence than needed, but it substantiates the default and is not padding.

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

Completeness5/5

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

For a read-only DOM walk with an output schema and full parameter coverage, the description covers the remaining risk surface: id validity lifetime, stale_id failure, isolation side effects, and truncation behavior. Nothing an agent needs to call it safely and interpret the cap is missing.

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?

Schema coverage is 100%, so baseline is 3, but the description adds real meaning for links: what 'h' contains (path when same-origin, full URL otherwise), why it is off by default (+116% on a 125-link page), and which link types emit nothing (javascript: handlers, bare '#', self-links). It also explains that limit is a cap reported via a truncation flag, though tab is left entirely to the schema.

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

Purpose5/5

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

States a specific verb and resource: 'List the page's interactive elements, each with a short numeric id.' It distinguishes itself from siblings by naming what it returns (buttons, links, inputs with numeric ids) and by describing the id contract that click/type_text consume, so an agent can tell it apart from get_text_content or screenshot without opening another schema.

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?

Gives clear usage context ('the cheapest way to see what can be clicked or typed into') and an explicit when-to-enable rule for links ('turn it on when you need to follow or identify a link' is implied by the follow-a-link explanation), plus the cost tradeoff. It doesn't explicitly exclude cases where another tool is better (e.g. when you only need text, use get_text_content), so it stops short of a full when/when-not table.

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