Skip to main content
Glama
yorifuji

MCP iOS Simulator Screenshot

by yorifuji

get_screenshot

Capture screenshots from iOS Simulator with customizable output options including filename, directory, and resize settings.

Instructions

Capture a screenshot from iOS Simulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
output_filenameNoOutput filename (if not specified, timestamp.png will be used)
output_directory_nameNoSubdirectory name for screenshots (if not specified, .screenshots will be used).screenshots
resizeNoWhether to resize the image to approximately VGA size
max_widthNoMaximum width for resizing (pixels)
device_idNoSpecify a simulator device (if not specified, the booted device will be used)

Implementation Reference

  • Core handler function that executes the screenshot capture logic: validates device, captures using xcrun simctl, saves, resizes with sharp, and returns metadata.
    public async captureScreenshot(options: ScreenshotOptions = {}): Promise<ScreenshotResult> {
      try {
        // Prepare file paths
        const { outputPath } = this.prepareFilePaths(options);
        
        // Validate device ID (only if specified)
        if (options.deviceId && options.deviceId !== 'booted') {
          const isValid = await this.deviceValidator.isValidDeviceId(options.deviceId);
          if (!isValid) {
            throw new Error(`Invalid device ID: ${options.deviceId}. Please use a valid device ID or 'booted'.`);
          }
        }
    
        // Capture screenshot from simulator
        const imageBuffer = await this.captureSimulatorScreenshot(options.deviceId);
    
        // Save the image
        await fs.writeFile(outputPath, imageBuffer);
    
        // Process the image (resize if needed)
        const finalPath = options.resize !== false
          ? await this.resizeImage(outputPath, options.maxWidth || config.screenshot.defaultMaxWidth)
          : outputPath;
    
        // Get image metadata
        const metadata = await this.getImageMetadata(finalPath);
    
        // Get command line arguments
        const outputDir = this.outputManager.isUsingRootDirectoryDirectly() ?
          this.outputManager.getRootDirectory() : undefined;
    
        return {
          success: true,
          message: 'iOS Simulator screenshot saved successfully',
          filePath: finalPath,
          metadata,
          serverConfig: {
            commandLineArgs: {
              outputDir
            }
          }
        };
      } catch (error) {
        return this.createErrorResult(error);
      }
    }
  • MCP tool call handler that maps request parameters to ScreenshotOptions and delegates to ScreenshotService.captureScreenshot.
    private async handleScreenshotRequest(request: any): Promise<any> {
      try {
        const args = request.params.arguments as Record<string, unknown> || {};
        
        // Map API parameters to internal options
        const options: ScreenshotOptions = {
          outputFileName: args.output_filename as string,
          outputDirectoryName: args.output_directory_name as string,
          resize: args.resize as boolean,
          maxWidth: args.max_width as number,
          deviceId: args.device_id as string
        };
        
        // Capture screenshot
        const result = await this.screenshotService.captureScreenshot(options);
        
        // Return formatted response
        return this.createMcpResponse(result);
      } catch (error) {
        const err = error as Error;
        return this.createMcpResponse({
          success: false,
          message: `Error: ${err.message}`,
          error: { code: 'UNEXPECTED_ERROR' }
        });
      }
    }
  • Defines the tool schema including inputSchema with properties for filename, directory, resize options, and device ID.
    private getScreenshotToolDefinition() {
      return {
        name: 'get_screenshot',
        description: 'Capture a screenshot from iOS Simulator',
        inputSchema: {
          type: 'object',
          properties: {
            output_filename: {
              type: 'string',
              description: 'Output filename (if not specified, timestamp.png will be used)'
            },
            output_directory_name: {
              type: 'string',
              description: 'Subdirectory name for screenshots (if not specified, .screenshots will be used)',
              default: config.screenshot.defaultOutputDirName
            },
            resize: {
              type: 'boolean',
              description: 'Whether to resize the image to approximately VGA size',
              default: true
            },
            max_width: {
              type: 'integer',
              description: 'Maximum width for resizing (pixels)',
              default: config.screenshot.defaultMaxWidth
            },
            device_id: {
              type: 'string',
              description: 'Specify a simulator device (if not specified, the booted device will be used)'
            }
          },
          required: []
        }
      };
    }
  • src/index.ts:133-135 (registration)
    Registers the get_screenshot tool by including it in the ListTools response.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [this.getScreenshotToolDefinition()]
    }));
  • Dispatch logic in CallToolRequestSchema handler that routes get_screenshot calls to the specific handler.
    if (request.params.name === 'get_screenshot') {
      return await this.handleScreenshotRequest(request);
    } else {
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Capture a screenshot' implies a read operation, but it doesn't specify whether this requires specific simulator states, permissions, or has side effects. The description lacks information about error conditions, what happens if no device is booted, or the format/location of output beyond what's in parameter descriptions.

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 states the core purpose without unnecessary words. It's appropriately sized for a straightforward tool and gets directly to the point. Every word earns its place in conveying the essential function.

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

Completeness2/5

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

For a tool with no annotations and no output schema, the description is insufficiently complete. While the purpose is clear, it lacks important behavioral context about how the tool operates, what it returns, error handling, and dependencies. The description doesn't compensate for the absence of structured metadata that would help an agent understand the tool's behavior and constraints.

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?

With 100% schema description coverage, all parameters are well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema descriptions. This meets the baseline expectation when schema coverage is complete, but doesn't provide extra semantic context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Capture') and target resource ('screenshot from iOS Simulator'), making the purpose immediately understandable. It lacks sibling differentiation, but since there are no sibling tools, this doesn't reduce clarity. The description is specific enough to distinguish this from other potential screenshot tools.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or context. It simply states what the tool does without indicating appropriate scenarios or limitations. While there are no sibling tools to differentiate from, the description offers no usage context whatsoever.

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/yorifuji/mcp-ios-simulator-screenshot'

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