Skip to main content
Glama
nntkio

UniFi MCP Server

by nntkio

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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))]
  • 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": [],
        },
    ),
  • 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")
  • 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)

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/nntkio/unifiMCP'

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