Skip to main content
Glama
alxspiker

Windows Command Line MCP Server

get_system_info

Retrieve Windows system information including OS details, hardware specifications, and user data. Choose basic or full detail levels to get system insights.

Instructions

Retrieve system information including OS, hardware, and user details. Can provide basic or full details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
detailNoLevel of detailbasic

Implementation Reference

  • The main handler function for the 'get_system_info' tool. It constructs and executes platform-specific shell commands (PowerShell on Windows, standard Unix commands otherwise) to fetch system details like OS, CPU, memory, storage, and network info based on the 'detail' parameter ('basic' or 'full'). Returns formatted text output or error.
    async ({ detail }) => {
      try {
        let cmd;
        
        if (isWindows) {
          cmd = "powershell.exe -Command \"";
          
          if (detail === "basic") {
            cmd += "$OS = Get-CimInstance Win32_OperatingSystem; " +
                  "$CS = Get-CimInstance Win32_ComputerSystem; " +
                  "$Processor = Get-CimInstance Win32_Processor; " +
                  "Write-Output 'OS: ' $OS.Caption $OS.Version; " +
                  "Write-Output 'Computer: ' $CS.Manufacturer $CS.Model; " +
                  "Write-Output 'CPU: ' $Processor.Name; " +
                  "Write-Output 'Memory: ' [math]::Round($OS.TotalVisibleMemorySize/1MB, 2) 'GB'";
          } else {
            cmd += "$OS = Get-CimInstance Win32_OperatingSystem; " +
                  "$CS = Get-CimInstance Win32_ComputerSystem; " +
                  "$Processor = Get-CimInstance Win32_Processor; " +
                  "$Disk = Get-CimInstance Win32_LogicalDisk -Filter 'DriveType=3'; " +
                  "$Network = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object {$_.IPAddress -ne $null}; " +
                  "Write-Output '=== OPERATING SYSTEM ==='; " +
                  "Write-Output ('OS: ' + $OS.Caption + ' ' + $OS.Version); " +
                  "Write-Output ('Architecture: ' + $OS.OSArchitecture); " +
                  "Write-Output ('Install Date: ' + $OS.InstallDate); " +
                  "Write-Output ('Last Boot: ' + $OS.LastBootUpTime); " +
                  "Write-Output (''; '=== HARDWARE ==='); " +
                  "Write-Output ('Manufacturer: ' + $CS.Manufacturer); " +
                  "Write-Output ('Model: ' + $CS.Model); " +
                  "Write-Output ('Serial Number: ' + (Get-CimInstance Win32_BIOS).SerialNumber); " +
                  "Write-Output ('Processor: ' + $Processor.Name); " +
                  "Write-Output ('Cores: ' + $Processor.NumberOfCores); " +
                  "Write-Output ('Logical Processors: ' + $Processor.NumberOfLogicalProcessors); " +
                  "Write-Output ('Memory: ' + [math]::Round($OS.TotalVisibleMemorySize/1MB, 2) + ' GB'); " +
                  "Write-Output (''; '=== STORAGE ==='); " +
                  "foreach($drive in $Disk) { " +
                  "Write-Output ('Drive ' + $drive.DeviceID + ' - ' + [math]::Round($drive.Size/1GB, 2) + ' GB (Free: ' + [math]::Round($drive.FreeSpace/1GB, 2) + ' GB)') " +
                  "}; " +
                  "Write-Output (''; '=== NETWORK ==='); " +
                  "foreach($adapter in $Network) { " +
                  "Write-Output ('Adapter: ' + $adapter.Description); " +
                  "Write-Output ('  IP Address: ' + ($adapter.IPAddress[0])); " +
                  "Write-Output ('  MAC Address: ' + $adapter.MACAddress); " +
                  "Write-Output ('  Gateway: ' + ($adapter.DefaultIPGateway -join ', ')); " +
                  "}";
          }
          
          cmd += "\"";
        } else {
          // Fallback for Unix systems
          if (detail === "basic") {
            cmd = "uname -a && lscpu | grep 'Model name' && free -h | head -n 2";
          } else {
            cmd = "uname -a && lscpu && free -h && df -h && ip addr";
          }
        }
        
        const stdout = executeCommand(cmd);
        
        return {
          content: [
            {
              type: "text",
              text: stdout.toString(),
            },
          ],
        };
      } catch (error) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Error retrieving system info: ${error}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameter 'detail' which can be 'basic' or 'full' with default 'basic'.
      detail: z.enum(["basic", "full"]).default("basic").describe("Level of detail"),
    },
  • index.ts:103-188 (registration)
    Registration of the 'get_system_info' tool using McpServer.tool() method, specifying name, description, input schema, and handler function.
    server.tool(
      "get_system_info",
      "Retrieve system information including OS, hardware, and user details. Can provide basic or full details.",
      {
        detail: z.enum(["basic", "full"]).default("basic").describe("Level of detail"),
      },
      async ({ detail }) => {
        try {
          let cmd;
          
          if (isWindows) {
            cmd = "powershell.exe -Command \"";
            
            if (detail === "basic") {
              cmd += "$OS = Get-CimInstance Win32_OperatingSystem; " +
                    "$CS = Get-CimInstance Win32_ComputerSystem; " +
                    "$Processor = Get-CimInstance Win32_Processor; " +
                    "Write-Output 'OS: ' $OS.Caption $OS.Version; " +
                    "Write-Output 'Computer: ' $CS.Manufacturer $CS.Model; " +
                    "Write-Output 'CPU: ' $Processor.Name; " +
                    "Write-Output 'Memory: ' [math]::Round($OS.TotalVisibleMemorySize/1MB, 2) 'GB'";
            } else {
              cmd += "$OS = Get-CimInstance Win32_OperatingSystem; " +
                    "$CS = Get-CimInstance Win32_ComputerSystem; " +
                    "$Processor = Get-CimInstance Win32_Processor; " +
                    "$Disk = Get-CimInstance Win32_LogicalDisk -Filter 'DriveType=3'; " +
                    "$Network = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object {$_.IPAddress -ne $null}; " +
                    "Write-Output '=== OPERATING SYSTEM ==='; " +
                    "Write-Output ('OS: ' + $OS.Caption + ' ' + $OS.Version); " +
                    "Write-Output ('Architecture: ' + $OS.OSArchitecture); " +
                    "Write-Output ('Install Date: ' + $OS.InstallDate); " +
                    "Write-Output ('Last Boot: ' + $OS.LastBootUpTime); " +
                    "Write-Output (''; '=== HARDWARE ==='); " +
                    "Write-Output ('Manufacturer: ' + $CS.Manufacturer); " +
                    "Write-Output ('Model: ' + $CS.Model); " +
                    "Write-Output ('Serial Number: ' + (Get-CimInstance Win32_BIOS).SerialNumber); " +
                    "Write-Output ('Processor: ' + $Processor.Name); " +
                    "Write-Output ('Cores: ' + $Processor.NumberOfCores); " +
                    "Write-Output ('Logical Processors: ' + $Processor.NumberOfLogicalProcessors); " +
                    "Write-Output ('Memory: ' + [math]::Round($OS.TotalVisibleMemorySize/1MB, 2) + ' GB'); " +
                    "Write-Output (''; '=== STORAGE ==='); " +
                    "foreach($drive in $Disk) { " +
                    "Write-Output ('Drive ' + $drive.DeviceID + ' - ' + [math]::Round($drive.Size/1GB, 2) + ' GB (Free: ' + [math]::Round($drive.FreeSpace/1GB, 2) + ' GB)') " +
                    "}; " +
                    "Write-Output (''; '=== NETWORK ==='); " +
                    "foreach($adapter in $Network) { " +
                    "Write-Output ('Adapter: ' + $adapter.Description); " +
                    "Write-Output ('  IP Address: ' + ($adapter.IPAddress[0])); " +
                    "Write-Output ('  MAC Address: ' + $adapter.MACAddress); " +
                    "Write-Output ('  Gateway: ' + ($adapter.DefaultIPGateway -join ', ')); " +
                    "}";
            }
            
            cmd += "\"";
          } else {
            // Fallback for Unix systems
            if (detail === "basic") {
              cmd = "uname -a && lscpu | grep 'Model name' && free -h | head -n 2";
            } else {
              cmd = "uname -a && lscpu && free -h && df -h && ip addr";
            }
          }
          
          const stdout = executeCommand(cmd);
          
          return {
            content: [
              {
                type: "text",
                text: stdout.toString(),
              },
            ],
          };
        } catch (error) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: `Error retrieving system info: ${error}`,
              },
            ],
          };
        }
      }
    );
  • Shared helper function used by get_system_info (and other tools) to execute shell commands cross-platform, with Windows priority and fallbacks/warnings for others.
    function executeCommand(command: string, options: any = {}) {
      if (isWindows) {
        return execSync(command, options);
      } else {
        // Log warning for non-Windows environments
        console.error(`Warning: Running in a non-Windows environment (${platform()}). Windows commands may not work.`);
        
        // For testing purposes on non-Windows platforms
        try {
          // For Linux/MacOS, we'll strip cmd.exe and powershell.exe references
          let modifiedCmd = command;
          
          // Replace cmd.exe /c with empty string
          modifiedCmd = modifiedCmd.replace(/cmd\.exe\s+\/c\s+/i, '');
          
          // Replace powershell.exe -Command with empty string or a compatible command
          modifiedCmd = modifiedCmd.replace(/powershell\.exe\s+-Command\s+("|')/i, '');
          
          // Remove trailing quotes if we removed powershell -Command
          if (modifiedCmd !== command) {
            modifiedCmd = modifiedCmd.replace(/("|')$/, '');
          }
          
          console.error(`Attempting to execute modified command: ${modifiedCmd}`);
          return execSync(modifiedCmd, options);
        } catch (error) {
          console.error(`Error executing modified command: ${error}`);
          return Buffer.from(`This tool requires a Windows environment. Current platform: ${platform()}`);
        }
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool can 'provide basic or full details,' which adds some context about output granularity, but fails to address critical aspects such as whether this is a read-only operation, potential performance impacts, or authentication requirements, leaving significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and front-loaded, consisting of just two sentences that efficiently convey the core functionality and parameter options without any wasted words. Every sentence earns its place by adding relevant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is minimally adequate but incomplete. It covers the basic purpose and parameter hint, yet lacks details on behavioral traits, usage context, or output format, which are needed for a more comprehensive understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the parameter 'detail' fully documented in the input schema (including enum values and default). The description adds minimal value by mentioning 'basic or full details,' which aligns with the schema but doesn't provide additional semantic context beyond what's already structured.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('retrieve') and resources ('system information including OS, hardware, and user details'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'get_network_info' or 'get_service_info', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_network_info' or 'execute_command', nor does it mention any prerequisites or exclusions. It only hints at usage through the 'detail' parameter options, but this is insufficient for effective tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/alxspiker/Windows-Command-Line-MCP-Server'

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