@toolprint/hypertool-mcp
Version:
HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers
113 lines • 3.45 kB
TypeScript
/**
* Connection manager for handling multiple MCP server connections
*/
import { EventEmitter } from "events";
import { ServerConfig } from "../types/config.js";
import { Connection, ConnectionEventType, ConnectionEventCallback, ConnectionEvent, ConnectionStatus, ConnectionPoolConfig, IConnectionManager, IConnectionPool } from "./types.js";
import { ConnectionFactory } from "./factory.js";
/**
* Connection manager orchestrates connections to multiple MCP servers
*/
export declare class ConnectionManager extends EventEmitter implements IConnectionManager {
private _pool;
private _healthMonitor;
private _logger;
private _recoveryCoordinator;
private servers;
private isInitialized;
private isStarted;
constructor(poolConfig?: ConnectionPoolConfig, connectionFactory?: ConnectionFactory);
/**
* Get the connection pool
*/
get pool(): IConnectionPool;
/**
* Get the status of all connections
*/
get status(): Record<string, ConnectionStatus>;
/**
* Initialize the connection manager with server configurations
*/
initialize(servers: Record<string, ServerConfig>): Promise<void>;
/**
* Connect to a specific server
*/
connect(serverName: string): Promise<void>;
/**
* Disconnect from a specific server
*/
disconnect(serverName: string): Promise<void>;
/**
* Reconnect to a specific server
*/
reconnect(serverName: string): Promise<void>;
/**
* Get a specific connection
*/
getConnection(serverName: string): Connection | undefined;
/**
* Get names of all connected servers
*/
getConnectedServers(): string[];
/**
* Check if a specific server is connected
*/
isServerConnected(serverName: string): boolean;
/**
* Start the connection manager
*/
start(): Promise<void>;
/**
* Stop the connection manager
*/
stop(): Promise<void>;
/**
* Add a new server configuration
*/
addServer(serverName: string, config: ServerConfig): Promise<void>;
/**
* Remove a server configuration
*/
removeServer(serverName: string): Promise<void>;
/**
* Get server configuration
*/
getServerConfig(serverName: string): ServerConfig | undefined;
/**
* Get all server names
*/
getServerNames(): string[];
/**
* Get connection statistics
*/
getStats(): {
totalServers: number;
connectedServers: number;
disconnectedServers: number;
connectionRate: number;
activeConnections: number;
poolSize: number;
};
/**
* Validate server configurations
*/
private validateServerConfigurations;
/**
* Setup event forwarding from the pool
*/
private setupPoolEventForwarding;
/**
* Ensure the manager is initialized
*/
private ensureInitialized;
/**
* Override EventEmitter methods for 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=manager.d.ts.map