Skip to main content
Glama

shutdown_simulator

Shut down iOS, macOS, or other Apple platform simulators by device ID or name to manage Xcode development resources and optimize workflow efficiency.

Instructions

Shutdown a simulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdYesDevice UDID or name of the simulator to shutdown

Implementation Reference

  • The execute method implements the core handler logic for the 'shutdown_simulator' MCP tool, handling input validation, use case execution, error handling, and response formatting.
    async execute(args: unknown): Promise<{ content: Array<{ type: string; text: string }> }> {
      try {
        // Cast to expected shape
        const input = args as { deviceId: unknown };
    
        // Create domain value object - will validate
        const deviceId = DeviceId.create(input.deviceId);
    
        // Create domain request
        const request = ShutdownRequest.create(deviceId);
    
        // Execute use case
        const result = await this.useCase.execute(request);
        
        // Format response
        return {
          content: [{
            type: 'text',
            text: this.formatResult(result)
          }]
        };
      } catch (error: any) {
        // Handle validation and other errors consistently
        const message = ErrorFormatter.format(error);
        return {
          content: [{
            type: 'text',
            text: `❌ ${message}`
          }]
        };
      }
    }
  • Defines the input schema for the shutdown_simulator tool, requiring a 'deviceId' string parameter.
    get inputSchema() {
      return {
        type: 'object' as const,
        properties: {
          deviceId: {
            type: 'string' as const,
            description: 'Device UDID or name of the simulator to shutdown'
          }
        },
        required: ['deviceId'] as const
      };
    }
  • src/index.ts:83-83 (registration)
    The ShutdownSimulatorController is instantiated via its factory during tool registration in the main server setup.
    ShutdownSimulatorControllerFactory.create(),
  • The use case execute method contains the business logic for shutting down a simulator, including locator, state checks, and control operations.
    async execute(request: ShutdownRequest): Promise<ShutdownResult> {
      // Find the simulator
      const simulator = await this.simulatorLocator.findSimulator(request.deviceId);
      
      if (!simulator) {
        return ShutdownResult.failed(
          request.deviceId,
          '',  // No name available since simulator wasn't found
          new SimulatorNotFoundError(request.deviceId)
        );
      }
      
      // Check simulator state
      if (simulator.state === SimulatorState.Shutdown) {
        return ShutdownResult.alreadyShutdown(
          simulator.id,
          simulator.name
        );
      }
      
      // Handle ShuttingDown state - simulator is already shutting down
      if (simulator.state === SimulatorState.ShuttingDown) {
        return ShutdownResult.alreadyShutdown(
          simulator.id,
          simulator.name
        );
      }
      
      // Shutdown the simulator (handles Booted and Booting states)
      try {
        await this.simulatorControl.shutdown(simulator.id);
        
        return ShutdownResult.shutdown(
          simulator.id,
          simulator.name
        );
      } catch (error: any) {
        return ShutdownResult.failed(
          simulator.id,
          simulator.name,
          new ShutdownCommandFailedError(error.stderr || error.message || '')
        );
      }
    }
  • Factory method that wires all dependencies for the ShutdownSimulatorController, including adapters, use case, and decorators.
    static create(): MCPController {
      // Create the shell executor that all adapters will use
      const execAsync = promisify(exec);
      const executor = new ShellCommandExecutorAdapter(execAsync);
    
      // Create infrastructure adapters
      const simulatorLocator = new SimulatorLocatorAdapter(executor);
      const simulatorControl = new SimulatorControlAdapter(executor);
    
      // Create the use case with all dependencies
      const useCase = new ShutdownSimulatorUseCase(
        simulatorLocator,
        simulatorControl
      );
    
      // Create the controller
      const controller = new ShutdownSimulatorController(useCase);
    
      // Create dependency checker
      const dependencyChecker = new DependencyChecker(executor);
    
      // Wrap with dependency checking decorator
      const decoratedController = new DependencyCheckingDecorator(
        controller,
        ['xcrun'],  // simctl is part of xcrun
        dependencyChecker
      );
    
      return decoratedController;
    }
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. 'Shutdown' implies a destructive action, but the description doesn't clarify if this requires specific permissions, whether it's reversible, what happens to running processes, or error conditions. It lacks essential context 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 extremely concise with just three words, front-loading the essential information without any wasted text. Every word earns its place in communicating the core function.

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 destructive tool with no annotations and no output schema, the description is inadequate. It doesn't explain what 'shutdown' entails behaviorally, what the response looks like, or error handling. Given the complexity of a mutation operation, more context is needed.

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 single parameter 'deviceId' well-documented in the schema. The description doesn't add any parameter details beyond what the schema provides, so it meets the baseline score when 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 'Shutdown a simulator' clearly states the action (shutdown) and target resource (simulator), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'boot_simulator' or 'list_simulators' beyond the obvious action difference, so it doesn't reach the highest score.

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 like 'boot_simulator' or prerequisites for shutdown. It merely states what the tool does without context about appropriate usage scenarios or exclusions.

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/Stefan-Nitu/mcp-xcode'

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