get_sites
Retrieve all configured UniFi sites from the controller to manage network infrastructure, monitor devices, and perform configuration tasks.
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 central call_tool function that executes the get_sites tool: calls UniFiClient.get_sites() and formats the result using format_sites.case "get_sites": sites = await client.get_sites() return [TextContent(type="text", text=format_sites(sites))]
- src/unifi_mcp/server.py:103-110 (schema)Input schema definition for the get_sites tool: no required parameters.Tool( name="get_sites", description="Get all UniFi sites configured on the controller", inputSchema={ "type": "object", "properties": {}, "required": [], },
- src/unifi_mcp/server.py:16-17 (registration)Registration of tools list including get_sites via @server.list_tools() decorator.@server.list_tools() async def list_tools() -> list[Tool]:
- UniFiClient helper method that performs the actual API request to fetch sites from the 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")
- src/unifi_mcp/server.py:306-323 (helper)Helper function to format the list of sites into a human-readable string.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)