Skip to main content
Glama

Take Screenshot

mobile_take_screenshot
Read-only

Capture screenshots from mobile devices to analyze on-screen content and identify interactive elements for mobile automation tasks.

Instructions

Take a screenshot of the mobile device. Use this to understand what's on screen, if you need to press an element that is available through view hierarchy then you must list elements on screen instead. Do not cache this result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceYesThe device identifier to use. Use mobile_list_available_devices to find which devices are available to you.

Implementation Reference

  • The complete handler and registration for the 'mobile_take_screenshot' tool. It captures a screenshot using the selected robot (device), validates the PNG, optionally resizes and compresses to JPEG using ImageMagick, encodes to base64, and returns as an image content block in the MCP tool response.
    server.tool(
    	"mobile_take_screenshot",
    	"Take a screenshot of the mobile device. Use this to understand what's on screen, if you need to press an element that is available through view hierarchy then you must list elements on screen instead. Do not cache this result.",
    	{
    		noParams
    	},
    	async ({}) => {
    		requireRobot();
    
    		try {
    			const screenSize = await robot!.getScreenSize();
    
    			let screenshot = await robot!.getScreenshot();
    			let mimeType = "image/png";
    
    			// validate we received a png, will throw exception otherwise
    			const image = new PNG(screenshot);
    			const pngSize = image.getDimensions();
    			if (pngSize.width <= 0 || pngSize.height <= 0) {
    				throw new ActionableError("Screenshot is invalid. Please try again.");
    			}
    
    			if (isImageMagickInstalled()) {
    				trace("ImageMagick is installed, resizing screenshot");
    				const image = Image.fromBuffer(screenshot);
    				const beforeSize = screenshot.length;
    				screenshot = image.resize(Math.floor(pngSize.width / screenSize.scale))
    					.jpeg({ quality: 75 })
    					.toBuffer();
    
    				const afterSize = screenshot.length;
    				trace(`Screenshot resized from ${beforeSize} bytes to ${afterSize} bytes`);
    
    				mimeType = "image/jpeg";
    			}
    
    			const screenshot64 = screenshot.toString("base64");
    			trace(`Screenshot taken: ${screenshot.length} bytes`);
    
    			return {
    				content: [{ type: "image", data: screenshot64, mimeType }]
    			};
    		} catch (err: any) {
    			error(`Error taking screenshot: ${err.message} ${err.stack}`);
    			return {
    				content: [{ type: "text", text: `Error: ${err.message}` }],
    				isError: true,
    			};
    		}
    	}
    );

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv1.0.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / device
      Added value: +{
      +  "description": "The device identifier to use. Use mobile_list_available_devices to find which devices are available to you.",
      +  "type": "string"
      +}
    • removedInput schema / properties / noParams
      Removed value: -{
      -  "additionalProperties": false,
      -  "properties": {},
      -  "type": "object"
      -}
    • changedInput schema / required
      Previous value: -[
      -  "noParams"
      -]New value: +[
      +  "device"
      +]
  2. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, so the read-only nature is covered. The description adds valuable behavioral context beyond annotations: 'Do not cache this result,' which is a non-obvious constraint that the agent must know. It also clarifies that the screenshot is for understanding the screen, not for saving or interaction, which supplements the annotation's minimal safety signal.

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 compact: two sentences, with the main purpose stated first, followed by usage guidance and a cache warning. Every sentence serves a distinct and valuable purpose, with no wasted words.

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?

For a simple tool with one well-documented parameter and a read-only annotation, the description is quite complete. It covers purpose, usage guidelines, and a behavioral note about caching. It does not explicitly describe the return format, but given the tool's nature and the lack of an output schema, the omission is acceptable because the screenshot result is inherently visual and the description implies its purpose.

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 schema has 100% coverage for the single parameter, and its description already explains how to find available devices. The tool description adds no additional parameter detail, so the schema carries the full burden, which matches the baseline of 3 for high schema coverage.

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's function with a specific verb and resource: 'Take a screenshot of the mobile device.' It also distinguishes its purpose from the sibling tool for listing elements by explaining when each should be used, which is exactly what a clear purpose statement should do.

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?

The description provides explicit guidance on when to use this tool versus alternatives: use it to understand what's on screen, but if you need to press an element available through the view hierarchy, you must list elements on screen instead. It also adds a constraint not to cache the result, giving clear usage context.

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