cpanel_email_create
Create a new email account for a cPanel user by specifying email address, password, and mailbox quota.
Instructions
Create a new email account for a cPanel user
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | Yes | Account alias from accounts.json (use list_accounts to see options) | |
| cpanel_user | Yes | ||
| Yes | Full email address | ||
| password | Yes | ||
| quota | No | Mailbox quota in MB (0 = unlimited) |
Implementation Reference
- src/tools.py:299-313 (schema)Input schema definition for cpanel_email_create tool, specifying required params: account, cpanel_user, email, password, and optional quota.
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"] } ), - src/tools.py:528-535 (handler)Handler for cpanel_email_create: splits email into local part and domain, then calls UAPI Email::add_pop to create the email account with password and quota.
case "cpanel_email_create": email_parts = args["email"].split("@") return await _get(client, url("Email", "add_pop"), headers, { "email": email_parts[0], "domain": email_parts[1] if len(email_parts) > 1 else "", "password": args["password"], "quota": args.get("quota", 0) }) - src/server.py:47-75 (registration)The cpanel_email_create tool is dispatched via handle_cpanel_tool when a tool name starting with 'cpanel_' is called, as registered in the MCP server's call_tool handler.
@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/server.py:43-43 (registration)cpanel_tools() (which includes cpanel_email_create) is registered into the MCP server's tool list via list_tools().
all_tools.extend(cpanel_tools()) - src/tools.py:17-22 (helper)Helper that builds the WHM-proxied UAPI URL for cPanel operations like Email::add_pop used by cpanel_email_create.
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"