launch_app
Quickly launch Mac applications by specifying the app name, enabling efficient app management directly from the macOS command line.
Instructions
Launch a Mac application by name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appName | Yes |
Implementation Reference
- utils/index.ts:18-28 (handler)The launchApp function implements the core logic to launch a Mac application using the 'open' command.export async function launchApp(appName: string): Promise<boolean> { try { const fullAppName = appName.endsWith(".app") ? appName : `${appName}.app`; const appPath = join("/Applications", fullAppName); await execAsync(`open "${appPath}"`); return true; } catch (error) { console.error("Error launching application:", error); return false; } }
- tools.ts:10-12 (schema)Zod input schema for the launch_app tool, requiring 'appName' as string.export const LaunchAppInputSchema = { appName: z.string(), };
- tools.ts:50-75 (registration)Tool configuration object for 'launch_app' including name, description, annotations, schema reference, and thin wrapper callback that invokes the launchApp utility.const launchAppConfig: ToolConfig<typeof LaunchAppInputSchema> = { name: "launch_app", description: "Launch a Mac application by name", annotations: { title: "啟動應用程式", readOnlyHint: false, // 會修改系統狀態(啟動應用程式) destructiveHint: false, // 不執行破壞性操作 idempotentHint: false, // 重複啟動可能有不同結果 openWorldHint: true, // 與外部應用程式互動 }, schema: LaunchAppInputSchema, cb: async (args) => { const success = await launchApp(args.appName); const toolResult: CallToolResult = { content: [ { type: "text", text: success ? "Application launched successfully" : "Failed to launch application", }, ], }; return toolResult; }, };
- tools.ts:103-107 (registration)Export of the tools array where launchAppConfig is registered alongside other tools for use in the MCP server.export const tools: ToolConfig<any>[] = [ listApplicationsConfig, launchAppConfig, openWithAppConfig, ];