Skip to main content
Glama

take_screenshot

Capture JPEG screenshots from iOS Simulators with configurable compression, resolution limits, and unchanged-image detection for automation workflows.

Instructions

Take a JPEG screenshot with optional compression and unchanged-image suppression.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
udidNoSimulator UDID (optional, defaults to booted simulator)
max_dimNoMax width/height for output image (default: 960)
qualityNoJPEG quality 20..95 (default: 60)
only_if_changedNoDo not return image content if hash is unchanged
previous_image_hashNoCompare against this hash for unchanged detection

Implementation Reference

  • The `takeScreenshot` private method in `src/index.ts` is the handler that performs the screenshot operation and returns the MCP tool response.
    private async takeScreenshot(
      udid?: string,
      maxDimInput?: number,
      qualityInput?: number,
      onlyIfChanged?: boolean,
      previousImageHash?: string
    ) {
      const target = await resolveUdid(udid);
      const options = normalizeScreenshotOptions(maxDimInput, qualityInput);
    
      try {
        const shot = await this.captureScreenshot(target, options);
    
        const compareHash = previousImageHash ?? (
          onlyIfChanged ? this.lastScreenshotHashByUdid.get(target) : undefined
        );
        const changed = compareHash ? compareHash !== shot.hash : true;
    
        this.lastScreenshotHashByUdid.set(target, shot.hash);
    
        const meta = {
          udid: target,
          hash: shot.hash,
          previous_hash: compareHash ?? null,
          changed,
          included: changed,
          source_width: shot.sourceWidth,
          source_height: shot.sourceHeight,
          sent_width: shot.sentWidth,
          sent_height: shot.sentHeight,
          max_dim: shot.maxDim,
          quality: shot.quality,
        };
    
        const content: any[] = [{ type: 'text', text: JSON.stringify(meta, null, 2) }];
        if (changed) {
          content.push({ type: 'image', data: shot.base64, mimeType: 'image/jpeg' });
        }
    
        return { content };
  • src/index.ts:336-336 (registration)
    The `take_screenshot` tool is registered in the list of available MCP tools within the initialization of the server in `src/index.ts`.
    name: 'take_screenshot',

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/xmuweili/app-screen-mcp'

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