Skip to main content
Glama
nntkio

UniFi MCP Server

by nntkio

get_networks

Retrieve all network configurations for the current UniFi site to manage network settings and monitor infrastructure.

Instructions

Get all network configurations for the current site

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler logic within the call_tool function that executes get_networks by fetching data from UniFiClient and formatting it for output.
    case "get_networks": networks = await client.get_networks() return [TextContent(type="text", text=format_networks(networks))]
  • Tool schema definition including name, description, and empty input schema (no parameters required).
    Tool( name="get_networks", description="Get all network configurations for the current site", inputSchema={ "type": "object", "properties": {}, "required": [], }, ), # Activity tools
  • Registration of all tools including get_networks via the list_tools decorator, which returns the list of Tool objects.
    @server.list_tools() async def list_tools() -> list[Tool]: """List all available UniFi MCP tools.""" return [ # Device tools Tool( name="get_devices", description="Get all UniFi network devices (access points, switches, gateways)", inputSchema={ "type": "object", "properties": {}, "required": [], }, ), Tool( name="restart_device", description="Restart a UniFi network device by its MAC address", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the device to restart (e.g., '00:11:22:33:44:55')", } }, "required": ["mac"], }, ), # Client tools Tool( name="get_clients", description="Get all currently connected clients on the UniFi network", inputSchema={ "type": "object", "properties": { "include_offline": { "type": "boolean", "description": "Include offline/historical clients", "default": False, } }, "required": [], }, ), Tool( name="block_client", description="Block a client from accessing the network", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the client to block", } }, "required": ["mac"], }, ), Tool( name="unblock_client", description="Unblock a previously blocked client", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the client to unblock", } }, "required": ["mac"], }, ), Tool( name="disconnect_client", description="Force disconnect a client from the network", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the client to disconnect", } }, "required": ["mac"], }, ), # Site tools Tool( name="get_sites", description="Get all UniFi sites configured on the controller", inputSchema={ "type": "object", "properties": {}, "required": [], }, ), Tool( name="get_site_health", description="Get health status for the current site", inputSchema={ "type": "object", "properties": {}, "required": [], }, ), Tool( name="get_networks", description="Get all network configurations for the current site", inputSchema={ "type": "object", "properties": {}, "required": [], }, ), # Activity tools Tool( name="get_device_activity", description="Get activity for a specific device including connected clients and their traffic", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the device (AP or switch)", } }, "required": ["mac"], }, ), ]
  • UniFiClient method that performs the actual API request to retrieve network configurations from the controller.
    async def get_networks(self) -> list[dict[str, Any]]: """Get all network configurations. Returns: List of network configuration dictionaries. """ return await self._request("GET", "/api/s/{site}/rest/networkconf")
  • Helper function to format the list of networks into a human-readable string.
    def format_networks(networks: list[dict[str, Any]]) -> str: """Format network list for display.""" if not networks: return "No networks configured." lines = [f"Found {len(networks)} network(s):\n"] for net in networks: name = net.get("name", "Unknown") purpose = net.get("purpose", "unknown") vlan = net.get("vlan", "N/A") subnet = net.get("ip_subnet", "N/A") enabled = net.get("enabled", True) status = "Enabled" if enabled else "Disabled" lines.append(f"- {name}") lines.append(f" Purpose: {purpose}") lines.append(f" VLAN: {vlan}") lines.append(f" Subnet: {subnet}") lines.append(f" Status: {status}") 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