import type { CallToolResult } from "./protocol/content.js"; import { type ClientCapabilities, type Implementation, type InitializeResult, type ListResourcesResult, type ListResourceTemplatesResult, type ProgressNotification, type ReadResourceResult, type Resource, type ResourceTemplate, type Root, type ServerCapabilities, type SupportedProtocolVersion, type Tool } from "./protocol/types.js"; import type { McpTransport } from "./transports/transport.js"; type ClientState = "idle" | "connecting" | "connected" | "closed"; type NotificationListener = (params: unknown) => void; type ErrorListener = (error: Error) => void; type CloseListener = () => void; type RequestHandler = (params: unknown, context: { signal: AbortSignal; }) => unknown | Promise; export interface McpClientOptions extends Implementation { capabilities?: ClientCapabilities; protocolVersion?: SupportedProtocolVersion; requestTimeoutMs?: number; roots?: readonly Root[] | (() => readonly Root[] | Promise); } export interface McpRequestOptions { signal?: AbortSignal; timeoutMs?: number; onProgress?: (progress: ProgressNotification) => void; } export declare class McpClient { readonly options: Readonly; private state; private transport; private nextRequestId; private serverInfoValue; private serverCapabilitiesValue; private instructionsValue; private protocolVersionValue; private pending; private progressRequests; private incoming; private requestHandlers; private notificationListeners; private errorListeners; private closeListeners; private disposers; constructor(options: McpClientOptions); get connectionState(): ClientState; get serverInfo(): Implementation | undefined; get serverCapabilities(): ServerCapabilities | undefined; get instructions(): string | undefined; get protocolVersion(): string | undefined; connect(transport: McpTransport): Promise; request(method: string, params?: Record, options?: McpRequestOptions): Promise; notify(method: string, params?: Record): Promise; setRequestHandler(method: string, handler: RequestHandler): () => void; onNotification(method: string, listener: NotificationListener): () => void; onError(listener: ErrorListener): () => void; /** Called once when the connection closes, whether the transport dropped or `close()` was called. */ onClose(listener: CloseListener): () => void; ping(options?: McpRequestOptions): Promise; listTools(options?: McpRequestOptions): Promise; /** Every resource, following `nextCursor` through all pages. */ listResources(options?: McpRequestOptions): Promise; /** One page of resources, starting at `cursor`. */ listResourcesPage(cursor?: string, options?: McpRequestOptions): Promise; /** Every resource template, following `nextCursor` through all pages. */ listResourceTemplates(options?: McpRequestOptions): Promise; /** One page of resource templates, starting at `cursor`. */ listResourceTemplatesPage(cursor?: string, options?: McpRequestOptions): Promise; readResource(uri: string, options?: McpRequestOptions): Promise; private listPage; /** Every item of a paginated list method. */ private listAll; callTool(name: string, args?: Record, options?: McpRequestOptions): Promise; close(): Promise; private requestInternal; private notifyInternal; private requireTransport; private handleMessage; private handleResponse; private handleRequest; private handleNotification; private handleProgress; private handleCancelled; private armTimeout; private cancelPending; private removePending; private rejectPending; private handleTransportClose; /** Idempotent: rejects in-flight requests, aborts server requests we are serving, and flips the state. */ private markClosed; private emitError; private disposeTransportListeners; } export {}; //# sourceMappingURL=client.d.ts.map