get_disk_usage
Check disk space usage in WSL environments to monitor storage capacity and identify potential space constraints.
Instructions
Get disk space information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Path to check |
Implementation Reference
- src/index.ts:248-271 (handler)Handler function that executes the 'df -h' command to get disk usage, optionally for a specific path, formats the output, and handles errors.async ({ path }) => { try { const cmd = path ? `df -h "${path}"` : 'df -h'; const result = await this.command_executor.execute_command(cmd); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } },
- src/index.ts:236-243 (schema)Input schema for the get_disk_usage tool, defining an optional 'path' parameter.schema: v.object({ path: v.optional( v.pipe( v.string(), v.description('Path to check'), ), ), }),
- src/index.ts:232-272 (registration)Registration of the 'get_disk_usage' tool using this.server.tool, including name, description, schema, annotations, and inline handler.this.server.tool( { name: 'get_disk_usage', description: 'Get disk space information', schema: v.object({ path: v.optional( v.pipe( v.string(), v.description('Path to check'), ), ), }), annotations: { readOnlyHint: true, }, }, async ({ path }) => { try { const cmd = path ? `df -h "${path}"` : 'df -h'; const result = await this.command_executor.execute_command(cmd); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, );