whm_change_password
Change the password for a cPanel account by supplying account alias, username, and new password.
Instructions
Change password for a cPanel account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | Yes | Account alias from accounts.json (use list_accounts to see options) | |
| username | Yes | ||
| password | Yes |
Implementation Reference
- src/tools.py:136-148 (schema)Tool definition and input schema for whm_change_password. Registers the tool with name 'whm_change_password', description 'Change password for a cPanel account', and requires 'account', 'username', and 'password' fields.
Tool( name="whm_change_password", description="Change password for a cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string"}, "password": {"type": "string"} }, "required": ["account", "username", "password"] } ), - src/tools.py:453-457 (handler)Handler case for whm_change_password. Calls the WHM JSON API 'passwd' function with the username and password from arguments via HTTP GET.
case "whm_change_password": return await _get(client, url("passwd"), headers, { "user": args["username"], "password": args["password"] }) - src/tools.py:63-412 (registration)The whm_tools() function is called by server.py during list_tools() to register this tool. The whm_change_password tool is part of the WHM tool list returned by this function.
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"] } ), Tool( name="whm_create_account", description="Create a new cPanel hosting account on the WHM server", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string"}, "domain": {"type": "string"}, "password": {"type": "string"}, "email": {"type": "string"}, "plan": {"type": "string", "description": "Hosting plan name (optional)"} }, "required": ["account", "username", "domain", "password", "email"] } ), 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"] } ), Tool( name="whm_unsuspend_account", description="Unsuspend/reactivate a suspended cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string"} }, "required": ["account", "username"] } ), Tool( name="whm_change_password", description="Change password for a cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string"}, "password": {"type": "string"} }, "required": ["account", "username", "password"] } ), Tool( name="whm_terminate_account", description="⚠️ PERMANENTLY DELETE a cPanel account and all its data", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string"}, "confirm": {"type": "boolean", "description": "Must be true to confirm deletion"} }, "required": ["account", "username", "confirm"] } ), Tool( name="whm_server_load", description="Get real-time server load averages, memory usage, CPU, swap", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_disk_usage", description="Get disk usage breakdown across all accounts on the server", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_list_packages", description="List all hosting packages/plans configured on the WHM server", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_list_ips", description="List all IP addresses on the server and their assignments", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_dns_list_zones", description="List all DNS zones managed by this WHM server", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_dns_zone_records", description="Get all DNS records for a specific zone/domain", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "domain": {"type": "string", "description": "Domain name to query"} }, "required": ["account", "domain"] } ), Tool( name="whm_mysql_list_dbs", description="List all MySQL databases on the server across all accounts", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_bandwidth_usage", description="Get bandwidth usage statistics for all accounts or a specific account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "username": {"type": "string", "description": "Filter by cPanel username (optional)"} }, "required": ["account"] } ), Tool( name="whm_list_services", description="Check status of all WHM services (Apache, MySQL, cPanel, SMTP, etc.)", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_restart_service", description="Restart a specific service on the WHM server (apache, mysql, exim, etc.)", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "service": {"type": "string", "description": "Service name: apache, mysql, exim, ftp, cpsrvd"} }, "required": ["account", "service"] } ), Tool( name="whm_ssl_list", description="List all SSL certificates installed on the server", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), Tool( name="whm_backup_list", description="List available backups on the WHM server", inputSchema={ "type": "object", "properties": ACCOUNT_PARAM, "required": ["account"] } ), ] # ─── cPanel Tool Definitions (account-level) ────────────────────────────────── def cpanel_tools() -> list[Tool]: return [ Tool( name="cpanel_email_list", description="List all email accounts for a cPanel user's domain", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string", "description": "cPanel username"}, "domain": {"type": "string", "description": "Domain to list emails for"} }, "required": ["account", "cpanel_user", "domain"] } ), Tool( name="cpanel_email_create", description="Create a new email account for a cPanel user", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"}, "email": {"type": "string", "description": "Full email address"}, "password": {"type": "string"}, "quota": {"type": "integer", "description": "Mailbox quota in MB (0 = unlimited)"} }, "required": ["account", "cpanel_user", "email", "password"] } ), Tool( name="cpanel_forwarders_list", description="List all email forwarders for a cPanel user's domain", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"}, "domain": {"type": "string"} }, "required": ["account", "cpanel_user", "domain"] } ), Tool( name="cpanel_dns_records", description="Get DNS zone records for a domain via cPanel UAPI", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"}, "domain": {"type": "string"} }, "required": ["account", "cpanel_user", "domain"] } ), Tool( name="cpanel_mysql_list", description="List MySQL databases and users for a cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"} }, "required": ["account", "cpanel_user"] } ), Tool( name="cpanel_disk_usage", description="Get disk usage breakdown for a specific cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"} }, "required": ["account", "cpanel_user"] } ), Tool( name="cpanel_ssl_check", description="Check SSL certificate status and expiry for a cPanel account's domains", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"} }, "required": ["account", "cpanel_user"] } ), Tool( name="cpanel_cron_list", description="List all cron jobs configured for a cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"} }, "required": ["account", "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"] } ), Tool( name="cpanel_bandwidth_usage", description="Get bandwidth usage stats for a specific cPanel account", inputSchema={ "type": "object", "properties": { **ACCOUNT_PARAM, "cpanel_user": {"type": "string"} }, "required": ["account", "cpanel_user"] } ), ] - src/server.py:47-75 (registration)The call_tool handler in server.py dispatches tool names starting with 'whm_' to handle_whm_tool, which contains the whm_change_password case.
@app.call_tool() async def call_tool(name: str, arguments: dict[str, Any]) -> list[TextContent]: log.info(f"Tool called: {name} | Args: {json.dumps(arguments)}") if name == "list_accounts": accounts = load_accounts() result = [ {"alias": a, "host": cfg["host"], "type": cfg.get("type","whm")} for a, cfg in accounts.items() ] return [TextContent(type="text", text=json.dumps(result, indent=2))] account_alias = arguments.get("account") if not account_alias: return [TextContent(type="text", text="ERROR: 'account' parameter is required. Use list_accounts to see available accounts.")] account = get_account(account_alias) if not account: return [TextContent(type="text", text=f"ERROR: Account '{account_alias}' not found. Use list_accounts to see configured accounts.")] 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:10-14 (helper)The _whm_url helper constructs the WHM API URL. For whm_change_password, it builds the URL to the 'passwd' API endpoint with 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"