import { Client } from '@modelcontextprotocol/sdk/client/index.js'; /** * Represents a pooled connection to an MCP server */ export interface PooledConnection { url: string; transport: 'stdio' | 'http' | 'websocket' | 'tcp' | 'auto'; client: Client; connectedAt: Date; lastUsed: Date; useCount: number; healthy: boolean; metadata?: Record; } /** * Configuration for connection pool */ export interface ConnectionPoolConfig { maxConnections?: number; connectionTTL?: number; idleTimeout?: number; healthCheckInterval?: number; retryAttempts?: number; retryDelay?: number; } /** * Connection pool for managing MCP client connections * Handles connection reuse, health checks, and automatic transport negotiation */ export declare class MCPConnectionPool { private connections; private config; private healthCheckTimer?; private cleanupTimer?; constructor(config?: ConnectionPoolConfig); /** * Get or create a client connection * @param url The server URL * @param transport Optional transport type (auto-negotiates if not specified) * @returns The MCP client */ getClient(url: string, transport?: 'stdio' | 'http' | 'websocket' | 'tcp' | 'auto'): Promise; /** * Create a new connection with auto-negotiation */ private createConnection; /** * Create a transport based on type */ private createTransport; /** * Detect transport type from URL */ private detectTransport; /** * Get next transport to try in fallback sequence */ private getNextTransport; /** * Extract headers from URL parameters */ private extractHeaders; /** * Remove a connection from the pool */ private removeConnection; /** * Evict the least recently used connection */ private evictLeastRecentlyUsed; /** * Perform health check on a connection */ private checkHealth; /** * Start maintenance tasks (health checks and cleanup) */ private startMaintenanceTasks; /** * Get connection key for caching */ private getConnectionKey; /** * Get count of active connections (those recently used) */ private getActiveConnectionCount; /** * Get pool statistics */ getStats(): { totalConnections: number; healthyConnections: number; unhealthyConnections: number; activeConnections: number; idleConnections: number; connectionsByTransport: Record; connectionsByUseCount: Array<{ url: string; useCount: number; ageMs: number; }>; averageUseCount: number; }; /** * Close all connections and stop maintenance tasks */ close(): Promise; } //# sourceMappingURL=ConnectionPool.d.ts.map