Skip to main content
Glama
vandreus

UniFi MCP Server

by vandreus

get_sites_for_host

Retrieve all UniFi network sites managed by a specific host to organize and access network infrastructure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the 'get_sites_for_host' tool within the networkTools object. Includes the tool description, input schema using Zod, and a thin handler wrapper that calls the underlying unifi helper and formats the response as MCP content.
    get_sites_for_host: { description: 'Get all sites for a specific host', schema: z.object({ hostId: z.string().describe('The host ID') }), handler: async ({ hostId }) => { const sites = await unifi.getSitesForHost(hostId); return { content: [{ type: 'text', text: JSON.stringify(sites, null, 2) }] }; } },
  • The core handler logic for fetching sites associated with a specific UniFi host via the Cloud API. This function is called by the tool's wrapper handler.
    export async function getSitesForHost(hostId) { const response = await cloudApi.get(`/v1/hosts/${hostId}/sites`); return response.data; }
  • src/server.js:28-28 (registration)
    Registers all tools from the networkTools module (including get_sites_for_host) to the MCP server using the registerToolsFromModule utility.
    registerToolsFromModule(networkTools);
  • Utility function used to register tools from a module object to the MCP server, processing name, schema, handler, and description.
    const registerToolsFromModule = (toolsModule) => { Object.entries(toolsModule).forEach(([name, toolConfig]) => { server.tool( name, toolConfig.schema, toolConfig.handler, { description: toolConfig.description } ); }); };

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