Skip to main content
Glama

mobile_take_screenshot

Capture a screenshot of a mobile device screen via the Mobile Next MCP server for real-time visual context in mobile automation workflows. Useful for troubleshooting or analyzing app interfaces.

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
noParamsYes

Implementation Reference

  • Handler function that requires a selected robot/device, captures screenshot, validates PNG, optionally resizes/compresses with ImageMagick, base64 encodes, and returns as image content in CallToolResult format.
    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, }; } }
  • src/server.ts:399-449 (registration)
    Registration of the mobile_take_screenshot tool on the MCP server with description, empty input schema (noParams), and the handler function.
    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, }; } } );
  • Shared empty input schema (z.object({})) used by mobile_take_screenshot and other parameterless tools.
    const noParams = z.object({});

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/EmpathySlainLovers/MCP'

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