set_sim_appearance
Change the appearance mode of an iOS simulator to dark or light using its UUID. Simplify simulator customization for testing environments.
Instructions
Sets the appearance mode (dark/light) of an iOS simulator.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | The appearance mode to set (either "dark" or "light") | |
| simulatorUuid | Yes | UUID of the simulator to use (obtained from list_simulators) |
Implementation Reference
- src/tools/simulator.ts:571-582 (handler)The async handler function for the 'set_sim_appearance' tool. It logs the operation and calls the shared executeSimctlCommandAndRespond helper to execute the xcrun simctl ui command for setting the simulator's 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 input schema for the 'set_sim_appearance' tool, defining 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:559-584 (registration)The registration function registerSetSimulatorAppearanceTool that registers the 'set_sim_appearance' tool on the MCP server using server.tool(), providing description, schema, and handler.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:500-557 (helper)Shared helper function executeSimctlCommandAndRespond used by multiple simulator tools, including set_sim_appearance, to validate parameters, execute xcrun simctl commands, log results, and return standardized ToolResponse.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 }], }; } }
- src/utils/register-tools.ts:334-337 (registration)Configuration entry in the toolRegistrations array for conditionally registering the set_sim_appearance tool (via its register function) based on environment variable and tool group.register: registerSetSimulatorAppearanceTool, groups: [ToolGroup.SIMULATOR_MANAGEMENT], envVar: 'XCODEBUILDMCP_TOOL_SET_SIMULATOR_APPEARANCE', },