Skip to main content
Glama
nntkio

UniFi MCP Server

by nntkio

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

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

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