UNPKG

@toolprint/hypertool-mcp

Version:

HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers

113 lines • 3.03 kB
/** * Health monitoring system for MCP server connections */ import { EventEmitter } from "events"; import { Connection } from "./types.js"; /** * Server health states */ export declare enum HealthState { HEALTHY = "healthy", UNHEALTHY = "unhealthy", FAILED = "failed" } /** * Health check result */ export interface HealthCheckResult { serverId: string; serverName: string; state: HealthState; timestamp: Date; lastHealthyAt?: Date; error?: Error; } /** * Health monitoring configuration */ export interface HealthMonitorConfig { checkInterval: number; } /** * Health monitoring events */ export interface HealthMonitorEvents { stateChange: (result: HealthCheckResult, previousState?: HealthState) => void; } /** * Health monitor for tracking server availability */ export declare class HealthMonitor extends EventEmitter { private config; private connections; private healthResults; private checkTimer?; private isRunning; constructor(config?: Partial<HealthMonitorConfig>); /** * Add a connection to monitor */ addConnection(connection: Connection): void; /** * Remove a connection from monitoring */ removeConnection(serverName: string): void; /** * Start health monitoring */ start(): void; /** * Stop health monitoring */ stop(): void; /** * Get health status for a specific server */ getHealthStatus(serverName: string): HealthCheckResult | undefined; /** * Get health status for all servers */ getAllHealthStatus(): Map<string, HealthCheckResult>; /** * Get list of healthy servers */ getHealthyServers(): string[]; /** * Get list of unhealthy servers */ getUnhealthyServers(): string[]; /** * Get list of failed servers */ getFailedServers(): string[]; /** * Perform health check on all connections */ performHealthCheck(): Promise<Map<string, HealthCheckResult>>; /** * Check health of a specific connection */ private checkConnectionHealth; /** * Process health check result and emit appropriate events */ private processHealthResult; /** * Update health status based on connection events */ private updateHealthStatus; /** * Schedule periodic health checks */ private scheduleHealthChecks; /** * Override EventEmitter methods for type safety */ on<K extends keyof HealthMonitorEvents>(event: K, listener: HealthMonitorEvents[K]): this; on(event: string, listener: (...args: any[]) => void): this; off<K extends keyof HealthMonitorEvents>(event: K, listener: HealthMonitorEvents[K]): this; off(event: string, listener: (...args: any[]) => void): this; emit<K extends keyof HealthMonitorEvents>(event: K, ...args: Parameters<HealthMonitorEvents[K]>): boolean; emit(event: string, ...args: any[]): boolean; } //# sourceMappingURL=healthMonitor.d.ts.map