Skip to main content
Glama

set_network_condition

Simulate network conditions like wifi, 3G, or high latency in simulators to test application performance under various connection scenarios.

Instructions

Simulates different network conditions (e.g., wifi, 3g, edge, high-latency, dsl, 100%loss, 3g-lossy, very-lossy) in the simulator.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
simulatorUuidYesUUID of the simulator to use (obtained from list_simulators)
profileYesThe network profile to simulate. Must be one of: wifi, 3g, edge, high-latency, dsl, 100%loss, 3g-lossy, very-lossy.

Implementation Reference

  • The tool handler function that validates parameters, logs the action, and executes the 'xcrun simctl status_bar override --dataNetwork <profile>' command via the helper function to simulate network conditions.
    async (params: { simulatorUuid: string; profile: string }): Promise<ToolResponse> => { log( 'info', `Setting simulator ${params.simulatorUuid} network condition to ${params.profile}`, ); return executeSimctlCommandAndRespond( params, ['status_bar', params.simulatorUuid, 'override', '--dataNetwork', params.profile], 'Set Network Condition', `Successfully set simulator ${params.simulatorUuid} network condition to ${params.profile} profile`, 'Failed to set network condition', 'set network condition', ); },
  • Input schema using Zod for simulatorUuid (string) and profile (enum: wifi, 3g, edge, etc.).
    { simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), profile: z .enum(['wifi', '3g', 'edge', 'high-latency', 'dsl', '100%loss', '3g-lossy', 'very-lossy']) .describe( 'The network profile to simulate. Must be one of: wifi, 3g, edge, high-latency, dsl, 100%loss, 3g-lossy, very-lossy.', ), },
  • Registration function that calls server.tool('set_network_condition', ...) to register the tool with schema and handler.
    export function registerSetNetworkConditionTool(server: McpServer): void { server.tool( 'set_network_condition', 'Simulates different network conditions (e.g., wifi, 3g, edge, high-latency, dsl, 100%loss, 3g-lossy, very-lossy) in the simulator.', { simulatorUuid: z .string() .describe('UUID of the simulator to use (obtained from list_simulators)'), profile: z .enum(['wifi', '3g', 'edge', 'high-latency', 'dsl', '100%loss', '3g-lossy', 'very-lossy']) .describe( 'The network profile to simulate. Must be one of: wifi, 3g, edge, high-latency, dsl, 100%loss, 3g-lossy, very-lossy.', ), }, async (params: { simulatorUuid: string; profile: string }): Promise<ToolResponse> => { log( 'info', `Setting simulator ${params.simulatorUuid} network condition to ${params.profile}`, ); return executeSimctlCommandAndRespond( params, ['status_bar', params.simulatorUuid, 'override', '--dataNetwork', params.profile], 'Set Network Condition', `Successfully set simulator ${params.simulatorUuid} network condition to ${params.profile} profile`, 'Failed to set network condition', 'set network condition', ); }, ); }
  • High-level tool registration entry that conditionally registers registerSetNetworkConditionTool based on environment variable.
    register: registerSetNetworkConditionTool, groups: [ToolGroup.SIMULATOR_MANAGEMENT], envVar: 'XCODEBUILDMCP_TOOL_SET_NETWORK_CONDITION', },
  • Shared helper function used by multiple simulator tools to execute xcrun simctl commands, handle validation, errors, and 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 }], }; } }

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