simulator.erase
Factory reset an iOS simulator by erasing all content and settings to restore it to a clean state for testing.
Instructions
Erase all content and settings from a simulator (factory reset)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | Device name or UDID to erase. |
Implementation Reference
- src/simulator/devices.ts:166-190 (handler)Core handler function that erases the simulator device by shutting it down if necessary and calling simctl erase.export async function eraseDevice(nameOrUdid: string): Promise<void> { logger.info("simulator", `Erasing simulator: ${nameOrUdid}`); const device = await findDevice(nameOrUdid); if (!device) { throw createError("SIM_NOT_FOUND", `Simulator not found: ${nameOrUdid}`, { details: "Use simulator.list_devices to see available simulators", }); } // Must be shut down before erasing if (device.state !== "Shutdown") { await shutdownDevice(device.udid); } const result = await simctl(["erase", device.udid]); if (result.exitCode !== 0) { const { code, message } = parseSimctlError(result.stderr); throw createError(code, message, { details: result.stderr }); } logger.info("simulator", `Device ${device.name} erased successfully`); }
- src/mcp/server.ts:146-165 (registration)Registers the 'simulator.erase' tool with MCP server, providing description, input schema, and thin wrapper handler that delegates to eraseDevice.server.tool( "simulator.erase", "Erase all content and settings from a simulator (factory reset)", SimulatorEraseInputSchema.shape, async (args) => { try { await eraseDevice(args.device); return { content: [ { type: "text", text: JSON.stringify({ success: true, message: `Device ${args.device} erased` }), }, ], }; } catch (error) { return handleToolError(error); } } );
- src/mcp/schemas.ts:24-26 (schema)Zod schema defining the input for the simulator.erase tool: requires a 'device' string (name or UDID).export const SimulatorEraseInputSchema = z.object({ device: z.string().describe("Device name or UDID to erase."), });