cpanel_subdomains_list
Retrieve a complete list of subdomains and addon domains for a cPanel account.
Instructions
List all subdomains and addon domains for a cPanel account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | Yes | Account alias from accounts.json (use list_accounts to see options) | |
| cpanel_user | Yes |
Implementation Reference
- src/tools.py:388-399 (registration)Tool registration/definition for 'cpanel_subdomains_list' inside the cpanel_tools() function. Defines name, description, and inputSchema (requires account and cpanel_user).
Tool( name="cpanel_subdomains_list", description="List all subdomains and addon domains for a cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"} }, "required": ["account", "cpanel_user"] } ), - src/tools.py:557-560 (handler)Handler for 'cpanel_subdomains_list' inside handle_cpanel_tool(). Calls UAPI SubDomain::list_subdomains and AddonDomain::list_addon_domains via _get helper and returns combined result.
case "cpanel_subdomains_list": subs = await _get(client, url("SubDomain", "list_subdomains"), headers) addons = await _get(client, url("AddonDomain", "list_addon_domains"), headers) return {"subdomains": subs, "addon_domains": addons} - src/tools.py:17-22 (helper)Helper _cpanel_url() constructs the WHM-proxied UAPI URL for cPanel operations, used by the handler to build API endpoints.
def _cpanel_url(account: dict, module: str, function: str, cpanel_user: str = None) -> str: host = account["host"] port = account.get("port", 2087) # WHM-proxied UAPI call on behalf of a cPanel user user = cpanel_user or account.get("cpanel_user", "") return f"https://{host}:{port}/json-api/cpanel?api.version=1&cpanel_jsonapi_user={user}&cpanel_jsonapi_module={module}&cpanel_jsonapi_func={function}&cpanel_jsonapi_apiversion=3" - src/tools.py:34-41 (helper)Helper _get() is an async HTTP GET wrapper used by the handler to call WHM/cPanel APIs.
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/server.py:67-71 (registration)Dispatch to handle_cpanel_tool when tool name starts with 'cpanel_', as seen in the call_tool() function.
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)