Skip to main content
Glama
zillow
by zillow

detectIntentChooser

Identify intent chooser dialogs in mobile app views to automate user interaction testing and validation processes.

Instructions

Detect system intent chooser dialog in the current view hierarchy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the MCP tool 'detectIntentChooser' with ToolRegistry, providing name, description, schema, and handler function.
    ToolRegistry.registerDeviceAware(
      "detectIntentChooser",
      "Detect system intent chooser dialog in the current view hierarchy",
      detectIntentChooserSchema,
      detectIntentChooserHandler,
      false // Does not support progress notifications
    );
  • The main handler function for the 'detectIntentChooser' tool. Instantiates DetectIntentChooser class, calls execute(), and formats the response.
    const detectIntentChooserHandler = async (device: BootedDevice, args: DetectIntentChooserArgs) => {
      try {
        const detectIntentChooser = new DetectIntentChooser(device);
        const result = await detectIntentChooser.execute();
    
        return createJSONToolResponse({
          message: `Intent chooser detection completed. Detected: ${result.detected}`,
          success: result.success,
          detected: result.detected,
          error: result.error,
          observation: result.observation
        });
      } catch (error) {
        logger.error(`[detectIntentChooser] Failed to detect intent chooser: ${error}`);
        throw new ActionableError(`Failed to detect intent chooser: ${error}`);
      }
    };
  • Zod schema definition for the tool arguments (no parameters required).
    export const detectIntentChooserSchema = z.object({
    });
  • DetectIntentChooser class that performs screen observation and delegates detection to DeepLinkManager.
    export class DetectIntentChooser extends BaseVisualChange {
      private deepLinkManager: DeepLinkManager;
    
      constructor(device: BootedDevice, adb: AdbUtils | null = null) {
        super(device, adb);
        this.deepLinkManager = new DeepLinkManager(device);
      }
    
      /**
         * Execute intent chooser detection
         * @returns Promise with intent chooser detection results
         */
      async execute(): Promise<IntentChooserResult> {
        return this.observedInteraction(
          async (observeResult: ObserveResult) => {
            try {
    
              const viewHierarchy = observeResult.viewHierarchy;
              if (!viewHierarchy) {
                return { success: false, error: "View hierarchy not found" };
              }
    
              logger.info("[DetectIntentChooser] Starting intent chooser detection");
              const detected = this.deepLinkManager.detectIntentChooser(viewHierarchy);
    
              logger.info(`[DetectIntentChooser] Intent chooser detection completed. Detected: ${detected}`);
    
              return {
                success: true,
                detected
              };
            } catch (error) {
              logger.error(`[DetectIntentChooser] Failed to detect intent chooser: ${error}`);
    
              return {
                success: false,
                detected: false,
                error: error instanceof Error ? error.message : String(error)
              };
            }
          },
          {
            changeExpected: false
          }
        );
      }
    }
  • Core detection logic that traverses the view hierarchy and checks for text, class, and resource ID indicators of the intent chooser dialog.
    detectIntentChooser(viewHierarchy: ViewHierarchyResult): boolean {
      try {
        // If the hierarchy is empty, return false
        if (!viewHierarchy || !viewHierarchy.hierarchy || !viewHierarchy.hierarchy.node) {
          return false;
        }
    
        // Look for common intent chooser indicators
        const textIndicators = [
          "Choose an app",
          "Open with",
          "Complete action using",
          "Always",
          "Just once"
        ];
    
        const classIndicators = [
          "com.android.internal.app.ChooserActivity",
          "com.android.internal.app.ResolverActivity"
        ];
    
        const resourceIdIndicators = [
          "android:id/button_always",
          "android:id/button_once",
          "resolver_list",
          "chooser_list"
        ];
    
        // Get root nodes from the view hierarchy
        const rootNodes = this.elementUtils.extractRootNodes(viewHierarchy);
    
        // Check all nodes in the hierarchy
        for (const rootNode of rootNodes) {
          let foundIndicator = false;
    
          this.elementUtils.traverseNode(rootNode, (node: any) => {
            if (foundIndicator) {return;}
    
            const nodeProperties = this.elementUtils.extractNodeProperties(node);
            const nodeClass = nodeProperties.class || "";
            const nodeText = nodeProperties.text || nodeProperties["content-desc"] || "";
            const nodeResourceId = nodeProperties["resource-id"] || "";
    
            // Check for class indicators
            for (const className of classIndicators) {
              if (nodeClass.includes(className)) {
                foundIndicator = true;
                return;
              }
            }
    
            // Check for text indicators (exact match)
            for (const text of textIndicators) {
              if (nodeText === text) {
                foundIndicator = true;
                return;
              }
            }
    
            // Check for resource ID indicators
            for (const resourceId of resourceIdIndicators) {
              if (nodeResourceId.includes(resourceId)) {
                foundIndicator = true;
                return;
              }
            }
          });
    
          if (foundIndicator) {
            return true;
          }
        }
    
        return false;
      } catch (error) {
        logger.warn(`[DeepLinkManager] Error detecting intent chooser: ${error}`);
        return false;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool detects a dialog but doesn't explain what happens upon detection (e.g., returns a boolean, triggers an action, or provides details). It also omits critical context like permissions needed, side effects, or error handling, which is inadequate for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that directly states the tool's function without any fluff or redundancy. It's front-loaded with the core action ('detect') and resource, making it highly efficient and easy to parse. Every word contributes to understanding the purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of UI automation and lack of annotations or output schema, the description is incomplete. It doesn't specify what the tool returns (e.g., detection status, dialog details) or behavioral traits like error cases. For a tool that likely interacts with device states, more context on usage and outcomes is needed to be fully helpful.

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?

The tool has 0 parameters, and schema description coverage is 100%, so there's no need for parameter details in the description. The description appropriately avoids discussing parameters, focusing on the tool's purpose instead. This meets the baseline for tools with no parameters, as it doesn't add unnecessary information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: detecting a system intent chooser dialog in the current view hierarchy. It uses specific verbs ('detect') and resources ('system intent chooser dialog', 'current view hierarchy'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'handleIntentChooser', which might handle or interact with the same dialog.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing an active device or view hierarchy, or compare it to siblings like 'handleIntentChooser' for context on usage scenarios. This leaves the agent without explicit direction on application.

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/zillow/auto-mobile'

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