Skip to main content
Glama

set_sim_appearance

Change the visual theme of an iOS simulator by switching between dark and light appearance modes using the simulator's UUID.

Instructions

Sets the appearance mode (dark/light) of an iOS simulator.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
simulatorUuidYesUUID of the simulator to use (obtained from list_simulators)
modeYesThe appearance mode to set (either "dark" or "light")

Implementation Reference

  • Registers the 'set_sim_appearance' tool with the MCP server, defining its description, input schema, and handler function.
    export function registerSetSimulatorAppearanceTool(server: McpServer): void {
      server.tool(
        'set_sim_appearance',
        'Sets the appearance mode (dark/light) of an iOS simulator.',
        {
          simulatorUuid: z
            .string()
            .describe('UUID of the simulator to use (obtained from list_simulators)'),
          mode: z
            .enum(['dark', 'light'])
            .describe('The appearance mode to set (either "dark" or "light")'),
        },
        async (params: { simulatorUuid: string; mode: 'dark' | 'light' }): Promise<ToolResponse> => {
          log('info', `Setting simulator ${params.simulatorUuid} appearance to ${params.mode} mode`);
    
          return executeSimctlCommandAndRespond(
            params,
            ['ui', params.simulatorUuid, 'appearance', params.mode],
            'Set Simulator Appearance',
            `Successfully set simulator ${params.simulatorUuid} appearance to ${params.mode} mode`,
            'Failed to set simulator appearance',
            'set simulator appearance',
          );
        },
      );
    }
  • The handler function for 'set_sim_appearance' that logs the action and delegates to executeSimctlCommandAndRespond to run 'xcrun simctl ui <uuid> appearance <mode>'.
    async (params: { simulatorUuid: string; mode: 'dark' | 'light' }): Promise<ToolResponse> => {
      log('info', `Setting simulator ${params.simulatorUuid} appearance to ${params.mode} mode`);
    
      return executeSimctlCommandAndRespond(
        params,
        ['ui', params.simulatorUuid, 'appearance', params.mode],
        'Set Simulator Appearance',
        `Successfully set simulator ${params.simulatorUuid} appearance to ${params.mode} mode`,
        'Failed to set simulator appearance',
        'set simulator appearance',
      );
    },
  • Zod schema defining the input parameters: simulatorUuid (string) and mode (enum: 'dark' | 'light').
      simulatorUuid: z
        .string()
        .describe('UUID of the simulator to use (obtained from list_simulators)'),
      mode: z
        .enum(['dark', 'light'])
        .describe('The appearance mode to set (either "dark" or "light")'),
    },
  • Shared helper function that performs validation, executes simctl commands via executeCommand, handles success/error responses, and logging. Used by set_sim_appearance handler.
    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