Skip to main content
Glama
zillow
by zillow

observe

Retrieve the view hierarchy displayed on screen for mobile automation testing. Supports Android and iOS platforms to analyze UI structure.

Instructions

Get the view hierarchy of what is displayed on screen

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformYesTarget platform

Implementation Reference

  • Handler function that executes the observe tool by creating an ObserveScreen instance and calling its execute method, returning the JSON response.
    const observeHandler = async (device: BootedDevice) => {
      try {
        const observeScreen = new ObserveScreen(device);
        const result = await observeScreen.execute();
        return createJSONToolResponse(result);
      } catch (error) {
        throw new ActionableError(`Failed to execute observe: ${error}`);
      }
    };
  • Input schema (Zod) for the observe tool, specifying the target platform.
    export const observeSchema = z.object({
      platform: z.enum(["android", "ios"]).describe("Target platform")
    });
  • Registers the observe tool with the ToolRegistry, specifying name, description, schema, and handler.
    ToolRegistry.registerDeviceAware(
      "observe",
      "Get the view hierarchy of what is displayed on screen",
      observeSchema,
      observeHandler,
    );
  • Output type definition (TypeScript interface) for the result returned by the observe tool.
    export interface ObserveResult {
      /**
       * Timestamp when observation was made
       * Can be a number (milliseconds) or ISO string depending on context
       */
      timestamp: string | number;
    
      /** Screen dimensions */
      screenSize: ScreenSize;
    
      /** System UI insets */
      systemInsets: SystemInsets;
    
      /** Screen rotation (0: portrait, 1: landscape 90°, 2: reverse portrait 180°, 3: reverse landscape 270°) */
      rotation?: number;
    
      /** View hierarchy data */
      viewHierarchy?: ViewHierarchyResult;
    
      /** Active window information */
      activeWindow?: ActiveWindowInfo;
    
      /**
       * Categorized elements from the view hierarchy
       */
      elements?: {
        clickable: Element[];
        scrollable: Element[];
        text: Element[];
      };
    
      /**
       * The single currently focused UI element from the view hierarchy
       * Contains the element that has focus state set to true
       */
      focusedElement?: Element;
    
      /** Whether a system intent chooser dialog was detected */
      intentChooserDetected?: boolean;
    
      /** Error message if observation failed partially or completely */
      error?: string;
    }
  • Core execution logic in ObserveScreen.execute(), which orchestrates collection of screen data, view hierarchy, caching, and returns ObserveResult.
    async execute(queryOptions?: ViewHierarchyQueryOptions): Promise<ObserveResult> {
      try {
        logger.debug("Executing observe command");
        const startTime = Date.now();
    
        // Create base result object with timestamp
        const result = this.createBaseResult();
    
        // Collect all data components with parallelization
        await this.collectAllData(result, queryOptions);
    
        // Cache the result for future use
        await this.cacheObserveResult(result);
    
        logger.debug("Observe command completed");
        logger.debug(`Total observe command execution took ${Date.now() - startTime}ms`);
        return result;
      } catch (err) {
        logger.error("Critical error in observe command:", err);
        return {
          timestamp: new Date().toISOString(),
          screenSize: { width: 0, height: 0 },
          systemInsets: { top: 0, right: 0, bottom: 0, left: 0 },
          error: "Observation failed due to device access error"
        };
      }
    }
  • Top-level call to registerObserveTools() during MCP server setup, which triggers observe tool registration.
    registerObserveTools();
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. It states it 'gets' information, implying a read-only operation, but doesn't disclose behavioral traits like whether it requires specific device states, has performance impacts, returns structured data, or handles errors. This leaves significant gaps for a tool interacting with device screens.

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, direct sentence with no wasted words, front-loading the core action and resource. It efficiently communicates the essential purpose without unnecessary elaboration.

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 device interaction and no annotations or output schema, the description is insufficient. It lacks details on return values (e.g., hierarchy format), error conditions, dependencies on other tools (e.g., 'startDevice'), or behavioral constraints, making it incomplete for safe and effective use.

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 the single parameter 'platform' fully documented in the schema (enum: 'android', 'ios'). The description adds no additional parameter semantics beyond implying it retrieves screen data, which aligns with the schema but doesn't provide extra value like format details or usage examples.

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 action ('Get') and the resource ('view hierarchy of what is displayed on screen'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'getAllConfigs' or 'listApps', which also retrieve information but about different resources.

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. With many sibling tools for device interaction (e.g., 'tapOn', 'scroll', 'listApps'), there's no indication of context, prerequisites, or exclusions for using 'observe'.

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