import { z } from 'zod';
import * as unifi from '../unifi-client.js';
export const networkTools = {
// ========================================
// Health & Status
// ========================================
unifi_health: {
description: 'Check UniFi Cloud API connectivity and basic health status',
schema: z.object({}),
handler: async () => {
const health = await unifi.healthCheck();
return {
content: [{ type: 'text', text: JSON.stringify(health, null, 2) }]
};
}
},
get_system_status: {
description: 'Get comprehensive UniFi system status including all hosts, sites, devices, and clients',
schema: z.object({}),
handler: async () => {
const status = await unifi.getSystemStatus();
return {
content: [{ type: 'text', text: JSON.stringify(status, null, 2) }]
};
}
},
// ========================================
// Hosts Management
// ========================================
list_hosts: {
description: 'List all UniFi OS hosts (consoles) in your account',
schema: z.object({}),
handler: async () => {
const hosts = await unifi.listHosts();
return {
content: [{ type: 'text', text: JSON.stringify(hosts, null, 2) }]
};
}
},
get_host: {
description: 'Get details of a specific UniFi OS host',
schema: z.object({
hostId: z.string().describe('The host ID')
}),
handler: async ({ hostId }) => {
const host = await unifi.getHost(hostId);
return {
content: [{ type: 'text', text: JSON.stringify(host, null, 2) }]
};
}
},
// ========================================
// Sites Management
// ========================================
list_sites: {
description: 'List all sites across all hosts',
schema: z.object({}),
handler: async () => {
const sites = await unifi.listSites();
return {
content: [{ type: 'text', text: JSON.stringify(sites, null, 2) }]
};
}
},
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) }]
};
}
},
// ========================================
// ISP Metrics
// ========================================
get_isp_metrics: {
description: 'Get ISP performance metrics (latency, speed, uptime) for a host',
schema: z.object({
hostId: z.string().describe('The host ID'),
duration: z.enum(['1h', '1d', '7d', '30d']).optional().default('1d').describe('Time duration for metrics')
}),
handler: async ({ hostId, duration }) => {
const metrics = await unifi.getIspMetrics(hostId, duration);
return {
content: [{ type: 'text', text: JSON.stringify(metrics, null, 2) }]
};
}
}
};
export default networkTools;