get_system_info
Retrieve detailed system information from Windows environments using PowerShell commands. This tool enables efficient management and monitoring of system configurations, hardware, and software details.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:79-138 (handler)Inline handler for the 'get_system_info' tool. Executes a PowerShell command to gather system information (computer name, OS details, processor, memory, PowerShell version) using Get-ComputerInfo and $PSVersionTable, formats as JSON, and returns as text content or error.// Get system information this.server.tool('get_system_info', {}, async () => { try { const command = ` $ComputerInfo = Get-ComputerInfo $PSVersion = $PSVersionTable $EnvVars = Get-ChildItem Env: | Sort-Object Name $Output = [PSCustomObject]@{ ComputerName = $ComputerInfo.CsName OSName = $ComputerInfo.WindowsProductName OSVersion = $ComputerInfo.OsVersion OSBuild = $ComputerInfo.OsBuildNumber ProcessorName = $ComputerInfo.CsProcessors.Name TotalMemory = "$([math]::Round($ComputerInfo.CsTotalPhysicalMemory / 1GB, 2)) GB" PSVersion = "$($PSVersion.PSVersion)" PSEdition = "$($PSVersion.PSEdition)" PSBuildVersion = "$($PSVersion.BuildVersion)" CLRVersion = "$($PSVersion.CLRVersion)" } ConvertTo-Json -InputObject $Output -Depth 3 `; const { stdout, stderr } = await execAsync( `powershell -Command "${command.replace(/"/g, '\\"')}"` ); if (stderr) { return { isError: true, content: [ { type: 'text' as const, text: `Error retrieving system information: ${stderr}`, }, ], }; } return { content: [ { type: 'text' as const, text: stdout, }, ], }; } catch (error) { return { isError: true, content: [ { type: 'text' as const, text: `Error retrieving system information: ${(error as Error).message}`, }, ], }; } });
- src/index.ts:80-138 (registration)Registers the 'get_system_info' tool with the MCP server using this.server.tool, providing an empty input schema {} and the inline async handler function.this.server.tool('get_system_info', {}, async () => { try { const command = ` $ComputerInfo = Get-ComputerInfo $PSVersion = $PSVersionTable $EnvVars = Get-ChildItem Env: | Sort-Object Name $Output = [PSCustomObject]@{ ComputerName = $ComputerInfo.CsName OSName = $ComputerInfo.WindowsProductName OSVersion = $ComputerInfo.OsVersion OSBuild = $ComputerInfo.OsBuildNumber ProcessorName = $ComputerInfo.CsProcessors.Name TotalMemory = "$([math]::Round($ComputerInfo.CsTotalPhysicalMemory / 1GB, 2)) GB" PSVersion = "$($PSVersion.PSVersion)" PSEdition = "$($PSVersion.PSEdition)" PSBuildVersion = "$($PSVersion.BuildVersion)" CLRVersion = "$($PSVersion.CLRVersion)" } ConvertTo-Json -InputObject $Output -Depth 3 `; const { stdout, stderr } = await execAsync( `powershell -Command "${command.replace(/"/g, '\\"')}"` ); if (stderr) { return { isError: true, content: [ { type: 'text' as const, text: `Error retrieving system information: ${stderr}`, }, ], }; } return { content: [ { type: 'text' as const, text: stdout, }, ], }; } catch (error) { return { isError: true, content: [ { type: 'text' as const, text: `Error retrieving system information: ${(error as Error).message}`, }, ], }; } });
- src/index.ts:7-7 (helper)Helper function promisify(exec) used by the handler to asynchronously execute the PowerShell command.const execAsync = promisify(exec);
- src/index.ts:80-80 (schema)Empty input schema for the 'get_system_info' tool (no parameters required).this.server.tool('get_system_info', {}, async () => {