get_disk_info
Retrieve disk information on Windows systems to monitor storage capacity, usage, and drive details for system management.
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": "get_disk_info"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/powershell.js:156-183 (handler)The handler function that runs a PowerShell command to retrieve disk information (drives, total/used/free GB, percent used) and parses the JSON output.
async getDiskInfo() { try { const command = ` Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Used -ne $null } | ForEach-Object { @{ Drive = $_.Name TotalGB = [math]::Round($_.Used / 1GB + $_.Free / 1GB, 2) UsedGB = [math]::Round($_.Used / 1GB, 2) FreeGB = [math]::Round($_.Free / 1GB, 2) PercentUsed = [math]::Round(($_.Used / ($_.Used + $_.Free)) * 100, 2) } } | ConvertTo-Json `; const { stdout } = await execAsync(`powershell -Command "${command.replace(/"/g, '\\"')}"`, { shell: 'powershell.exe' }); let disks = JSON.parse(stdout); if (!Array.isArray(disks)) { disks = [disks]; } return { success: true, disks }; } catch (error) { return { success: false, error: error.message }; } } - src/tools/powershell.js:44-51 (registration)Tool registration in getToolDefinitions(): defines name, description, and empty input schema for get_disk_info.
{ name: 'get_disk_info', description: '获取磁盘信息', inputSchema: { type: 'object', properties: {}, }, }, - src/tools/powershell.js:77-78 (registration)In executeTool switch statement: dispatches 'get_disk_info' calls to the getDiskInfo() handler method.
case 'get_disk_info': return await this.getDiskInfo(); - src/tools/powershell.js:64-66 (registration)In canHandle(): includes 'get_disk_info' in the list of supported tools.
const tools = ['run_powershell', 'run_cmd', 'get_system_info', 'get_disk_info', 'get_network_info']; return tools.includes(toolName); - src/tools/powershell.js:47-50 (schema)Input schema definition: object with no properties (no input parameters required).
inputSchema: { type: 'object', properties: {}, },