getInstalledApps
Retrieve a list of applications installed on your current device to audit software inventory or identify available tools.
Instructions
获取当前设备已安装的应用信息
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "getInstalledApps"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:501-529 (handler)The handler case for the 'getInstalledApps' tool within the switch statement in handleCallToolRequest. It detects the OS platform and uses appropriate system commands (system_profiler on macOS, dpkg/rpm on Linux, PowerShell WMI on Windows) to list installed applications and returns them as a JSON array.
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 (registration)The tool registration in the list of tools returned by handleRequest function, including name, description, and empty inputSchema.
{ name: "getInstalledApps", description: "获取当前设备已安装的应用信息", inputSchema: { type: "object", properties: {}, required: [] } }, - src/index.ts:148-152 (schema)The input schema for the getInstalledApps tool, which takes no parameters (empty object).
inputSchema: { type: "object", properties: {}, required: [] }