Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
registerInstallAppInSimulatorTool,
registerLaunchAppInSimulatorTool,
registerLaunchAppWithLogsInSimulatorTool,
registerSetSimulatorAppearanceTool,
} from './tools/simulator.js';

// Import bundle ID tools
Expand Down Expand Up @@ -134,6 +135,7 @@ async function main(): Promise<void> {
// Register Simulator management tools
registerBootSimulatorTool(server);
registerOpenSimulatorTool(server);
registerSetSimulatorAppearanceTool(server);

// Register App installation and launch tools
registerInstallAppInSimulatorTool(server);
Expand Down
60 changes: 60 additions & 0 deletions src/tools/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* - Opening the Simulator.app application
* - Installing applications in simulators
* - Launching applications in simulators by bundle ID
* - Setting the appearance mode of simulators (dark/light)
*/

import { z } from 'zod';
Expand Down Expand Up @@ -495,3 +496,62 @@ export function registerOpenSimulatorTool(server: McpServer): void {
},
);
}

export function registerSetSimulatorAppearanceTool(server: McpServer): void {
server.tool(
'set_simulator_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): Promise<ToolResponse> => {
const simulatorUuidValidation = validateRequiredParam('simulatorUuid', params.simulatorUuid);
if (!simulatorUuidValidation.isValid) {
return simulatorUuidValidation.errorResponse!;
}

log('info', `Setting simulator ${params.simulatorUuid} appearance to ${params.mode} mode`);

try {
const command = ['xcrun', 'simctl', 'ui', params.simulatorUuid, 'appearance', params.mode];
const result = await executeXcodeCommand(command, 'Set Simulator Appearance');

if (!result.success) {
return {
content: [
{
type: 'text',
text: `Failed to set simulator appearance: ${result.error}`,
},
],
};
}

return {
content: [
{
type: 'text',
text: `Successfully set simulator ${params.simulatorUuid} to ${params.mode} mode`,
},
],
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
log('error', `Error setting simulator appearance: ${errorMessage}`);
return {
content: [
{
type: 'text',
text: `Failed to set simulator appearance: ${errorMessage}`,
},
],
};
}
},
);
}