UNPKG

adk-typescript

Version:

TypeScript port of Google's Agent Development Kit (ADK)

81 lines (80 loc) 2.9 kB
import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { Tool as McpBaseTool } from "@modelcontextprotocol/sdk/types.js"; export interface ACloseable { aclose(): Promise<void>; } export type CleanupCallback = () => Promise<void>; export declare class ClosedResourceError extends Error { constructor(message: string); } export declare class AsyncExitStack { private callbacks; /** * Enter an async context and register its cleanup function * @param context An object with an aclose method or a cleanup function * @returns The context that was entered */ enterAsyncContext<T>(context: T): Promise<T>; /** * Close all registered contexts in reverse order */ aclose(): Promise<void>; } export { McpBaseTool }; export type ClientSession = Client; export interface ListToolsResult { tools: McpBaseTool[]; } export interface StdioServerParameters { command: string; args: string[]; } export declare class SseServerParams { url: string; headers?: Record<string, any>; timeout?: number; sseReadTimeout?: number; constructor({ url, headers, timeout, sseReadTimeout }: { url: string; headers?: Record<string, any>; timeout?: number; sseReadTimeout?: number; }); } /** * A decorator factory that creates a function to retry operations when resources are closed. * @param asyncReinitFuncName Name of the method to call for reinitialization */ export declare function retryOnClosedResource(asyncReinitFuncName: string): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Manages MCP client sessions. * This class provides methods for creating and initializing MCP client sessions, * handling different connection parameters (Stdio and SSE). */ export declare class MCPSessionManager { private connectionParams; private exitStack; private errlog?; /** * Initializes the MCP session manager. * @param connectionParams Parameters for the MCP connection (Stdio or SSE) * @param exitStack AsyncExitStack to manage the session lifecycle * @param errlog Optional error logging stream */ constructor(connectionParams: StdioServerParameters | SseServerParams, exitStack: AsyncExitStack, errlog?: any); /** * Creates a new MCP client session * @returns A promise that resolves to a new ClientSession */ createSession(): Promise<ClientSession>; /** * Initializes an MCP client session * @param params Session initialization parameters * @returns A promise that resolves to the initialized ClientSession */ static initializeSession({ connectionParams, exitStack, errlog }: { connectionParams: StdioServerParameters | SseServerParams; exitStack: AsyncExitStack; errlog?: any; }): Promise<ClientSession>; }