getDiskUsage
Check current disk space usage on your system to monitor storage capacity and prevent data loss from insufficient space.
Instructions
获取当前平台的硬盘使用率
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:368-384 (handler)The core handler implementation for the 'getDiskUsage' tool. It checks the platform (macOS vs others) and executes the appropriate 'df' command via execSync to retrieve disk usage information, then returns it as text content in the MCP response format.case "getDiskUsage": { let diskUsage; if (os.platform() === 'darwin') { // macOS 使用 df -h 命令 diskUsage = execSync('df -h').toString(); } else { // 其他平台使用 df -h --output=used,size,pcent 命令 diskUsage = execSync('df -h --output=used,size,pcent').toString(); } return { content: [{ type: "text", text: diskUsage }] }; }
- src/index.ts:82-90 (schema)The tool schema definition for 'getDiskUsage', registered in the listTools response. Includes the tool name, description in Chinese ('Get current platform's disk usage rate'), and an empty input schema (no parameters required).{ name: "getDiskUsage", description: "获取当前平台的硬盘使用率", inputSchema: { type: "object", properties: {}, required: [] } },
- src/index.ts:787-787 (registration)Registration of the listTools handler function, which returns the list of tools including 'getDiskUsage' schema.server.setRequestHandler(ListToolsRequestSchema, handleRequest);
- src/index.ts:790-790 (registration)Registration of the callTool handler function, which contains the switch case dispatching to the 'getDiskUsage' implementation.server.setRequestHandler(CallToolRequestSchema, handleCallToolRequest);