reset_network_condition
Restore simulator network conditions to default settings by specifying the simulator UUID, ensuring stable testing environments.
Instructions
Resets network conditions to default in the simulator.
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:697-708 (handler)The handler function for the 'reset_network_condition' tool. It logs the action and invokes the shared executeSimctlCommandAndRespond helper to run 'xcrun simctl status_bar <uuid> clear'.async (params: { simulatorUuid: string }): Promise<ToolResponse> => { log('info', `Resetting simulator ${params.simulatorUuid} network condition`); return executeSimctlCommandAndRespond( params, ['status_bar', params.simulatorUuid, 'clear'], 'Reset Network Condition', `Successfully reset simulator ${params.simulatorUuid} network conditions.`, 'Failed to reset network condition', 'reset network condition', ); },
- src/tools/simulator.ts:692-696 (schema)Zod input schema for the tool, requiring a 'simulatorUuid' string parameter.{ simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), },
- src/tools/simulator.ts:688-710 (registration)Direct registration function that registers the 'reset_network_condition' tool on the MCP server using server.tool(), including name, description, schema, and inline handler.export function registerResetNetworkConditionTool(server: McpServer): void { server.tool( 'reset_network_condition', 'Resets network conditions to default in the simulator.', { 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} network condition`); return executeSimctlCommandAndRespond( params, ['status_bar', params.simulatorUuid, 'clear'], 'Reset Network Condition', `Successfully reset simulator ${params.simulatorUuid} network conditions.`, 'Failed to reset network condition', 'reset network condition', ); }, ); }
- src/utils/register-tools.ts:353-357 (registration)Entry in the toolRegistrations array that includes registerResetNetworkConditionTool for conditional registration based on the XCODEBUILDMCP_TOOL_RESET_NETWORK_CONDITION environment variable.{ register: registerResetNetworkConditionTool, groups: [ToolGroup.SIMULATOR_MANAGEMENT], envVar: 'XCODEBUILDMCP_TOOL_RESET_NETWORK_CONDITION', },
- src/tools/simulator.ts:500-557 (helper)Helper utility shared across simulator tools that validates simulatorUuid, optionally runs extra validation, executes 'xcrun simctl' commands via executeCommand, logs outcomes, and returns standardized ToolResponse objects.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 }], }; } }