mcp-use
Version:
A utility library for integrating Model Context Protocol (MCP) with LangChain, Zod, and related tools. Provides helpers for schema conversion, event streaming, and SDK usage.
56 lines • 1.65 kB
TypeScript
export type ConnectionType<T = any> = T;
export declare abstract class ConnectionManager<T = any> {
private _readyPromise;
private _readyResolver;
private _donePromise;
private _doneResolver;
private _exception;
private _connection;
private _task;
private _abortController;
constructor();
/**
* Establish the connection.
*
* This method should be implemented by subclasses to establish the specific
* type of connection needed.
*
* @returns The established connection.
* @throws If the connection cannot be established.
*/
protected abstract establishConnection(): Promise<T>;
/**
* Close the connection.
*
* This method should be implemented by subclasses to close the specific type
* of connection.
*
* @param connection The connection to close.
*/
protected abstract closeConnection(connection: T): Promise<void>;
/**
* Start the connection manager and establish a connection.
*
* @returns The established connection.
* @throws If the connection cannot be established.
*/
start(): Promise<T>;
/**
* Stop the connection manager and close the connection.
*/
stop(): Promise<void>;
/**
* Reset all internal state.
*/
private reset;
/**
* The background task responsible for establishing and maintaining the
* connection until it is cancelled.
*/
private connectionTask;
/**
* Helper that returns a promise which resolves when the abort signal fires.
*/
private waitForAbort;
}
//# sourceMappingURL=base.d.ts.map