list-devices
List all network devices including switches, access points, gateways, and cameras. Filter by host or device type, and project specific fields to reduce response size.
Instructions
List all devices across hosts (switches, APs, gateways, cameras)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostId | No | Filter by host ID | |
| type | No | Filter by device type (e.g., 'uap', 'usw', 'ugw') | |
| extractFields | No | Comma-separated dotted paths to project from response (e.g. 'id,name,owner.name,columns.*.name'). Use `*` as wildcard for arrays/objects. Wrap field names with dots in backticks. Reduces response tokens dramatically on large entities. |
Implementation Reference
- src/tools/devices.ts:14-25 (handler)The main handler function for list-devices. It builds query params from hostId/type filters, calls GET /devices on the UniFi client, and optionally extracts fields or returns the full response data.
export async function listDevices(params: z.infer<typeof listDevicesSchema>) { const queryParams: Record<string, string | undefined> = {}; if (params.hostId) queryParams.hostId = params.hostId; if (params.type) queryParams.type = params.type; const response = await unifiClient.get<{ data: unknown[] }>("/devices", queryParams); if (params.extractFields) return response.data; return applyExtractFields( response.data, "*.hostId,*.hostName,*.devices.*.id,*.devices.*.name,*.devices.*.model,*.devices.*.status,*.devices.*.version", ); } - src/tools/devices.ts:8-12 (schema)Zod schema for list-devices input validation. Accepts optional hostId (filter by host), type (filter by device type e.g. 'uap', 'usw', 'ugw'), and extractFields.
export const listDevicesSchema = z.object({ hostId: z.string().optional().describe("Filter by host ID"), type: z.string().optional().describe("Filter by device type (e.g., 'uap', 'usw', 'ugw')"), extractFields: ef, }); - src/index.ts:121-123 (registration)Registration of the 'list-devices' tool with its description, schema, and handler wrapped via wrapToolHandler.
tool("list-devices", "List all devices across hosts (switches, APs, gateways, cameras)", listDevicesSchema.shape, wrapToolHandler(listDevices)); - src/index.ts:23-23 (registration)Import of listDevicesSchema and listDevices from './tools/devices.js' into the main entry point.
import { listDevicesSchema, listDevices } from "./tools/devices.js";