get_devices_for_site
Retrieve all network devices associated with a specific UniFi site to monitor and manage your network infrastructure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/devices.js:39-44 (handler)The MCP tool handler function that invokes the UniFi client to fetch devices for a specific site and returns a formatted JSON response in the MCP content format.handler: async ({ hostId, siteId }) => { const devices = await unifi.getDevicesForSite(hostId, siteId); return { content: [{ type: 'text', text: JSON.stringify(devices, null, 2) }] }; }
- src/tools/devices.js:35-38 (schema)Zod input schema defining the required parameters: hostId and siteId as strings.schema: z.object({ hostId: z.string().describe('The host ID'), siteId: z.string().describe('The site ID') }),
- src/tools/devices.js:33-44 (registration)Registration of the get_devices_for_site tool within the deviceTools object exported from devices.js, which includes description, schema, and handler. This module is imported and registered to the MCP server.get_devices_for_site: { description: 'Get all devices for a specific site', schema: z.object({ hostId: z.string().describe('The host ID'), siteId: z.string().describe('The site ID') }), handler: async ({ hostId, siteId }) => { const devices = await unifi.getDevicesForSite(hostId, siteId); return { content: [{ type: 'text', text: JSON.stringify(devices, null, 2) }] }; }
- src/unifi-client.js:105-108 (helper)Core helper function in the UniFi client that performs the actual API request to retrieve devices for a given host and site.export async function getDevicesForSite(hostId, siteId) { const response = await cloudApi.get(`/v1/hosts/${hostId}/sites/${siteId}/devices`); return response.data; }