Skip to main content
Glama

get_ui_tree

Reads a window's UI Automation tree as a compact, interactive-element list with paths, control types, names, IDs, and screen rects. Use it to inspect desktop app controls by window handle or title.

Instructions

Read the UI Automation tree of one window as a compact text list.

`window` is an hwnd from list_windows (e.g. "132456") or a unique part of a
title or process name (e.g. "notepad"). ambiguous matches are an error, not
a guess.

Returns one line per interactive element: path, control type, name,
automation id, screen rect. Invisible and zero-size elements are dropped.

max_depth defaults to 8 and the walk is breadth-first, because shallow
depth limits hide real controls (a calculator loses its keypad at depth 4,
Explorer hides the file list at depth 6). max_nodes caps the walk: dense
windows cost about 2.5 ms per node, so raise it deliberately.
include_text also lists static text elements, which is useful for reading
labels and status messages. include_containers adds List/Tree/Table/DataGrid
nodes: their paths are what inspect_element expects when you want to read a
whole table or list instead of numbering every row.

Read-only. If the window runs elevated while this server does not, Windows
blocks UIA and the tool reports that instead of returning an empty tree.

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": {
      "window": "<window>"
    },
    "name": "get_ui_tree"
  }
}

Input Schema

NameRequiredDescriptionDefault
windowYes
max_depthNo
max_nodesNo
include_textNo
include_containersNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.1

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: read-only, invisible/zero-size elements dropped, breadth-first walk, ~2.5 ms per node cost with max_nodes as a deliberate cap, and elevated-window UIA blocking reported as an error rather than a silently empty tree.

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 purpose and return format, then one block per behavioral concern; nothing is redundant. The calculator/Explorer depth examples are the one arguable luxury, though they justify the defaults rather than pad.

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 5-parameter read tool with an output schema, the definition covers input disambiguation, output line contents, filtering behavior, performance limits, and the failure mode. An agent can call it correctly without opening the schema.

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

Parameters5/5

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

Schema coverage is 0%, so the description must compensate, and it documents all five parameters with meaning beyond the schema: window accepts hwnd or a unique title/process fragment, max_depth's default of 8 and why shallow limits hide controls, max_nodes' cost model, and what include_text and include_containers each add.

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?

Opens with a specific verb and resource ("Read the UI Automation tree of one window") plus the output shape ("compact text list"). It also positions itself relative to siblings: window handles come from list_windows, and container paths are what inspect_element consumes.

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 preconditions and inputs (an hwnd from list_windows or a unique title/process fragment, with ambiguous matches treated as an error), and explains when to flip include_containers versus numbering rows. It stops short of an explicit "use this instead of inspect_element/capture_window when..." routing statement.

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