list_accounts
Retrieve a list of all configured WHM/cPanel server accounts available in this MCP.
Instructions
List all configured WHM/cPanel server accounts available in this MCP
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.py:34-44 (registration)The 'list_accounts' tool is registered as an MCP tool in the list_tools() handler. It is defined with no required input parameters.
@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 - src/server.py:47-57 (handler)The 'list_accounts' tool handler directly inlines its logic in the call_tool() function (lines 51-57). It loads accounts via load_accounts() and returns a JSON list of aliases, hosts, and types.
@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))] - src/accounts.py:17-46 (helper)The load_accounts() helper function loads accounts from accounts.json or falls back to environment variables. This is the backing data source for the list_accounts tool.
def load_accounts() -> dict: global _ACCOUNTS if _ACCOUNTS is not None: return _ACCOUNTS # Try accounts.json first if CONFIG_PATH.exists(): with open(CONFIG_PATH) as f: _ACCOUNTS = json.load(f) return _ACCOUNTS # Fall back to environment variables (single account) host = os.environ.get("WHM_HOST") user = os.environ.get("WHM_USER", "root") token = os.environ.get("WHM_TOKEN") if host and token: _ACCOUNTS = { "default": { "host": host, "user": user, "token": token, "type": "whm", "port": int(os.environ.get("WHM_PORT", "2087")) } } else: _ACCOUNTS = {} return _ACCOUNTS