Skip to main content
Glama
andreahaku
by andreahaku

simulator.screenshot

Capture screenshots from iOS Simulator during React Native/Expo development to document app states, debug UI issues, and create visual records.

Instructions

Take a screenshot of the booted simulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoName prefix for the screenshot file.screenshot

Implementation Reference

  • Core handler function that takes a screenshot of the booted simulator using simctl, handles errors, manages artifacts, and updates state.
    export async function takeScreenshot(name: string = "screenshot"): Promise<ScreenshotResult> { logger.info("simulator", `Taking screenshot: ${name}`); // Check if simulator is booted if (!stateManager.isSimulatorReady()) { const bootedDevice = await getBootedDevice(); if (!bootedDevice) { throw createError("SIM_NOT_BOOTED", "No simulator is currently booted", { details: "Boot a simulator first using simulator.boot", }); } stateManager.updateSimulator({ state: "booted", udid: bootedDevice.udid, deviceName: bootedDevice.name, }); } const screenshotPath = await artifactManager.getScreenshotPath(name); // Use 'booted' to target the currently booted simulator const result = await simctl(["io", "booted", "screenshot", screenshotPath], { timeoutMs: 30000, }); if (result.exitCode !== 0) { throw createError("SIMCTL_FAILED", "Failed to take screenshot", { details: result.stderr, evidence: [logger.formatForEvidence("simulator", 50)], }); } const timestamp = new Date().toISOString(); artifactManager.registerArtifact({ type: "screenshot", path: screenshotPath, metadata: { name, captureMethod: "simctl" }, }); logger.info("simulator", `Screenshot saved to ${screenshotPath}`); return { path: screenshotPath, timestamp, }; }
  • MCP server.tool registration for 'simulator.screenshot', providing description, input schema, and thin wrapper handler calling takeScreenshot.
    server.tool( "simulator.screenshot", "Take a screenshot of the booted simulator", SimulatorScreenshotInputSchema.shape, async (args) => { try { const result = await takeScreenshot(args.name); return { content: [ { type: "text", text: JSON.stringify({ success: true, ...result }, null, 2), }, ], }; } catch (error) { return handleToolError(error); } } );
  • Zod input schema defining optional 'name' parameter with default 'screenshot'.
    export const SimulatorScreenshotInputSchema = z.object({ name: z.string().optional().default("screenshot").describe("Name prefix for the screenshot file."), });
  • Helper usage of takeScreenshot in the toolExecutor switch for flow.run tool.
    case "simulator.screenshot": const screenshot = await takeScreenshot(input.name as string | undefined); return { success: true, result: 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/andreahaku/expo_ios_development_mcp'

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