Skip to main content
Glama
nntkio

UniFi MCP Server

by nntkio

get_networks

Retrieve network configurations for a UniFi site to view settings, manage infrastructure, and monitor connected devices.

Instructions

Get all network configurations for the current site

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler logic for the 'get_networks' tool within the main call_tool dispatcher function. Fetches networks from UniFiClient and formats the output using format_networks.
    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 for 'get_networks' in the list_tools function.
    Tool(
        name="get_networks",
        description="Get all network configurations for the current site",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": [],
        },
    ),
  • Registration of all tools including 'get_networks' schema via @server.list_tools() decorator on list_tools function.
    @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"],
                },
            ),
        ]
  • Helper function to format the list of networks into a human-readable string for the tool output.
    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)
  • Core UniFiClient method that performs the API request to retrieve network configurations from the UniFi 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")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read-only operation, but doesn't specify details like pagination, rate limits, authentication needs, or what 'all network configurations' entails (e.g., format, scope). This leaves significant gaps in understanding how the tool behaves beyond its basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that efficiently conveys the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by specifying scope ('all', 'for the current site'), ensuring no waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and scope but lacks details on behavioral traits (e.g., response format, limitations) that would be helpful for an agent. Without annotations or output schema, more context on what 'network configurations' includes could improve completeness, but it meets the minimum for this low-complexity case.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description doesn't add param info, which is appropriate here. A baseline of 4 is applied as it adequately handles the lack of parameters without redundancy or omission.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('all network configurations for the current site'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'get_sites' or 'get_devices', but the scope ('network configurations') is specific enough to imply distinction. No tautology or misleading elements are present.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_sites' or 'get_devices', nor does it mention prerequisites or exclusions. It implies usage for retrieving network data in the current site context, but this is minimal and lacks explicit comparison to sibling tools, leaving the agent to infer appropriate contexts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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