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)MCP tool handler dispatch for get_site_health: calls UniFiClient.get_site_health() and formats the response using format_health.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 including name, description, and empty input schema (no parameters required).Tool( name="get_site_health", description="Get health status for the current site", inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
- UniFiClient method that performs the actual API request to retrieve site health data from the controller.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-357 (helper)Formats raw health data from UniFi API into human-readable text, categorizing by subsystems like WAN, WLAN, LAN.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)