Skip to main content
Glama

set_simulator_location

Set a custom GPS location for a simulator using its UUID, latitude, and longitude to simulate specific geographic conditions or test location-based features.

Instructions

Sets a custom GPS location for the simulator.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesThe latitude for the custom location.
longitudeYesThe longitude for the custom location.
simulatorUuidYesUUID of the simulator to use (obtained from list_simulators)

Implementation Reference

  • The main handler function for the 'set_simulator_location' tool. It performs parameter validation and delegates to the shared executeSimctlCommandAndRespond helper to run the 'xcrun simctl location set LAT,LON' command.
    async (params: { simulatorUuid: string; latitude: number; longitude: number; }): Promise<ToolResponse> => { const extraValidation = (): ToolResponse | null => { const latitudeValidation = validateRequiredParam('latitude', params.latitude); if (!latitudeValidation.isValid) { return latitudeValidation.errorResponse!; } const longitudeValidation = validateRequiredParam('longitude', params.longitude); if (!longitudeValidation.isValid) { return longitudeValidation.errorResponse!; } return null; }; log( 'info', `Setting simulator ${params.simulatorUuid} location to ${params.latitude},${params.longitude}`, ); return executeSimctlCommandAndRespond( params, ['location', params.simulatorUuid, 'set', `${params.latitude},${params.longitude}`], 'Set Simulator Location', `Successfully set simulator ${params.simulatorUuid} location to ${params.latitude},${params.longitude}`, 'Failed to set simulator location', 'set simulator location', extraValidation, ); },
  • Zod input schema defining parameters for the tool: simulatorUuid (string), latitude (number), longitude (number).
    { simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), latitude: z.number().describe('The latitude for the custom location.'), longitude: z.number().describe('The longitude for the custom location.'), },
  • The registerSetSimulatorLocationTool function that calls server.tool to register the MCP tool with its name, description, schema, and handler.
    export function registerSetSimulatorLocationTool(server: McpServer): void { server.tool( 'set_simulator_location', 'Sets a custom GPS location for the simulator.', { simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), latitude: z.number().describe('The latitude for the custom location.'), longitude: z.number().describe('The longitude for the custom location.'), }, async (params: { simulatorUuid: string; latitude: number; longitude: number; }): Promise<ToolResponse> => { const extraValidation = (): ToolResponse | null => { const latitudeValidation = validateRequiredParam('latitude', params.latitude); if (!latitudeValidation.isValid) { return latitudeValidation.errorResponse!; } const longitudeValidation = validateRequiredParam('longitude', params.longitude); if (!longitudeValidation.isValid) { return longitudeValidation.errorResponse!; } return null; }; log( 'info', `Setting simulator ${params.simulatorUuid} location to ${params.latitude},${params.longitude}`, ); return executeSimctlCommandAndRespond( params, ['location', params.simulatorUuid, 'set', `${params.latitude},${params.longitude}`], 'Set Simulator Location', `Successfully set simulator ${params.simulatorUuid} location to ${params.latitude},${params.longitude}`, 'Failed to set simulator location', 'set simulator location', extraValidation, ); }, ); }
  • Shared helper function executeSimctlCommandAndRespond used by the handler to execute the xcrun simctl command and handle responses.
    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 }], }; } }
  • High-level tool registration entry in the toolRegistrations array, which conditionally calls registerSetSimulatorLocationTool based on environment variable.
    register: registerSetSimulatorLocationTool, groups: [ToolGroup.SIMULATOR_MANAGEMENT], envVar: 'XCODEBUILDMCP_TOOL_SET_SIMULATOR_LOCATION', },

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/SampsonKY/XcodeBuildMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server