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
| Name | Required | Description | Default |
|---|---|---|---|
| udid | No | Simulator UDID (optional, defaults to booted simulator) | |
| max_dim | No | Max width/height for output image (default: 960) | |
| quality | No | JPEG quality 20..95 (default: 60) | |
| only_if_changed | No | Do not return image content if hash is unchanged | |
| previous_image_hash | No | Compare against this hash for unchanged detection |
Implementation Reference
- src/index.ts:627-666 (handler)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',