@n8n/n8n-nodes-langchain
Version:
47 lines (46 loc) • 1.47 kB
TypeScript
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { McpClientConfig } from '@n8n/config';
import type { McpTool } from './types';
export interface McpCacheLogger {
warn(message: string, meta?: object): void;
debug(message: string, meta?: object): void;
}
interface CachedClient {
client: Client;
mcpTools: McpTool[];
lastUsedAt: number;
epoch: number;
detachLifecycle: () => void;
}
interface GetOrConnectOpts {
logger?: McpCacheLogger;
onExecutionCancellation?: (handler: () => void) => void;
onExecutionFinish?: (handler: () => void) => void;
}
export declare class McpClientsManager {
private readonly config;
private readonly activeClients;
private readonly pendingConnections;
private readonly cleanupTimer;
private connectionEpoch;
private readonly exitHandler;
constructor(config: McpClientConfig);
get size(): number;
getEntry(key: string): CachedClient | undefined;
getOrConnect(key: string, factory: () => Promise<{
client: Client;
mcpTools: McpTool[];
}>, opts?: GetOrConnectOpts): Promise<{
client: Client;
mcpTools: McpTool[];
}>;
refresh(key: string): void;
remove(key: string, logger?: McpCacheLogger): void;
private registerLifecycleCleanup;
private removeIfCurrent;
evictStale(): void;
private enforceMaxSize;
private attachTransportLifecycle;
shutdown(): void;
}
export {};