Skip to main content
Glama
tiefeiyu
by tiefeiyu

qt_find_element

Locate UI elements in a live Qt app by matching type, text, object name, or properties. Returns element IDs for immediate use in automation commands.

Instructions

Find UI elements matching a query in a session.

Query fields (all AND-ed): type (exact C++ class name), type_inherits (superclass chain — C++ classes only; custom QML components are generated classes like X_QMLTYPE_8 and do NOT match a QML type name), text / text_contains (display text, CJK supported), object_name, window_title / window_title_contains, properties (all key-value pairs must match), ancestor_id / window_id (scope limits), depth ("exact" = direct children, "shallow" = 2 levels, integer = that many, "deep"/omitted = whole tree), limit (max matches). include_hidden is a field INSIDE the query dict (default false) — hidden elements are only matched when it is true.

Example: {"text_contains": "OK", "type_inherits": "QPushButton", "depth": "shallow"} or {"object_name": "searchBox", "limit": 5}.

Result: {"ok": true, "count": N, "elements": [{id, className, objectName, ...}]}; when nothing matches: {"ok": false, "message": "No matching element found"} — adjust the query or set include_hidden: true. No prior snapshot is needed; this call rebuilds the element map itself.

ID LIFECYCLE: the rebuild invalidates EVERY element_id/window_id from previous snapshots/finds. Use the returned ids immediately — if an operation reports "Element not found: id=N", the id is stale or the element was destroyed: re-run qt_find_element (or a snapshot) and retry with the fresh id; never reuse old ids.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
session_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

With no annotations provided, the description carries the full burden and succeeds. It discloses the AND-ed query semantics, default hidden element handling, result shape for both success and no-match, and the critical side effect: every call invalidates all previous element/window IDs. The ID lifecycle warning about stale IDs and re-running is essential behavioral context.

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 description is longer than typical but every sentence earns its place given the tool's complexity. It is well-structured with sections for query fields, examples, result format, and ID lifecycle. Minor redundancy (explaining result format when an output schema exists) keeps it from a 5, but it is dense and highly scannable.

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?

The tool has a nested query object and an output schema, yet the description goes far beyond schema requirements. It covers query field semantics, depth/limit behavior, hidden element handling, error results, and ID invalidation—details an agent needs to invoke the tool correctly and handle failures gracefully. It is complete for this tool's complexity.

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?

The input schema treats 'query' as an opaque object with 0% property coverage, so the description must explain all valid keys. It does so comprehensively: type, type_inherits, text/text_contains, object_name, window_title variants, properties, ancestor/window_id, depth with exact values, limit, and include_hidden. It also gives two concrete examples, fully compensating for the schema's lack of detail.

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 resource: 'Find UI elements matching a query in a session.' It clearly distinguishes this from sibling tools like qt_snapshot (snapshot creation) and qt_get_property (property inspection) by focusing on element discovery via a flexible query.

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?

The description says 'No prior snapshot is needed; this call rebuilds the element map itself,' which clarifies when to use this instead of taking a snapshot first. It also instructs when to re-run the tool after stale IDs, referencing 'qt_find_element (or a snapshot)' as recovery options, effectively naming an alternative.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tiefeiyu/qt-commander'

If you have feedback or need assistance with the MCP directory API, please join our Discord server