Skip to main content
Glama
conorluddy

XC-MCP: XCode CLI wrapper

by conorluddy

simctl-shutdown

Shutdown iOS simulator devices intelligently using 'booted' or 'all' options, with enhanced error handling, state tracking, and batch operations for efficient device management.

Instructions

⚔ Prefer this over 'xcrun simctl shutdown' - Intelligent shutdown with better device management.

Advantages over direct CLI: • šŸŽÆ Smart device targeting - "booted" and "all" options vs complex CLI syntax • šŸ›”ļø Better error handling - Clear feedback when devices can't be shut down • šŸ“Š State tracking - Updates internal device state for better recommendations • ⚔ Batch operations - Efficiently handle multiple device shutdowns

Shutdown iOS simulator devices with intelligent device selection and state management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdYesDevice UDID, "booted" for all booted devices, or "all" for all devices

Implementation Reference

  • Core handler function that executes the simctl shutdown command with validation, error handling, and response formatting.
    export async function simctlShutdownTool(args: any) {
      const { deviceId } = args as SimctlShutdownToolArgs;
    
      try {
        // Validate inputs
        validateDeviceId(deviceId);
    
        // Build shutdown command
        const command = buildSimctlCommand('shutdown', { deviceId });
    
        console.error(`[simctl-shutdown] Executing: ${command}`);
    
        // Execute shutdown command
        const startTime = Date.now();
        const result = await executeCommand(command, {
          timeout: 60000, // 1 minute for shutdown
        });
        const duration = Date.now() - startTime;
    
        let shutdownStatus = {
          success: result.code === 0,
          command,
          output: result.stdout,
          error: result.stderr,
          exitCode: result.code,
          duration,
        };
    
        // Handle common shutdown scenarios
        if (!shutdownStatus.success) {
          // Device already shutdown
          if (result.stderr.includes('Unable to shutdown device in current state: Shutdown')) {
            shutdownStatus = {
              ...shutdownStatus,
              success: true,
              error: 'Device was already shut down',
            };
          }
          // Invalid device ID
          else if (result.stderr.includes('Invalid device')) {
            throw new McpError(ErrorCode.InvalidParams, `Invalid device ID: ${deviceId}`);
          }
        }
    
        // Format response
        const responseText = JSON.stringify(shutdownStatus, null, 2);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: responseText,
            },
          ],
          isError: !shutdownStatus.success,
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `simctl-shutdown failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Type definition for the tool input parameters.
    interface SimctlShutdownToolArgs {
      deviceId: string;
    }
  • Router dispatcher that calls the shutdown handler for 'shutdown' operation in the consolidated simctl-device tool.
    case 'shutdown':
      if (!args.deviceId) {
        throw new McpError(ErrorCode.InvalidRequest, 'deviceId is required for shutdown operation');
      }
      return simctlShutdownTool({ deviceId: args.deviceId });
    case 'create':
  • Registers the consolidated 'simctl-device' tool, which implements simctl-shutdown functionality via operation='shutdown'.
    // simctl-device
    server.registerTool(
      'simctl-device',
      {
        description: getDescription(SIMCTL_DEVICE_DOCS, SIMCTL_DEVICE_DOCS_MINI),
        inputSchema: {
          operation: z.enum(['boot', 'shutdown', 'create', 'delete', 'erase', 'clone', 'rename']),
          deviceId: z.string().optional(),
          waitForBoot: z.boolean().default(true),
          openGui: z.boolean().default(true),
          name: z.string().optional(),
          deviceType: z.string().optional(),
          runtime: z.string().optional(),
          force: z.boolean().default(false),
          newName: z.string().optional(),
        },
        ...DEFER_LOADING_CONFIG,
      },
      async args => {
        try {
          await validateXcodeInstallation();
          return await simctlDeviceTool(args);
        } catch (error) {
          if (error instanceof McpError) throw error;
          throw new McpError(
            ErrorCode.InternalError,
            `Tool execution failed: ${error instanceof Error ? error.message : String(error)}`
          );
        }
      }
    );
  • Import statement that brings in the shutdown handler for use in the device router.
    import { simctlShutdownTool } from '../shutdown.js';
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: intelligent device targeting with 'booted' and 'all' options, better error handling, state tracking for recommendations, and batch operations. However, it lacks details on permissions, rate limits, or what happens if shutdown fails, leaving some gaps in behavioral transparency.

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 well-structured and concise, using bullet points to highlight advantages and a summary sentence. Every sentence adds value, with no wasted words. It's front-loaded with the key recommendation and efficiently communicates the tool's benefits without unnecessary elaboration.

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

Completeness4/5

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

Given the tool's complexity (shutdown operation with state management) and no annotations or output schema, the description does a good job covering purpose, usage, and behaviors. However, it lacks details on return values or error formats, which would be helpful for an agent. For a tool with no structured output, more on what to expect post-execution would improve completeness.

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?

The input schema has 100% description coverage, with the deviceId parameter fully documented. The description adds minimal semantics beyond the schema, mentioning 'booted' and 'all' options but not elaborating further. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

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

Purpose5/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: 'Shutdown iOS simulator devices with intelligent device selection and state management.' It specifies the verb ('shutdown'), resource ('iOS simulator devices'), and distinguishes from the CLI alternative. The opening sentence explicitly contrasts it with 'xcrun simctl shutdown', making the distinction clear.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: '⚔ **Prefer this over 'xcrun simctl shutdown'**' and lists advantages like smart device targeting, better error handling, state tracking, and batch operations. It directly names the alternative (CLI) and explains why this tool is superior, giving clear 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

Related 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/conorluddy/xc-mcp'

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