Skip to main content
Glama
JackXuyi

Current operating environment

getInstalledApps

Retrieve a list of applications installed on your current device to audit software inventory or identify available tools.

Instructions

获取当前设备已安装的应用信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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: []
      }
    },
  • The input schema for the getInstalledApps tool, which takes no parameters (empty object).
    inputSchema: {
      type: "object",
      properties: {},
      required: []
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JackXuyi/env-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server