Skip to main content
Glama
andreahaku
by andreahaku

simulator.shutdown

Shut down an iOS simulator device to free system resources or prepare for development environment changes. Specify a device name or UDID, or use the currently booted device.

Instructions

Shut down an iOS simulator device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceNoDevice name or UDID. If not specified, shuts down the booted device.

Implementation Reference

  • Core handler function shutdownDevice that locates the simulator device, checks its state, calls simctl to shutdown, handles errors, and updates the global state manager.
    export async function shutdownDevice(nameOrUdid: string): Promise<void> { logger.info("simulator", `Shutting down 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", }); } if (device.state === "Shutdown") { logger.info("simulator", `Device ${device.name} is already shut down`); stateManager.updateSimulator({ state: "shutdown" }); return; } const result = await simctl(["shutdown", device.udid]); if (result.exitCode !== 0) { const { code, message } = parseSimctlError(result.stderr); throw createError(code, message, { details: result.stderr }); } stateManager.updateSimulator({ state: "shutdown", udid: undefined, deviceName: undefined }); logger.info("simulator", `Device ${device.name} shut down successfully`); }
  • Zod schema defining the input for simulator.shutdown tool: optional 'device' string parameter.
    export const SimulatorShutdownInputSchema = z.object({ device: z.string().optional().describe("Device name or UDID. If not specified, shuts down the booted device."), });
  • MCP server.tool registration for 'simulator.shutdown', providing description, input schema, and async handler wrapper that determines device (from args, state, or booted), calls shutdownDevice, and formats MCP response.
    server.tool( "simulator.shutdown", "Shut down an iOS simulator device", SimulatorShutdownInputSchema.shape, async (args) => { try { const device = args.device ?? stateManager.getSimulator().udid; if (!device) { const booted = await getBootedDevice(); if (!booted) { return { content: [{ type: "text", text: JSON.stringify({ success: true, message: "No simulator is running" }) }], }; } await shutdownDevice(booted.udid); } else { await shutdownDevice(device); } return { content: [ { type: "text", text: JSON.stringify({ success: true, state: stateManager.getSimulator() }, null, 2), }, ], }; } catch (error) { return handleToolError(error); } } );

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