Skip to main content
Glama
mobile-next

Mobile Next MCP Server

Official
by mobile-next

List Screen Elements

mobile_list_elements_on_screen
Read-only

Identify and locate on-screen elements with their coordinates, text, or accessibility labels for mobile automation tasks.

Instructions

List elements on screen and their coordinates, with display text or accessibility label. 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 handler function for the 'mobile_list_elements_on_screen' tool. It fetches the robot instance for the specified device, retrieves the screen elements using getElementsOnScreen(), processes them into a structured JSON format including type, text, label, coordinates, etc., and returns a descriptive string with the JSON data.
    async ({ device }) => {
    	const robot = getRobotFromDevice(device);
    	const elements = await robot.getElementsOnScreen();
    
    	const result = elements.map(element => {
    		const out: any = {
    			type: element.type,
    			text: element.text,
    			label: element.label,
    			name: element.name,
    			value: element.value,
    			identifier: element.identifier,
    			coordinates: {
    				x: element.rect.x,
    				y: element.rect.y,
    				width: element.rect.width,
    				height: element.rect.height,
    			},
    		};
    
    		if (element.focused) {
    			out.focused = true;
    		}
    
    		return out;
    	});
    
    	return `Found these elements on screen: ${JSON.stringify(result)}`;
    }
  • src/server.ts:388-424 (registration)
    The registration of the tool using the 'tool()' function, which includes the tool name, title, description, input schema (requiring 'device' string), and the inline handler function.
    tool(
    	"mobile_list_elements_on_screen",
    	"List Screen Elements",
    	"List elements on screen and their coordinates, with display text or accessibility label. Do not cache this result.",
    	{
    		device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you.")
    	},
    	async ({ device }) => {
    		const robot = getRobotFromDevice(device);
    		const elements = await robot.getElementsOnScreen();
    
    		const result = elements.map(element => {
    			const out: any = {
    				type: element.type,
    				text: element.text,
    				label: element.label,
    				name: element.name,
    				value: element.value,
    				identifier: element.identifier,
    				coordinates: {
    					x: element.rect.x,
    					y: element.rect.y,
    					width: element.rect.width,
    					height: element.rect.height,
    				},
    			};
    
    			if (element.focused) {
    				out.focused = true;
    			}
    
    			return out;
    		});
    
    		return `Found these elements on screen: ${JSON.stringify(result)}`;
    	}
    );
  • The input schema for the tool, defined using Zod, requiring a 'device' string parameter.
    {
    	device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you.")
    },
  • Helper function that resolves a device ID to the appropriate Robot implementation (IosRobot, AndroidRobot, or MobileDevice), ensuring mobilecli is available and throwing an error if device not found. Used in the tool handler to get the robot instance.
    const getRobotFromDevice = (deviceId: string): Robot => {
    
    	// from now on, we must have mobilecli working
    	ensureMobilecliAvailable();
    
    	// Check if it's an iOS device
    	const iosManager = new IosManager();
    	const iosDevices = iosManager.listDevices();
    	const iosDevice = iosDevices.find(d => d.deviceId === deviceId);
    	if (iosDevice) {
    		return new IosRobot(deviceId);
    	}
    
    	// Check if it's an Android device
    	const androidManager = new AndroidDeviceManager();
    	const androidDevices = androidManager.getConnectedDevices();
    	const androidDevice = androidDevices.find(d => d.deviceId === deviceId);
    	if (androidDevice) {
    		return new AndroidRobot(deviceId);
    	}
    
    	// Check if it's a simulator (will later replace all other device types as well)
    	const response = mobilecli.getDevices({
    		platform: "ios",
    		type: "simulator",
    		includeOffline: false,
    	});
    
    	if (response.status === "ok" && response.data && response.data.devices) {
    		for (const device of response.data.devices) {
    			if (device.id === deviceId) {
    				return new MobileDevice(deviceId);
    			}
    		}
    	}
    
    	throw new ActionableError(`Device "${deviceId}" not found. Use the mobile_list_available_devices tool to see available devices.`);
    };
Behavior3/5

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

Annotations already declare readOnlyHint=true, indicating a safe read operation. The description adds useful behavioral context: it specifies that results include coordinates and text/labels, and warns against caching, which helps the agent understand freshness requirements. However, it lacks details on output format, pagination, or error handling.

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, efficient sentence that front-loads the core purpose and includes a critical behavioral note ('Do not cache this result'). Every word serves a purpose, with no redundancy or unnecessary elaboration.

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 tool's moderate complexity (read-only listing with one parameter) and the presence of annotations (readOnlyHint), the description is mostly complete. It covers the action, output attributes, and a key behavioral constraint. However, without an output schema, it could benefit from more details on the return structure, though this is partially mitigated by the clarity provided.

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 'device' fully documented in the schema. The description does not add any parameter-specific information beyond what the schema provides, so it meets the baseline for high schema coverage without compensating value.

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 specific action ('List elements on screen'), the resource ('elements'), and key attributes ('coordinates, with display text or accessibility label'). It distinguishes from siblings by focusing on listing rather than interacting with elements (e.g., mobile_click_on_screen_at_coordinates).

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

Usage Guidelines4/5

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

The description provides clear context for when to use it ('List elements on screen') and includes a constraint ('Do not cache this result'), but does not explicitly state when not to use it or name alternatives among siblings. It implies usage for real-time element detection without persistence.

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/mobile-next/mobile-mcp'

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