getInstalledApps
Retrieve a list of installed applications on the current device to assess the operating environment and manage application configurations.
Instructions
获取当前设备已安装的应用信息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"required": [],
"type": "object"
}
Implementation Reference
- src/index.ts:501-529 (handler)The switch case that implements the getInstalledApps tool logic. It uses platform-specific commands to fetch lists of installed applications and returns them as JSON.case "getInstalledApps": { let installedApps: string[] = []; try { if (os.platform() === 'darwin') { // macOS 使用 system_profiler 命令获取已安装的应用 const apps = execSync('system_profiler SPApplicationsDataType -json').toString(); installedApps = JSON.parse(apps).SPApplicationsDataType.map((app: any) => app._name); } else if (os.platform() === 'linux') { // Linux 使用 dpkg 或 rpm 命令获取已安装的软件包 try { installedApps = execSync('dpkg --list | grep ^ii').toString().split('\n').map(line => line.split(/\s+/)[1]); } catch (error) { installedApps = execSync('rpm -qa').toString().split('\n'); } } else if (os.platform() === 'win32') { // Windows 使用 Get-WmiObject 命令获取已安装的应用 const apps = execSync('powershell -Command "Get-WmiObject -Class Win32_Product | Select-Object -Property Name"').toString(); installedApps = apps.split('\n').filter(line => line.trim()).slice(1); } } catch (error) { console.error("获取已安装应用信息失败:", error); } return { content: [{ type: "text", text: JSON.stringify({ installedApps }, null, 2) }] };
- src/index.ts:145-153 (schema)The tool schema definition including name, description, and empty input schema, provided in the list of tools for registration.{ name: "getInstalledApps", description: "获取当前设备已安装的应用信息", inputSchema: { type: "object", properties: {}, required: [] } },
- src/index.ts:787-787 (registration)Registration of the ListToolsRequestSchema handler which returns the list of tools including getInstalledApps.server.setRequestHandler(ListToolsRequestSchema, handleRequest);
- src/index.ts:790-790 (registration)Registration of the CallToolRequestSchema handler which dispatches to the getInstalledApps case.server.setRequestHandler(CallToolRequestSchema, handleCallToolRequest);