Skip to main content
Glama
zillow
by zillow

handleIntentChooser

Automatically handle system intent chooser dialogs by specifying preferences for app selection, including always, just once, or custom app packages.

Instructions

Automatically handle system intent chooser dialog with specified preferences

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
preferenceNoPreference for handling intent chooser (default: 'just_once')
customAppPackageNoSpecific app package to select when preference is 'custom'

Implementation Reference

  • The primary handler function for the handleIntentChooser MCP tool. It instantiates HandleIntentChooser class and executes it with provided arguments, then formats the response.
    const handleIntentChooserHandler = async (device: BootedDevice, args: HandleIntentChooserArgs) => {
      try {
        const handleIntentChooser = new HandleIntentChooser(device);
        const result = await handleIntentChooser.execute(
          args.preference || "just_once",
          args.customAppPackage,
        );
    
        return createJSONToolResponse({
          message: result.detected
            ? `Intent chooser handled with preference: ${args.preference || "just_once"}`
            : "No intent chooser detected",
          success: result.success,
          detected: result.detected,
          action: result.action,
          appSelected: result.appSelected,
          error: result.error,
          observation: result.observation
        });
      } catch (error) {
        logger.error(`[handleIntentChooser] Failed to handle intent chooser: ${error}`);
        throw new ActionableError(`Failed to handle intent chooser: ${error}`);
      }
    };
  • Tool registration call that adds handleIntentChooser to the ToolRegistry with its schema and handler.
    ToolRegistry.registerDeviceAware(
      "handleIntentChooser",
      "Automatically handle system intent chooser dialog with specified preferences",
      handleIntentChooserSchema,
      handleIntentChooserHandler,
      false // Does not support progress notifications
    );
  • Zod schema for validating input arguments to the handleIntentChooser tool: preference (enum) and optional customAppPackage.
    export const handleIntentChooserSchema = z.object({
      preference: z.enum(["always", "just_once", "custom"]).optional().describe("Preference for handling intent chooser (default: 'just_once')"),
      customAppPackage: z.string().optional().describe("Specific app package to select when preference is 'custom'"),
    });
  • Core execution logic in HandleIntentChooser class: observes view hierarchy and delegates handling to DeepLinkManager.
    async execute(
      preference: "always" | "just_once" | "custom" = "just_once",
      customAppPackage?: string
    ): Promise<IntentChooserResult> {
    
      return this.observedInteraction(
        async (observeResult: ObserveResult) => {
    
          const viewHierarchy = observeResult.viewHierarchy;
          if (!viewHierarchy) {
            return { success: false, error: "View hierarchy not found" };
          }
    
          return await this.deepLinkManager.handleIntentChooser(
            viewHierarchy,
            preference,
            customAppPackage
          );
        },
        {
          changeExpected: false,
          timeoutMs: 500,
        }
      );
    }
  • Core helper method implementing the intent chooser handling logic: detects chooser, locates appropriate button/app based on preference, and performs ADB tap.
    async handleIntentChooser(
      viewHierarchy: ViewHierarchyResult,
      preference: "always" | "just_once" | "custom" = "just_once",
      customAppPackage?: string
    ): Promise<IntentChooserResult> {
      try {
        const detected = this.detectIntentChooser(viewHierarchy);
    
        if (!detected) {
          return {
            success: true,
            detected: false
          };
        }
    
        logger.info(`[DeepLinkManager] Intent chooser detected, preference: ${preference}`);
    
        // Parse the view hierarchy to find buttons
        const rootNodes = this.elementUtils.extractRootNodes(viewHierarchy);
        let targetElement = null;
    
        if (preference === "always") {
          // Look for "Always" button
          for (const rootNode of rootNodes) {
            targetElement = this.findButtonByText(rootNode, ["Always", "ALWAYS"]);
            if (targetElement) {break;}
          }
        } else if (preference === "just_once") {
          // Look for "Just once" button
          for (const rootNode of rootNodes) {
            targetElement = this.findButtonByText(rootNode, ["Just once", "JUST ONCE", "Once"]);
            if (targetElement) {break;}
          }
        } else if (preference === "custom" && customAppPackage) {
          // Look for specific app in the list
          for (const rootNode of rootNodes) {
            targetElement = this.findAppInChooser(rootNode, customAppPackage);
            if (targetElement) {break;}
          }
        }
    
        if (targetElement) {
          // Simulate tap on the target element
          const center = this.elementUtils.getElementCenter(targetElement);
          await this.adbUtils.executeCommand(`shell input tap ${center.x} ${center.y}`);
    
          logger.info(`[DeepLinkManager] Tapped on intent chooser option at (${center.x}, ${center.y})`);
    
          return {
            success: true,
            detected: true,
            action: preference,
            appSelected: customAppPackage
          };
        } else {
          return {
            success: false,
            detected: true,
            error: `Could not find target element for preference: ${preference}`
          };
        }
      } catch (error) {
        logger.error(`[DeepLinkManager] Failed to handle intent chooser: ${error}`);
        return {
          success: false,
          detected: true,
          error: error instanceof Error ? error.message : String(error)
        };
      }
    }
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 mentions 'Automatically handle' but doesn't specify what this entails—e.g., whether it interacts with UI elements, requires permissions, has side effects like closing dialogs, or handles errors. For a tool that likely involves system-level interactions, this lack of detail is a significant gap, making it hard for an agent to predict outcomes.

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 a single, efficient sentence that gets straight to the point without unnecessary words. It's front-loaded with the core action ('Automatically handle'), but could be slightly improved by specifying the outcome (e.g., 'dismiss' or 'select'). Overall, it's concise and well-structured, earning a high score for brevity.

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 handling system dialogs, no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like success/failure conditions, return values, or error handling. For a tool that interacts with system UI, more context is needed to ensure the agent can use it effectively, making this inadequate for the task's demands.

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

Parameters3/5

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

Schema description coverage is 100%, with clear parameter descriptions and an enum for 'preference'. The description adds no additional meaning beyond the schema, as it doesn't explain parameter interactions (e.g., that 'customAppPackage' is only relevant for 'custom' preference) or usage examples. Since the schema is well-documented, the baseline score of 3 is appropriate, but the description doesn't enhance understanding.

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

Purpose3/5

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

The description states the tool 'Automatically handle system intent chooser dialog with specified preferences', which provides a verb ('handle') and resource ('system intent chooser dialog'). However, it's somewhat vague about what 'handle' means (e.g., dismiss, select, interact) and doesn't clearly distinguish from sibling tools like 'detectIntentChooser' or 'openLink', which might have overlapping functionality. The purpose is understandable but lacks specificity.

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 scenarios like when an intent chooser appears, prerequisites (e.g., after launching an app), or exclusions (e.g., not for web links). With siblings like 'detectIntentChooser' and 'openLink', there's no indication of how this tool fits into a workflow, leaving the agent to guess based on context.

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