get_sites_for_host
Retrieve all UniFi network sites managed by a specific host to organize and access network infrastructure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/network.js:74-85 (registration)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) }] }; } },
- src/unifi-client.js:77-80 (handler)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);
- src/server.js:16-25 (helper)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 } ); }); };