UNPKG

@toolprint/hypertool-mcp

Version:

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

88 lines • 2.73 kB
/** * Connection pool implementation for managing multiple MCP server connections */ import { EventEmitter } from "events"; import { ServerConfig } from "../types/config.js"; import { Connection, ConnectionEventType, ConnectionEventCallback, ConnectionEvent, ConnectionPoolConfig, ConnectionStatus, IConnectionPool } from "./types.js"; import { ConnectionFactory } from "./factory.js"; /** * Connection pool manages a collection of connections to MCP servers */ export declare class ConnectionPool extends EventEmitter implements IConnectionPool { private connections; private config; private factory; private healthCheckTimer?; private isStarted; constructor(config?: ConnectionPoolConfig, factory?: ConnectionFactory); /** * Get the total number of connections in the pool */ get size(): number; /** * Get the number of active connections */ get activeConnections(): number; /** * Get the status of all connections */ get status(): Record<string, ConnectionStatus>; /** * Add a new connection to the pool */ addConnection(serverName: string, config: ServerConfig): Promise<Connection>; /** * Remove a connection from the pool */ removeConnection(serverName: string): Promise<void>; /** * Get a specific connection by server name */ getConnection(serverName: string): Connection | undefined; /** * Get all connections */ getConnections(): Connection[]; /** * Get names of all connected servers */ getConnectedServers(): string[]; /** * Start the connection pool */ start(): Promise<void>; /** * Stop the connection pool */ stop(): Promise<void>; /** * Setup connection event forwarding to pool events */ private setupConnectionEventForwarding; /** * Setup general event handlers */ private setupEventHandlers; /** * Start periodic health checks */ private startHealthCheck; /** * Stop periodic health checks */ private stopHealthCheck; /** * Perform health check on all connections */ private performHealthCheck; /** * Override EventEmitter methods to provide type safety */ on(event: ConnectionEventType, listener: ConnectionEventCallback): this; on(event: string, listener: (...args: any[]) => void): this; off(event: ConnectionEventType, listener: ConnectionEventCallback): this; off(event: string, listener: (...args: any[]) => void): this; emit(event: ConnectionEventType, data: ConnectionEvent): boolean; emit(event: string, ...args: any[]): boolean; } //# sourceMappingURL=pool.d.ts.map