stop_mac_app
Stops a running macOS application by specifying its name or process ID, ensuring precise control over app termination on the XcodeBuildMCP server.
Instructions
Stops a running macOS application. Can stop by app name or process ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appName | No | Name of the application to stop (e.g., "Calculator" or "MyApp") | |
| processId | No | Process ID (PID) of the application to stop |
Implementation Reference
- The main handler function stop_mac_appLogic that implements the tool logic: validates params, constructs shell command to kill by PID or app name using pkill/osascript, executes via executor, handles errors and returns ToolResponse.export async function stop_mac_appLogic( params: StopMacAppParams, executor: CommandExecutor, ): Promise<ToolResponse> { if (!params.appName && !params.processId) { return { content: [ { type: 'text', text: 'Either appName or processId must be provided.', }, ], isError: true, }; } log( 'info', `Stopping macOS app: ${params.processId ? `PID ${params.processId}` : params.appName}`, ); try { let command: string[]; if (params.processId) { // Stop by process ID command = ['kill', String(params.processId)]; } else { // Stop by app name - use shell command with fallback for complex logic command = [ 'sh', '-c', `pkill -f "${params.appName}" || osascript -e 'tell application "${params.appName}" to quit'`, ]; } await executor(command, 'Stop macOS App'); return { content: [ { type: 'text', text: `✅ macOS app stopped successfully: ${params.processId ? `PID ${params.processId}` : params.appName}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log('error', `Error stopping macOS app: ${errorMessage}`); return { content: [ { type: 'text', text: `❌ Stop macOS app operation failed: ${errorMessage}`, }, ], isError: true, }; } }
- Zod schema defining the input parameters for the tool: optional appName (string) or processId (number).const stopMacAppSchema = z.object({ appName: z .string() .optional() .describe('Name of the application to stop (e.g., "Calculator" or "MyApp")'), processId: z.number().optional().describe('Process ID (PID) of the application to stop'), });
- src/mcp/tools/macos/stop_mac_app.ts:81-86 (registration)Tool registration as default export, providing name, description, schema, and handler created via createTypedTool wrapping stop_mac_appLogic.export default { name: 'stop_mac_app', description: 'Stops a running macOS application. Can stop by app name or process ID.', schema: stopMacAppSchema.shape, // MCP SDK compatibility handler: createTypedTool(stopMacAppSchema, stop_mac_appLogic, getDefaultCommandExecutor), };