whm_account_summary
Retrieve disk, bandwidth, email, and database details for a specific cPanel account to assess resource usage.
Instructions
Get detailed summary for a specific cPanel account (disk, bandwidth, emails, DBs)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | Yes | Account alias from accounts.json (use list_accounts to see options) | |
| username | Yes | cPanel username to inspect |
Implementation Reference
- src/tools.py:63-94 (registration)Registration of whm_account_summary tool in the whm_tools() function. Defines name, description, and inputSchema requiring 'account' and 'username' (cPanel username).
def whm_tools() -> list[Tool]: return [ Tool( name="whm_server_info", description="Get WHM server information: hostname, OS, cPanel version, load, uptime", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_list_accounts", description="List all cPanel accounts on this WHM server with disk usage, domain, status", inputSchema={ "type": "object", "properties": {**ACCOUNT_PARAM}, "required": ["account"] } ), Tool( name="whm_account_summary", description="Get detailed summary for a specific cPanel account (disk, bandwidth, emails, DBs)", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string", "description": "cPanel username to inspect"} }, "required": ["account", "username"] } ), - src/tools.py:430-431 (handler)Handler for whm_account_summary inside handle_whm_tool(). Calls WHM JSON API 'accountsummary' with the 'username' argument passed as 'user' query parameter.
case "whm_account_summary": return await _get(client, url("accountsummary"), headers, {"user": args["username"]}) - src/tools.py:10-14 (helper)Helper _whm_url() constructs the WHM JSON API URL used by the handler to call the 'accountsummary' endpoint.
def _whm_url(account: dict, function: str) -> str: host = account["host"] port = account.get("port", 2087) user = account.get("user", "root") return f"https://{host}:{port}/json-api/{function}?api.version=1" - src/tools.py:34-40 (helper)Helper _get() performs the async HTTP GET request that the handler uses to fetch data from the WHM API.
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)} - src/tools.py:25-31 (helper)Helper _headers() constructs the Authorization header with the WHM token, used by the handler.
def _headers(account: dict) -> dict: token = account["token"] user = account.get("user", "root") return { "Authorization": f"whm {user}:{token}", "Content-Type": "application/json" }