list_applications
Discover and display all applications installed in the /Applications folder on a Mac system using this command-line tool for quick access and organization.
Instructions
List all applications installed in the /Applications folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools.ts:38-47 (handler)The tool handler callback that calls the listApplications helper, formats the app list as a numbered string, and returns it as a text content result.cb: async () => { const apps = await listApplications(); const appListString = apps.reduce((acc, app, index) => { return `${acc}${index + 1}. ${app}\n`; }, ""); const toolResult: CallToolResult = { content: [{ type: "text", text: appListString }], }; return toolResult; },
- tools.ts:9-9 (schema)Input schema for the list_applications tool (empty object as it requires no input parameters).export const ListApplicationsInputSchema = {};
- tools.ts:103-107 (registration)Registration of the list_applications tool config (along with others) in the exported tools array.export const tools: ToolConfig<any>[] = [ listApplicationsConfig, launchAppConfig, openWithAppConfig, ];
- utils/index.ts:8-16 (helper)Helper function imported and used by the tool handler to retrieve the list of .app files from /Applications directory.export async function listApplications(): Promise<string[]> { try { const files = await readdir("/Applications"); return files.filter((file) => file.endsWith(".app")).sort(); } catch (error) { console.error("Error listing applications:", error); return []; } }
- tools.ts:27-48 (registration)Definition of the tool configuration object for list_applications, including name, description, annotations, schema reference, and inline handler callback.const listApplicationsConfig: ToolConfig<typeof ListApplicationsInputSchema> = { name: "list_applications", description: "List all applications installed in the /Applications folder", annotations: { title: "列出所有應用程式", readOnlyHint: true, // 只讀取應用程式列表,不修改系統 destructiveHint: false, // 不執行任何破壞性操作 idempotentHint: true, // 重複呼叫會得到相同結果(若應用程式列表未變) openWorldHint: false, // 只與本機檔案系統互動,不連接外部系統 }, schema: ListApplicationsInputSchema, cb: async () => { const apps = await listApplications(); const appListString = apps.reduce((acc, app, index) => { return `${acc}${index + 1}. ${app}\n`; }, ""); const toolResult: CallToolResult = { content: [{ type: "text", text: appListString }], }; return toolResult; }, };