whm_disk_usage
Retrieve disk usage breakdown for a specific account on a WHM server. Input the account alias to view usage details.
Instructions
Get disk usage breakdown across all accounts on the server
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | Yes | Account alias from accounts.json (use list_accounts to see options) |
Implementation Reference
- src/tools.py:467-468 (handler)Handler for whm_disk_usage: calls WHM API 'getdiskusage' via GET request.
case "whm_disk_usage": return await _get(client, url("getdiskusage"), headers) - src/tools.py:171-179 (schema)Tool definition/schema for whm_disk_usage: describes input (account parameter) for getting disk usage breakdown across all accounts.
Tool( name="whm_disk_usage", description="Get disk usage breakdown across all accounts on the server", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), - src/server.py:34-44 (registration)Tools are registered in the list_tools handler which calls whm_tools() to collect all WHM tool definitions including whm_disk_usage.
@app.list_tools() async def list_tools() -> list[Tool]: all_tools = [] all_tools.append(Tool( name="list_accounts", description="List all configured WHM/cPanel server accounts available in this MCP", inputSchema={"type": "object", "properties": {}, "required": []} )) all_tools.extend(whm_tools()) all_tools.extend(cpanel_tools()) return all_tools - src/server.py:67-75 (registration)Routing: when tool name starts with 'whm_', handle_whm_tool is called, which handles whm_disk_usage in its match/case block.
async with httpx.AsyncClient(verify=False, timeout=30) as client: if name.startswith("whm_"): result = await handle_whm_tool(client, account, name, arguments) elif name.startswith("cpanel_"): result = await handle_cpanel_tool(client, account, name, arguments) else: result = {"error": f"Unknown tool: {name}"} return [TextContent(type="text", text=json.dumps(result, indent=2))] - src/tools.py:34-40 (helper)Helper _get function used by the handler to make the actual API call to WHM.
async def _get(client: httpx.AsyncClient, url: str, headers: dict, params: dict = None) -> dict: try: r = await client.get(url, headers=headers, params=params or {}) r.raise_for_status() return r.json() except Exception as e: return {"error": str(e)}