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 }],
        };
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe important behavioral aspects: whether this is a persistent setting, if it affects all simulator traffic, what permissions are needed, whether it's reversible (hinting at reset_network_condition but not explicit), or what happens on failure. For a configuration tool with mutation implications, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point. It front-loads the core purpose and provides helpful examples. However, it could be slightly more structured by separating the purpose from the profile examples for better readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that modifies simulator state with no annotations and no output schema, the description is insufficient. It doesn't explain the tool's effect duration, error conditions, relationship to reset_network_condition, or what happens to existing network conditions. Given the complexity of network simulation and lack of structured behavioral hints, more context is needed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters well-documented in the schema. The description adds minimal value beyond the schema by listing example profiles in parentheses, but doesn't explain profile semantics (e.g., what '100%loss' means operationally) or provide context about simulatorUuid beyond what's in the schema. Baseline 3 is appropriate given the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Simulates different network conditions in the simulator.' It specifies the verb ('simulates') and resource ('network conditions'), and provides concrete examples of profiles. However, it doesn't explicitly differentiate from sibling 'reset_network_condition', which is a related but distinct operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a simulator UUID from list_simulators), when this should be applied (before/after app launch), or how it relates to sibling tools like reset_network_condition. The agent must infer usage from parameter descriptions alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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