Skip to main content
Glama

wan-uptime-trend

Monitor WAN uptime across sites; flag connections below a threshold and prioritize those with lowest uptime.

Instructions

Aggregate WAN uptime across all sites with severity flagging (default threshold 95%). Returns per-WAN sorted by lowest uptime first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thresholdNoUptime % threshold below which WAN is flagged (default: 95)

Implementation Reference

  • src/index.ts:98-100 (registration)
    Registration of the 'wan-uptime-trend' tool with the MCP server, binding the schema and handler.
    tool("wan-uptime-trend",
      "Aggregate WAN uptime across all sites with severity flagging (default threshold 95%). Returns per-WAN sorted by lowest uptime first.",
      wanUptimeTrendSchema.shape, wrapToolHandler(wanUptimeTrend));
  • Input schema for wan-uptime-trend: optional threshold (default 95%).
    export const wanUptimeTrendSchema = z.object({
      threshold: z.coerce.number().optional().default(95)
        .describe("Uptime % threshold below which WAN is flagged (default: 95)"),
    });
  • Main handler function: aggregates WAN uptime across all sites, flags below threshold, returns sorted results with summary statistics.
    export async function wanUptimeTrend(params: z.infer<typeof wanUptimeTrendSchema>) {
      const sites = await resolveAllSites();
      const sitesResp = await unifiClient.get<{
        data: Array<{ hostId: string; statistics: SiteStatistics }>;
      }>("/sites");
    
      const rows: Array<{
        site: string;
        wan: string;
        uptime: number;
        externalIp: string;
        severity: "healthy" | "warning" | "critical";
      }> = [];
    
      for (const s of sitesResp.data) {
        const hostName = sites.find((x) => x.hostId === s.hostId)?.hostName ?? "unknown";
        const wans = s.statistics.wans ?? {};
        for (const [wanName, wan] of Object.entries(wans)) {
          const uptime = wan.wanUptime ?? 0;
          let severity: "healthy" | "warning" | "critical" = "healthy";
          if (uptime < 90) severity = "critical";
          else if (uptime < params.threshold) severity = "warning";
          rows.push({
            site: hostName,
            wan: wanName,
            uptime,
            externalIp: wan.externalIp ?? "",
            severity,
          });
        }
      }
    
      rows.sort((a, b) => a.uptime - b.uptime);
    
      const flagged = rows.filter((r) => r.severity !== "healthy");
      const critical = rows.filter((r) => r.severity === "critical").length;
      const warning = rows.filter((r) => r.severity === "warning").length;
      const avgUptime = rows.length === 0
        ? null
        : Math.round((rows.reduce((s, r) => s + r.uptime, 0) / rows.length) * 10) / 10;
    
      return {
        checkedAt: new Date().toISOString(),
        threshold: params.threshold,
        totalWans: rows.length,
        avgUptime,
        flagged: flagged.length,
        summary: flagged.length === 0
          ? `All ${rows.length} WAN(s) above ${params.threshold}% uptime`
          : `${flagged.length} WAN(s) below threshold: ${critical} critical, ${warning} warning`,
        wans: rows,
      };
    }
  • Type interface for SiteStatistics used by the handler to access WAN data.
    interface SiteStatistics {
      counts?: { totalDevice?: number; offlineDevice?: number };
      gateway?: { shortname?: string };
      percentages?: { wanUptime?: number };
      wans?: Record<string, { wanUptime?: number; externalIp?: string }>;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, description reveals input parameter (threshold) and output behavior (aggregation, sorting). However, it does not disclose data source, frequency of updates, or read-only nature, which are important for behavioral transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence efficiently conveys purpose, behavior, and output format. No redundant information; every part adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with no output schema, description covers key aspects (purpose, input, output format) but lacks details on output field structure, how flags are represented, and time range covered. More specificity would enhance completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema already provides complete description for the single parameter (threshold with default). Description adds context of 'severity flagging' but does not elaborate on value range or format, so minimal added value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states it aggregates WAN uptime across all sites with severity flagging and default threshold. It clearly distinguishes from sibling tools like 'get-isp-metrics' which focuses on metrics, not aggregate uptime.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description implies usage for getting an overview of WAN uptime with a threshold, but does not provide guidance on when to use this versus alternatives (e.g., 'site-health-timeline' for historical trends). No exclusion criteria or prerequisites mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/us-all/unifi-mcp-server'

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