Skip to main content
Glama
nntkio

UniFi MCP Server

by nntkio

get_devices

Retrieve all network devices including access points, switches, and gateways from UniFi infrastructure for monitoring and management.

Instructions

Get all UniFi network devices (access points, switches, gateways)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Executes the get_devices tool by fetching devices from UniFiClient and formatting the output using format_devices.
    case "get_devices":
        devices = await client.get_devices()
        return [TextContent(type="text", text=format_devices(devices))]
  • Input/output schema definition for the get_devices tool (no input parameters required).
    Tool(
        name="get_devices",
        description="Get all UniFi network devices (access points, switches, gateways)",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": [],
        },
    ),
  • Registers the list_tools function which includes the get_devices tool in the MCP server.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
  • Helper function to format the list of devices into a human-readable string for the tool response.
    def format_devices(devices: list[dict[str, Any]]) -> str:
        """Format device list for display."""
        if not devices:
            return "No devices found."
    
        lines = [f"Found {len(devices)} device(s):\n"]
    
        for device in devices:
            name = device.get("name", "Unknown")
            mac = device.get("mac", "Unknown")
            model = device.get("model", "Unknown")
            device_type = device.get("type", "Unknown")
            state = device.get("state", 0)
            state_str = "Online" if state == 1 else "Offline"
            ip = device.get("ip", "N/A")
            version = device.get("version", "N/A")
    
            lines.append(f"- {name}")
            lines.append(f"  MAC: {mac}")
            lines.append(f"  Model: {model} ({device_type})")
            lines.append(f"  Status: {state_str}")
            lines.append(f"  IP: {ip}")
            lines.append(f"  Firmware: {version}")
            lines.append("")
    
        return "\n".join(lines)
  • UniFiClient method that retrieves the list of devices from the UniFi Controller API, called by the tool handler.
    async def get_devices(self) -> list[dict[str, Any]]:
        """Get all network devices.
    
        Returns:
            List of device dictionaries.
        """
        return await self._request("GET", "/api/s/{site}/stat/device")
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool retrieves devices but doesn't disclose behavioral traits such as whether it requires authentication, rate limits, pagination, error handling, or what the return format looks like (e.g., list of objects with fields). For a read operation with zero annotation coverage, 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, efficient sentence that front-loads the key information ('Get all UniFi network devices') and adds clarifying examples without redundancy. Every word earns its place, making it easy to parse quickly. There's no wasted verbiage or structural issues.

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 low complexity (0 parameters, no output schema, no annotations), the description is complete enough for basic understanding. It specifies the resource type and examples, which suffices for a simple read operation. However, without annotations or output schema, it lacks details on behavioral aspects like response format or operational constraints, leaving some contextual gaps for an agent to use it effectively.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, as there are none to explain. This meets the baseline for tools with no parameters, where the description focuses on purpose rather than inputs.

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 verb ('Get') and resource ('all UniFi network devices') with specific examples (access points, switches, gateways). It distinguishes the tool's scope from siblings like get_clients (which gets clients) or get_networks (which gets networks), but doesn't explicitly contrast them. The purpose is unambiguous but lacks explicit sibling differentiation.

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

Usage Guidelines3/5

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

The description implies usage context by specifying 'all UniFi network devices', suggesting it's for retrieving device inventory rather than client or network data. However, it doesn't provide explicit guidance on when to use this versus alternatives like get_device_activity (for activity logs) or restart_device (for device management), nor does it mention prerequisites or exclusions. Usage is contextually implied but not clearly articulated.

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