Skip to main content
Glama

ui_get_page_state

ui_get_page_state

Retrieves the current page URL, title, visible interactive elements, alerts, overlays, and focused element so agents can inspect UI state before clicking or filling fields.

Instructions

Return the current page's URL, title, visible interactive elements and visible alert/status messages. Each element is {role, name, selector, state?}: pass selector unchanged to ui_click/ui_fill (at most 200 elements); state lists only non-default fields (disabled, checked, value, expanded, selected, pressed, required, invalid; a password's value is never returned). Custom widgets (combobox, listbox, option, switch, slider, contenteditable, summary...) are listed too. overlays ({role, name, selector, modal}, topmost first) names each open dialog and is absent when none is open; focused ({role, name, selector}) names the element holding focus and is absent when focus is on the page body. To read page text use ui_get_text.

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

Input Schema

NameRequiredDescriptionDefault
session_idNoWhich open session to act on, as returned by ui_start_session. Optional with one open session; required when several are open.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior5/5

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

With no annotations supplied, the description carries the entire burden and does so well: it discloses a hard cap of 200 elements, that `state` reports only non-default fields, that a password value is never returned, and that `overlays` are ordered topmost first and omitted when none are open. These are exactly the operational and safety facts an agent could not infer from the name or schema.

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?

The most important content, what is returned, is front-loaded, and every clause carries information (element shape, selector passthrough, state fields, overlays, focus, alternative tool). It is dense and heavily parenthesized, which makes it harder to scan than a lightly bulleted version would be, but nothing is genuinely redundant.

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?

There is no output schema, so the description must define the return shape itself, and it does: element object fields, the state field whitelist, overlay and focused objects with their absence conditions, and the 200-element limit. For a one-parameter inspection tool this leaves nothing an agent needs unresolved.

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% and the single `session_id` parameter is fully documented there, so the baseline of 3 applies. The description adds no additional meaning about session selection; its detail is spent on the return payload rather than on parameters.

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?

The description opens with a specific verb and an enumerated resource set: "Return the current page's URL, title, visible interactive elements and visible alert/status messages." It also distinguishes itself from the sibling that reads text by routing to ui_get_text, so an agent can choose between them without opening either 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?

It states an explicit alternative and the condition that selects it: "To read page text use ui_get_text." It also tells the agent how to chain the output into ui_click/ui_fill by passing `selector` unchanged. It does not cover when to prefer this over ui_wait_for or ui_take_screenshot, so it falls short of a full when/when-not matrix.

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