Skip to main content
Glama
vandreus

UniFi MCP Server

by vandreus

get_devices_for_host

Retrieve all network devices connected to a specific host in UniFi infrastructure for monitoring and management purposes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of getDevicesForHost that fetches devices via UniFi Cloud API
    export async function getDevicesForHost(hostId) { const response = await cloudApi.get(`/v1/hosts/${hostId}/devices`); return response.data; }
  • MCP tool handler wrapper that invokes the core function and formats the MCP response
    handler: async ({ hostId }) => { const devices = await unifi.getDevicesForHost(hostId); return { content: [{ type: 'text', text: JSON.stringify(devices, null, 2) }] }; }
  • Input schema using Zod for validating hostId parameter
    schema: z.object({ hostId: z.string().describe('The host ID') }),
  • Tool definition and registration within deviceTools object
    get_devices_for_host: { description: 'Get all devices for a specific host', schema: z.object({ hostId: z.string().describe('The host ID') }), handler: async ({ hostId }) => { const devices = await unifi.getDevicesForHost(hostId); return { content: [{ type: 'text', text: JSON.stringify(devices, null, 2) }] }; } },
  • src/server.js:29-29 (registration)
    Registers all tools from deviceTools module to the MCP server
    registerToolsFromModule(deviceTools);

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/vandreus/Unifi-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server