Skip to main content
Glama

webview_find_element

Read-only

[Tauri Apps Only] Find elements in a running Tauri app's webview and return their geometry, text, accessible name, attributes, visibility, and optionally their computed styles.

Instructions

[Tauri Apps Only] Find elements in a running Tauri app's webview and return their geometry, text, accessible name, attributes, visibility, and optionally their computed styles. Supports CSS selectors (default), XPath expressions, and text content matching via the strategy parameter. The "text" strategy searches element text content (not just direct text nodes), prefers exact matches over substring matches, prefers innermost elements, and prefers interactive ancestors. Returns structured JSON with totalMatches, returned count, and array of matches each containing: nth index, ref ID, tag, trimmed text, accessible name, attributes, bounding rect, visibility, interactability, optional computed styles, and optional truncated outerHTML. Use this instead of webview_execute_js for querySelector, getBoundingClientRect, textContent, and getComputedStyle reads. Requires active driver_session. Targets the only connected app, or the default app if multiple are connected. Specify appIdentifier (port or bundle ID) to target a specific app. For browser pages or documentation sites, use Chrome DevTools MCP instead.

Input Schema

NameRequiredDescriptionDefault
nthNoZero-based index to pick one of several matching elements. Omit when the selector is unique. Required when a text selector matches more than one visible element.
limitNoMaximum number of matches to return. Total match count is always reported.
selectorYesThe selector to find: CSS selector (default), XPath expression, text content, or ref ID (e.g., "ref=e3"). Interpretation depends on strategy.
strategyNoSelector strategy: "css" (default) for CSS selectors, "xpath" for XPath expressions, "text" to find elements by text content, with fallback to placeholder, aria-label, and title attributes. Ref IDs (e.g., "ref=e3") work with any strategy.css
windowIdNoWindow label to target (defaults to "main")
propertiesNoComputed CSS properties to include for each match, e.g. ["display","opacity","font-size"].
includeHtmlNoInclude outerHTML for each match, truncated to 2000 characters.
visibleOnlyNoReturn only rendered elements. Set false to include display:none and off-screen nodes.
appIdentifierNoApp port or bundle ID to target. Defaults to the only connected app or the default app if multiple are connected.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv1.0.1
    • addedInput schema / properties / includeHtml
      Added value: +{
      +  "default": false,
      +  "description": "Include outerHTML for each match, truncated to 2000 characters.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / limit
      Added value: +{
      +  "default": 5,
      +  "description": "Maximum number of matches to return. Total match count is always reported.",
      +  "maximum": 50,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • addedInput schema / properties / nth
      Added value: +{
      +  "description": "Zero-based index to pick one of several matching elements. Omit when the selector is unique. Required when a text selector matches more than one visible element.",
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / properties
      Added value: +{
      +  "description": "Computed CSS properties to include for each match, e.g. [\"display\",\"opacity\",\"font-size\"].",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / visibleOnly
      Added value: +{
      +  "default": true,
      +  "description": "Return only rendered elements. Set false to include display:none and off-screen nodes.",
      +  "type": "boolean"
      +}
  2. Addedv0.11.1

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only declare readOnlyHint and openWorldHint, yet the description discloses much more: the active driver_session requirement, targeting behavior (only connected app, default app when multiple, appIdentifier override), the text-strategy matching preferences (exact over substring, innermost, interactive ancestors), and full return shape. This is deep behavioral context beyond structured fields.

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 scope, then routing guidance, strategy behavior, and return shape. Dense and largely waste-free, though the long enumeration of return fields is somewhat list-like and could be tightened; every sentence still carries information.

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?

No output schema exists, so the description carries the return-value burden and does so thoroughly (totalMatches, returned, per-match fields). Combined with usage routing, prerequisites, and targeting rules, it is complete for a 9-parameter tool.

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 the baseline is 3; the description nonetheless adds meaning by explaining how the strategy parameter changes selector interpretation and how ref IDs work across all strategies, plus text-strategy intent. It stops short of detailing nth/limit/windowId tradeoffs, which remain schema-only.

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+resource (find elements in a running Tauri app's webview) and enumerates the data returned (geometry, text, accessible name, attributes, visibility, computed styles). The [Tauri Apps Only] prefix and the explicit 'use Chrome DevTools MCP instead' carve out scope against siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly routes the agent: 'Use this instead of webview_execute_js for querySelector, getBoundingClientRect, textContent, and getComputedStyle reads,' names the driver_session prerequisite, explains app-targeting defaults, and points browser/docs work to Chrome DevTools MCP. Both when-to-use and when-not are covered.

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