reset_simulator_location
Restore the simulator's location to default by specifying the simulator UUID obtained from list_simulators, ensuring accurate testing environments on sl-test MCP server.
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:632-654 (handler)The handler implementation for the 'reset_simulator_location' tool. It registers the tool with the MCP server, defines the input schema (simulatorUuid), and provides the execution logic which validates the simulatorUuid and executes 'xcrun simctl location <uuid> clear' via the shared helper function.export function registerResetSimulatorLocationTool(server: McpServer): void { 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/tools/simulator.ts:500-557 (helper)Helper function that implements the core logic for executing simctl commands, including validation, command execution via executeCommand, logging, and response formatting. Used by reset_simulator_location with subcommand ['location', simulatorUuid, 'clear'].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:343-347 (registration)The top-level registration entry for the reset_simulator_location tool in the main tool registry array. This calls registerResetSimulatorLocationTool(server) if the environment variable is set, integrating it into the MCP server.{ register: registerResetSimulatorLocationTool, groups: [ToolGroup.SIMULATOR_MANAGEMENT], envVar: 'XCODEBUILDMCP_TOOL_RESET_SIMULATOR_LOCATION', },
- src/tools/simulator.ts:636-640 (schema)Zod schema for input validation of the reset_simulator_location tool, requiring simulatorUuid as a string.{ simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), },