QueryScreenTool

class QueryScreenTool(context: Context) : McpTool

query_screen — dump the active window's AccessibilityNodeInfo tree as a flat, ranked list of node projections.

The full tree is walked breadth-first, then ranked by usefulness before truncation: clickable (+4) > has-text/content-description (+2) > scrollable (+1) > rest, with BFS order preserved as the tie-break within each rank. This ordering is a documented contract — when the result is truncated to max_nodes, the highest-ranked nodes are the ones kept, so token-bound callers can trust the prefix. Password-flagged nodes are emitted with is_password = true and their text / content_description masked to null (see NodeQuery.toMap).

Params: max_nodes (optional, clamped 1–2000, default 500).

On success returns count (Int, nodes returned after truncation), truncated (Boolean, true when the full tree exceeded max_nodes), package_name (String?, foreground package), and nodes (List of node projection maps, each shaped like NodeQuery.toMap).

Returns the short-form error accessibility_not_enabled when the host's DroidMcpAccessibilityService is not bound.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard
open override val annotations: ToolAnnotations
Link copied to clipboard
open override val description: String
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val parameters: List<ToolParameter>

Functions

Link copied to clipboard
open suspend override fun execute(params: Map<String, Any>): ToolResult