/** * Connection Pool Manager Service * * Manages MCP client connections with: * - Connection pooling and reuse * - LRU (Least Recently Used) eviction * - Idle connection cleanup * - Automatic reconnection after max executions */ import type { MCPConnection, MCPConfig, MCPTransport, ConnectionPoolConfig } from '../types/connection.js'; import type { OrchestratorContext } from '../interfaces/orchestrator-context.js'; import type { OrchestratorService } from '../interfaces/service-container.js'; /** * Factory for creating MCP transports * Abstracted to allow testing and customization */ export interface TransportFactory { /** * Create a transport for the given configuration * Supports: StdioClientTransport, SSEClientTransport, StreamableHTTPClientTransport */ createTransport(config: MCPConfig, env?: Record): Promise; /** * Get authentication token for a config (if needed) */ getAuthToken?(config: MCPConfig): Promise; } /** * Connection Pool Manager * * Manages a pool of MCP client connections with automatic lifecycle management. */ export declare class ConnectionPoolManager implements OrchestratorService { private context; private transportFactory; private config; private connections; private cleanupTimer?; constructor(context: OrchestratorContext, transportFactory: TransportFactory, config?: Partial); /** * Initialize the connection pool manager * Starts the cleanup timer */ initialize(): Promise; /** * Get or create a connection to an MCP * * @param mcpName - Name of the MCP to connect to * @returns Active connection to the MCP */ getOrCreateConnection(mcpName: string): Promise; /** * Create a new connection to an MCP */ private createConnection; /** * Disconnect a specific MCP */ disconnect(mcpName: string): Promise; /** * Get an existing connection (without creating) */ getConnection(mcpName: string): MCPConnection | undefined; /** * Check if a connection exists */ hasConnection(mcpName: string): boolean; /** * Get number of active connections */ getConnectionCount(): number; /** * Get all connection names */ getConnectionNames(): string[]; /** * Get connection statistics */ getConnectionStats(): Array<{ mcpName: string; executionCount: number; idleTime: number; connectTime: number; }>; /** * Evict least recently used connection when pool is full */ private evictLRU; /** * Start the cleanup timer */ private startCleanupTimer; /** * Clean up idle connections and enforce pool health */ private cleanupIdleConnections; /** * Cleanup - stop timer and close all connections */ cleanup(): Promise; } /** * Factory function for creating ConnectionPoolManager */ export declare function createConnectionPoolManager(context: OrchestratorContext, transportFactory: TransportFactory, config?: Partial): ConnectionPoolManager; //# sourceMappingURL=connection-pool.d.ts.map