Skip to main content
Glama

analyze_screen

Capture screenshots and analyze Android screen content to understand UI elements and structure for automation and testing purposes.

Instructions

Capture a screenshot and analyze the screen content. Returns both the visual screenshot and a text summary of the UI tree for comprehensive screen understanding. Use this when you need to understand the full screen context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idNoDevice serial number

Implementation Reference

  • The logic for capturing the screenshot and UI tree to analyze the screen.
    export async function analyzeScreen(deviceId?: string): Promise<ScreenAnalysis> {
      const resolved = await deviceManager.resolveDeviceId(deviceId);
    
      // Capture screenshot
      const screenshot = await captureScreenshot(resolved, {
        resize: { width: 1080, height: 1920 },
      });
    
      // Try to get UI tree summary (best effort)
      let uiSummary = '';
      try {
        const tree = await getUITree(resolved);
        uiSummary = summarizeTree(tree);
      } catch (error) {
        log.warn('UI tree dump failed during analysis, proceeding with screenshot only', {
          error: error instanceof Error ? error.message : String(error),
        });
      }
    
      const screenSize = await deviceManager.getScreenSize(resolved);
    
      return {
        screenshot,
        uiSummary,
        screenSize,
        deviceInfo: `Screen: ${screenSize.width}x${screenSize.height}`,
      };
    }
  • The MCP tool registration for the 'analyze_screen' tool.
    server.registerTool(
      'analyze_screen',
      {
        description: 'Capture a screenshot and analyze the screen content. Returns both the visual screenshot and a text summary of the UI tree for comprehensive screen understanding. Use this when you need to understand the full screen context.',
        inputSchema: {
          device_id: z.string().optional().describe('Device serial number'),
        },
      },
      async ({ device_id }) => {
        return await metrics.measure('analyze_screen', device_id || 'default', async () => {
          const analysis = await analyzeScreen(device_id);
    
          const content: Array<{ type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string }> = [];
    
          content.push({
            type: 'image' as const,
            data: analysis.screenshot.base64,
            mimeType: 'image/png',
          });
    
          content.push({
            type: 'text' as const,
            text: JSON.stringify({
              success: true,
              screenSize: analysis.screenSize,
              deviceInfo: analysis.deviceInfo,
              uiSummary: analysis.uiSummary,
            }, null, 2),
          });
    
          return { content };
        });
      }
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden. It successfully discloses the composite return type (visual + text), but omits operational details like whether this is a read-only operation, performance costs relative to single-mode alternatives, or return format specifics (file paths vs base64 vs objects).

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?

Three efficiently structured sentences: action definition, return value specification, and usage context. Each earns its place with no redundancy or filler content.

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

Completeness4/5

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

Given the lack of output schema, the description adequately explains the return values (screenshot + UI tree summary). However, it could improve by specifying return formats (e.g., base64 encoded image, JSON tree structure) or mentioning the optional nature of the device_id parameter.

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?

The input schema has 100% description coverage for the single device_id parameter. The description does not mention parameters, but with complete schema documentation, the baseline score of 3 is appropriate as no additional parameter semantics are required from the description.

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?

The description clearly states the tool captures a screenshot and returns both visual and UI tree data, distinguishing it from siblings like capture_screenshot (likely image-only) and get_ui_tree (likely text-only). The specific dual-return nature is explicitly documented.

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

Usage Guidelines3/5

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

The description includes 'Use this when you need to understand the full screen context' which provides a when-to-use hint, but lacks explicit comparison to siblings or guidance on when to use the simpler capture_screenshot or get_ui_tree alternatives instead.

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/divineDev-dotcom/android_mcp'

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