Skip to main content
Glama
nntkio

UniFi MCP Server

by nntkio

get_sites

Retrieve all configured UniFi network sites from the controller to manage and monitor network infrastructure.

Instructions

Get all UniFi sites configured on the controller

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler logic within the call_tool function that executes the get_sites tool by fetching sites from the UniFiClient and returning formatted TextContent.
    case "get_sites": sites = await client.get_sites() return [TextContent(type="text", text=format_sites(sites))]
  • Schema definition for the get_sites tool, specifying an empty input object schema (no parameters required).
    Tool( name="get_sites", description="Get all UniFi sites configured on the controller", inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
  • Registration of the get_sites tool in the list_tools() function, including name, description, and schema.
    Tool( name="get_sites", description="Get all UniFi sites configured on the controller", inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
  • Helper function to format the list of sites into a human-readable string for display.
    def format_sites(sites: list[dict[str, Any]]) -> str: """Format site list for display.""" if not sites: return "No sites found." lines = [f"Found {len(sites)} site(s):\n"] for site in sites: name = site.get("name", "Unknown") desc = site.get("desc", name) site_id = site.get("_id", "N/A") lines.append(f"- {desc}") lines.append(f" Name: {name}") lines.append(f" ID: {site_id}") lines.append("") return "\n".join(lines)
  • UniFiClient method that implements the API call to retrieve sites from the UniFi controller.
    async def get_sites(self) -> list[dict[str, Any]]: """Get all sites. Returns: List of site dictionaries. """ return await self._request("GET", "/api/self/sites")

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