Skip to main content
Glama

ios_shutdown_simulator

Shuts down iOS simulators to free system resources and manage virtual devices during mobile development testing workflows.

Instructions

Shutdown an iOS simulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
udidYesSimulator UDID

Implementation Reference

  • The main handler function for the ios_shutdown_simulator tool. It validates the UDID input using Zod schema, checks UDID format, stops any active video recordings for the simulator, executes 'xcrun simctl shutdown' command, handles already shutdown case (exit code 164), and returns structured success response.
    handler: async (args: any) => {
      checkMacOS();
    
      const validation = IosSimulatorActionSchema.safeParse(args);
      if (!validation.success) {
        throw new Error(`Invalid request: ${validation.error.message}`);
      }
    
      const { udid } = validation.data;
    
      // Validate UDID format
      if (!validateUDID(udid)) {
        throw new Error(`Invalid simulator UDID format. UDID must be in format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX: ${udid}`);
      }
    
      // Stop any active recordings for this simulator
      if (activeRecordings.has(udid)) {
        const pid = activeRecordings.get(udid);
        try {
          process.kill(pid!, 'SIGTERM');
          activeRecordings.delete(udid);
        } catch {
          // Process might already be dead
          activeRecordings.delete(udid);
        }
      }
    
      const result = await processExecutor.execute('xcrun', ['simctl', 'shutdown', udid], {
        timeout: 30000, // 30 seconds timeout for shutdown
      });
    
      // Note: simctl shutdown returns exit code 164 if simulator is already shut down
      if (result.exitCode !== 0 && result.exitCode !== 164) {
        throw new Error(`Failed to shutdown iOS simulator: ${result.stderr}`);
      }
    
      const wasAlreadyShutdown = result.exitCode === 164;
    
      return {
        success: true,
        data: {
          udid,
          status: wasAlreadyShutdown ? 'already_shutdown' : 'shutdown',
          message: wasAlreadyShutdown ? 'Simulator was already shut down' : 'Simulator shut down successfully',
          output: result.stdout,
        },
      };
    }
  • Registration of the ios_shutdown_simulator tool in the tools Map within createIOSTools function, including name, description, inputSchema (JSON Schema), and handler reference.
    tools.set('ios_shutdown_simulator', {
      name: 'ios_shutdown_simulator',
      description: 'Shutdown an iOS simulator',
      inputSchema: {
        type: 'object',
        properties: {
          udid: { type: 'string', minLength: 1, description: 'Simulator UDID' }
        },
        required: ['udid']
      },
      handler: async (args: any) => {
        checkMacOS();
    
        const validation = IosSimulatorActionSchema.safeParse(args);
        if (!validation.success) {
          throw new Error(`Invalid request: ${validation.error.message}`);
        }
    
        const { udid } = validation.data;
    
        // Validate UDID format
        if (!validateUDID(udid)) {
          throw new Error(`Invalid simulator UDID format. UDID must be in format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX: ${udid}`);
        }
    
        // Stop any active recordings for this simulator
        if (activeRecordings.has(udid)) {
          const pid = activeRecordings.get(udid);
          try {
            process.kill(pid!, 'SIGTERM');
            activeRecordings.delete(udid);
          } catch {
            // Process might already be dead
            activeRecordings.delete(udid);
          }
        }
    
        const result = await processExecutor.execute('xcrun', ['simctl', 'shutdown', udid], {
          timeout: 30000, // 30 seconds timeout for shutdown
        });
    
        // Note: simctl shutdown returns exit code 164 if simulator is already shut down
        if (result.exitCode !== 0 && result.exitCode !== 164) {
          throw new Error(`Failed to shutdown iOS simulator: ${result.stderr}`);
        }
    
        const wasAlreadyShutdown = result.exitCode === 164;
    
        return {
          success: true,
          data: {
            udid,
            status: wasAlreadyShutdown ? 'already_shutdown' : 'shutdown',
            message: wasAlreadyShutdown ? 'Simulator was already shut down' : 'Simulator shut down successfully',
            output: result.stdout,
          },
        };
      }
    });
  • Zod validation schema used internally by the handler for input validation (udid: string min length 1). Shared with other simulator action tools.
    const IosSimulatorActionSchema = z.object({
      udid: z.string().min(1),
    });
  • Helper function to validate iOS Simulator UDID format using UUID v4 regex pattern. Called within the handler.
    const validateUDID = (udid: string): boolean => {
      const uuidPattern = /^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/i;
      return uuidPattern.test(udid);
    };
  • Tool metadata registration in TOOL_REGISTRY, specifying category, platform, required tools (XCRUN), safety, and performance expectations.
    'ios_shutdown_simulator': {
      name: 'ios_shutdown_simulator',
      category: ToolCategory.ESSENTIAL,
      platform: 'ios',
      requiredTools: [RequiredTool.XCRUN],
      description: 'Shutdown iOS simulator',
      safeForTesting: false,
      performance: { expectedDuration: 5000, timeout: 30000 }
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action without behavioral details. It doesn't disclose if shutdown is destructive, requires specific simulator states, has side effects, or what happens on success/failure, leaving significant gaps for a mutation tool.

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

Conciseness5/5

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

The description is a single, direct sentence with no wasted words, making it highly concise and front-loaded. Every word contributes to stating the tool's purpose efficiently.

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?

Given the tool's complexity (a mutation with no annotations and no output schema), the description is incomplete. It lacks details on behavioral traits, usage context, and expected outcomes, failing to provide enough information for safe and effective use by an AI agent.

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 the parameter 'udid' documented as 'Simulator UDID', so the schema provides complete parameter info. The description adds no additional meaning beyond the schema, resulting in a baseline score of 3 as it doesn't compensate but schema is sufficient.

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 'Shutdown an iOS simulator' clearly states the action (shutdown) and target resource (iOS simulator), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like 'android_stop_emulator' or 'ios_boot_simulator' beyond the iOS platform mention, missing explicit sibling distinction.

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?

No guidance is provided on when to use this tool versus alternatives like 'android_stop_emulator' or 'ios_boot_simulator', nor does it mention prerequisites such as needing a booted simulator. The description only states what it does without context for selection.

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/cristianoaredes/mcp-mobile-server'

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