Skip to main content
Glama

cpanel_bandwidth_usage

Retrieve bandwidth usage statistics for a specific cPanel account. Provide the account alias and cPanel user to access the data.

Instructions

Get bandwidth usage stats for a specific cPanel account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountYesAccount alias from accounts.json (use list_accounts to see options)
cpanel_userYes

Implementation Reference

  • src/tools.py:400-411 (registration)
    Tool registration for 'cpanel_bandwidth_usage' with its name, description, and inputSchema. Requires 'account' (alias from accounts.json) and 'cpanel_user' (cPanel username).
    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"]
        }
    ),
  • Handler that executes the tool. Calls the cPanel UAPI StatsBar/get_stats module with 'display=bandwidthusage' to get bandwidth usage for the specified cPanel user.
    case "cpanel_bandwidth_usage":
        return await _get(client, url("StatsBar", "get_stats"), headers, {"display": "bandwidthusage"})
  • URL builder (_cpanel_url) that constructs the WHM-proxied cPanel UAPI endpoint used to call the StatsBar/get_stats API.
    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"
  • Generic async HTTP GET helper used to make the actual API request and parse JSON response.
    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:47-75 (registration)
    Top-level routing in call_tool that dispatches cpanel_* tools to handle_cpanel_tool, which includes the bandwidth usage tool.
    @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))]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and description fails to disclose behavioral traits such as auth requirements, scope of stats (e.g., monthly), or output format. Minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with purpose. Efficient, but lacks any structural elements like parameter notes or usage hints.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of many sibling tools and no output schema, the description is too minimal. Does not explain the relationship between 'account' and 'cpanel_user' or what bandwidth data is returned.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50%; only 'account' has a description. The description adds no extra meaning beyond the schema. For 'cpanel_user', no guidance is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Get bandwidth usage stats for a specific cPanel account'. Verb 'get' and resource 'bandwidth usage stats' are specific, and the context 'cPanel account' distinguishes from WHM-level sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'whm_bandwidth_usage' or 'cpanel_disk_usage'. Missing context about prerequisites or preferred scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/manofsadness/ItchWHMMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server