cpanel_mysql_list
List MySQL databases and users for a specified cPanel account.
Instructions
List MySQL databases and users 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:340-351 (registration)Tool definition/registration for cpanel_mysql_list as a Tool object with name, description, and inputSchema requiring 'account' and 'cpanel_user' parameters.
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"] } ), - src/tools.py:543-546 (handler)Handler for cpanel_mysql_list: calls cPanel UAPI Mysql::list_databases and Mysql::list_users via WHM-proxied API and returns combined result.
case "cpanel_mysql_list": dbs = await _get(client, url("Mysql", "list_databases"), headers) users = await _get(client, url("Mysql", "list_users"), headers) return {"databases": dbs, "users": users} - src/tools.py:17-22 (helper)Helper function _cpanel_url builds the WHM-proxied cPanel UAPI URL used by the handler to call Mysql::list_databases and Mysql::list_users.
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-40 (helper)Helper function _get used by the handler to perform async HTTP GET requests to the WHM/cPanel 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/server.py:34-44 (registration)Server registration: cpanel_tools() (which includes cpanel_mysql_list) is registered via list_tools() and dispatched via call_tool() which routes 'cpanel_' prefixed tools to handle_cpanel_tool.
@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