whm_suspend_account
Suspend a cPanel account to disable login, web, and email services by specifying the account and username along with a reason.
Instructions
Suspend a cPanel account (disables login, web, email)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | Yes | Account alias from accounts.json (use list_accounts to see options) | |
| username | Yes | ||
| reason | No | Reason for suspension |
Implementation Reference
- src/tools.py:111-123 (registration)Tool registration for 'whm_suspend_account' as an MCP Tool object with input schema requiring 'account' and 'username', with optional 'reason'.
Tool( name="whm_suspend_account", description="Suspend a cPanel account (disables login, web, email)", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string"}, "reason": {"type": "string", "description": "Reason for suspension"} }, "required": ["account", "username"] } ), - src/tools.py:444-448 (handler)Handler for 'whm_suspend_account' in the handle_whm_tool match statement. Builds params with username and optional reason, then calls WHM JSON API 'suspendacct' via GET.
case "whm_suspend_account": params = {"user": args["username"]} if "reason" in args: params["reason"] = args["reason"] return await _get(client, url("suspendacct"), headers, params) - src/tools.py:10-14 (helper)Helper _whm_url builds the WHM API URL (https://host:port/json-api/function?api.version=1).
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:25-31 (helper)Helper _headers builds the Authorization header using WHM token.
def _headers(account: dict) -> dict: token = account["token"] user = account.get("user", "root") return { "Authorization": f"whm {user}:{token}", "Content-Type": "application/json" } - src/tools.py:34-40 (helper)Helper _get performs the async HTTP GET request, returning JSON or an error dict.
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)}