get_site_health
Check the health status of a UniFi network site to monitor connectivity, device status, and overall network performance.
Instructions
Get health status for the current site
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/unifi_mcp/server.py:221-223 (handler)Handler logic inside call_tool that fetches site health data using UniFiClient and returns formatted TextContent.case "get_site_health": health = await client.get_site_health() return [TextContent(type="text", text=format_health(health))]
- src/unifi_mcp/server.py:112-120 (schema)Tool schema definition providing name, description, and input schema (no required properties).Tool( name="get_site_health", description="Get health status for the current site", inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
- src/unifi_mcp/server.py:148-149 (registration)Registration of the call_tool decorator which handles dispatching to get_site_health among other tools.@server.call_tool() async def call_tool(name: str, arguments: dict[str, Any]) -> list[TextContent]:
- UniFiClient helper method that performs the API request to retrieve raw site health data.async def get_site_health(self) -> list[dict[str, Any]]: """Get site health statistics. Returns: List of health metric dictionaries. """ return await self._request("GET", "/api/s/{site}/stat/health")
- src/unifi_mcp/server.py:326-356 (helper)Helper function to format the raw health data into a readable multi-line string with subsystem details.def format_health(health: list[dict[str, Any]]) -> str: """Format health data for display.""" if not health: return "No health data available." lines = ["Site Health Status:\n"] for subsystem in health: subsys_name = subsystem.get("subsystem", "Unknown") status = subsystem.get("status", "unknown") lines.append(f"- {subsys_name.upper()}") lines.append(f" Status: {status}") if subsys_name == "wan": gateways = subsystem.get("gw_mac", "N/A") lines.append(f" Gateway: {gateways}") elif subsys_name == "wlan": num_ap = subsystem.get("num_ap", 0) num_user = subsystem.get("num_user", 0) lines.append(f" Access Points: {num_ap}") lines.append(f" Wireless Clients: {num_user}") elif subsys_name == "lan": num_sw = subsystem.get("num_sw", 0) num_user = subsystem.get("num_user", 0) lines.append(f" Switches: {num_sw}") lines.append(f" Wired Clients: {num_user}") lines.append("") return "\n".join(lines)