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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/unifi_mcp/server.py:217-219 (handler)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))]
- src/unifi_mcp/server.py:103-111 (schema)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": [], }, ),
- src/unifi_mcp/server.py:103-111 (registration)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": [], }, ),
- src/unifi_mcp/server.py:306-323 (helper)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")