import type { Health } from "../contracts"; type TopologyProps = { hub?: Health; gateway?: Health; connectors?: Array<{ name: string; state: Health }>; compact?: boolean; }; const labels: Record = { healthy: "healthy", degraded: "degraded", unavailable: "unavailable", unknown: "unknown", }; function shortConnectorName(name: string): string { const normalized = name.toLowerCase(); if (normalized.includes("gitea")) return "Gitea"; if (normalized.includes("unraid")) return "Unraid"; if (normalized.includes("knowledge")) return "Knowledge"; if (normalized.includes("mobility")) return "Mobility"; return name.length > 13 ? `${name.slice(0, 12)}…` : name; } export function McpTopology({ hub = "healthy", gateway = "healthy", connectors = [], compact = false }: TopologyProps) { const targets = connectors.length ? connectors.slice(0, 3).map((connector) => ({ label: shortConnectorName(connector.name), state: connector.state })) : [ { label: "Gitea", state: "healthy" as const }, { label: "Knowledge", state: "healthy" as const }, { label: "Unraid", state: "healthy" as const }, ]; const hiddenTargets = Math.max(0, connectors.length - targets.length); const description = `Client requests pass through a ${labels[hub]} policy boundary and a ${labels[gateway]} MCP gateway to ${connectors.length || 3} scoped connector${(connectors.length || 3) === 1 ? "" : "s"}.`; return (
{connectors.length ? `${connectors.length} live routes` : "Deny by default"}
{description} {hiddenTargets > 0 ? +{hiddenTargets} additional scoped route{hiddenTargets === 1 ? "" : "s"} : null}
); }