reset_simulator_location
Reset a simulator's location to default coordinates using its UUID to restore original positioning for testing.
Instructions
Resets the simulator's location to default.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| simulatorUuid | Yes | UUID of the simulator to use (obtained from list_simulators) |
Implementation Reference
- src/tools/simulator.ts:641-652 (handler)The core handler function for the 'reset_simulator_location' tool. It validates the simulatorUuid, logs the action, and executes the 'xcrun simctl location clear' command via the helper function.async (params: { simulatorUuid: string }): Promise<ToolResponse> => { log('info', `Resetting simulator ${params.simulatorUuid} location`); return executeSimctlCommandAndRespond( params, ['location', params.simulatorUuid, 'clear'], 'Reset Simulator Location', `Successfully reset simulator ${params.simulatorUuid} location.`, 'Failed to reset simulator location', 'reset simulator location', ); },
- src/tools/simulator.ts:637-640 (schema)Zod input schema defining the required 'simulatorUuid' parameter for the tool.simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), },
- src/tools/simulator.ts:633-653 (registration)The server.tool registration call within registerResetSimulatorLocationTool that defines and registers the tool with name, description, schema, and handler.server.tool( 'reset_simulator_location', "Resets the simulator's location to default.", { simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), }, async (params: { simulatorUuid: string }): Promise<ToolResponse> => { log('info', `Resetting simulator ${params.simulatorUuid} location`); return executeSimctlCommandAndRespond( params, ['location', params.simulatorUuid, 'clear'], 'Reset Simulator Location', `Successfully reset simulator ${params.simulatorUuid} location.`, 'Failed to reset simulator location', 'reset simulator location', ); }, );
- src/utils/register-tools.ts:344-347 (registration)Entry in the toolRegistrations array that includes this tool's register function, associating it with SIMULATOR_MANAGEMENT group and controlled by XCODEBUILDMCP_TOOL_RESET_SIMULATOR_LOCATION env var.register: registerResetSimulatorLocationTool, groups: [ToolGroup.SIMULATOR_MANAGEMENT], envVar: 'XCODEBUILDMCP_TOOL_RESET_SIMULATOR_LOCATION', },
- src/tools/simulator.ts:500-557 (helper)Shared helper function called by the handler to perform the actual simctl command execution, validation, error handling, and response formatting for simulator operations.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 }], }; } }