set_sim_appearance
Change the visual theme of an iOS simulator by switching between dark and light appearance modes using the simulator's UUID.
Instructions
Sets the appearance mode (dark/light) of an iOS simulator.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| simulatorUuid | Yes | UUID of the simulator to use (obtained from list_simulators) | |
| mode | Yes | The appearance mode to set (either "dark" or "light") |
Implementation Reference
- src/tools/simulator.ts:559-584 (registration)Registers the 'set_sim_appearance' tool with the MCP server, defining its description, input schema, and handler function.export function registerSetSimulatorAppearanceTool(server: McpServer): void { server.tool( 'set_sim_appearance', 'Sets the appearance mode (dark/light) of an iOS simulator.', { simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), mode: z .enum(['dark', 'light']) .describe('The appearance mode to set (either "dark" or "light")'), }, async (params: { simulatorUuid: string; mode: 'dark' | 'light' }): Promise<ToolResponse> => { log('info', `Setting simulator ${params.simulatorUuid} appearance to ${params.mode} mode`); return executeSimctlCommandAndRespond( params, ['ui', params.simulatorUuid, 'appearance', params.mode], 'Set Simulator Appearance', `Successfully set simulator ${params.simulatorUuid} appearance to ${params.mode} mode`, 'Failed to set simulator appearance', 'set simulator appearance', ); }, ); }
- src/tools/simulator.ts:571-582 (handler)The handler function for 'set_sim_appearance' that logs the action and delegates to executeSimctlCommandAndRespond to run 'xcrun simctl ui <uuid> appearance <mode>'.async (params: { simulatorUuid: string; mode: 'dark' | 'light' }): Promise<ToolResponse> => { log('info', `Setting simulator ${params.simulatorUuid} appearance to ${params.mode} mode`); return executeSimctlCommandAndRespond( params, ['ui', params.simulatorUuid, 'appearance', params.mode], 'Set Simulator Appearance', `Successfully set simulator ${params.simulatorUuid} appearance to ${params.mode} mode`, 'Failed to set simulator appearance', 'set simulator appearance', ); },
- src/tools/simulator.ts:564-570 (schema)Zod schema defining the input parameters: simulatorUuid (string) and mode (enum: 'dark' | 'light').simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), mode: z .enum(['dark', 'light']) .describe('The appearance mode to set (either "dark" or "light")'), },
- src/tools/simulator.ts:500-557 (helper)Shared helper function that performs validation, executes simctl commands via executeCommand, handles success/error responses, and logging. Used by set_sim_appearance handler.async function executeSimctlCommandAndRespond( params: { simulatorUuid: string; [key: string]: unknown }, simctlSubCommand: string[], operationDescriptionForXcodeCommand: string, successMessage: string, failureMessagePrefix: string, operationLogContext: string, extraValidation?: () => ToolResponse | null, ): Promise<ToolResponse> { const simulatorUuidValidation = validateRequiredParam( 'simulatorUuid', params.simulatorUuid as string, ); if (!simulatorUuidValidation.isValid) { return simulatorUuidValidation.errorResponse!; } if (extraValidation) { const validationResult = extraValidation(); if (validationResult) { return validationResult; } } try { const command = ['xcrun', 'simctl', ...simctlSubCommand]; const result = await executeCommand(command, operationDescriptionForXcodeCommand); if (!result.success) { const fullFailureMessage = `${failureMessagePrefix}: ${result.error}`; log( 'error', `${fullFailureMessage} (operation: ${operationLogContext}, simulator: ${params.simulatorUuid})`, ); return { content: [{ type: 'text', text: fullFailureMessage }], }; } log( 'info', `${successMessage} (operation: ${operationLogContext}, simulator: ${params.simulatorUuid})`, ); return { content: [{ type: 'text', text: successMessage }], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); const fullFailureMessage = `${failureMessagePrefix}: ${errorMessage}`; log( 'error', `Error during ${operationLogContext} for simulator ${params.simulatorUuid}: ${errorMessage}`, ); return { content: [{ type: 'text', text: fullFailureMessage }], }; } }