import { Schema, z } from 'zod'; import { ChildProcess } from 'node:child_process'; import { DependencyContainer } from 'tsyringe'; export { container } from 'tsyringe'; /** * Interface for server configuration */ interface ServerConfig$1 { /** * Command to start the server */ command: string; /** * Arguments to pass to the command */ args?: string[]; /** * Environment variables to set */ env?: Record; /** * Working directory for the server process */ cwd?: string; /** * Timeout for server startup (in milliseconds) */ startupTimeout?: number; /** * Whether to restart the server automatically on failure */ autoRestart?: boolean; /** * Maximum number of restart attempts */ maxRestarts?: number; /** * Delay between restart attempts (in milliseconds) */ restartDelay?: number; } /** * Interface for connection configuration */ interface ConnectionConfig$1 { /** * Type of transport to use (stdio, sse) */ transportType: 'stdio' | 'sse'; /** * Configuration for stdio transport */ stdio?: { /** * Whether to inherit stdio from the parent process */ inherit?: boolean; }; /** * Configuration for SSE transport */ sse?: { /** * Base URL for the SSE endpoint */ baseUrl: string; /** * Headers to include in requests */ headers?: Record; }; /** * Timeout for requests (in milliseconds) */ requestTimeout?: number; /** * Whether to reconnect automatically on disconnection */ autoReconnect?: boolean; /** * Maximum number of reconnection attempts */ maxReconnects?: number; /** * Delay between reconnection attempts (in milliseconds) */ reconnectDelay?: number; } /** * Interface for tool executor configuration */ interface ToolExecutorConfig$1 { /** * Maximum number of retries for tool execution */ maxRetries?: number; /** * Delay between retry attempts (in milliseconds) */ retryDelay?: number; /** * Whether to use exponential backoff for retries */ useExponentialBackoff?: boolean; /** * Timeout for tool execution (in milliseconds) */ executionTimeout?: number; /** * Whether to cache tool results */ cacheResults?: boolean; /** * Time-to-live for cached results (in milliseconds) */ cacheTtl?: number; } /** * Interface for resource manager configuration */ interface ResourceManagerConfig$1 { /** * Maximum size of resource content to cache (in bytes) */ maxCacheSize?: number; /** * Time-to-live for cached resources (in milliseconds) */ cacheTtl?: number; } /** * Interface for logger configuration */ interface LoggerConfig$1 { /** * Log level (debug, info, warn, error) */ level?: 'debug' | 'info' | 'warn' | 'error'; /** * Whether to log to console */ console?: boolean; /** * File to log to */ file?: string; } /** * Interface for server manager configuration */ interface ServerManagerConfig { /** * Default configuration for all servers */ defaults?: Partial; /** * Map of server names to server configurations */ servers?: Record; } /** * Interface for connection manager configuration */ interface ConnectionManagerConfig { /** * Default configuration for all connections */ defaults?: ConnectionConfig$1; /** * Server-specific connection configuration overrides */ overrides?: Record; } /** * Interface for the unified MCP toolkit configuration */ interface MCPToolkitConfig$1 { /** * Server configurations */ servers: Record; /** * Connection configurations */ connections?: { /** * Default connection configuration */ defaults?: ConnectionConfig$1; /** * Server-specific connection configuration overrides */ overrides?: Record; }; /** * Tool executor configuration */ toolExecutor?: ToolExecutorConfig$1; /** * Resource manager configuration */ resourceManager?: ResourceManagerConfig$1; /** * Logger configuration */ logger?: LoggerConfig$1; } /** * Interface defining a strategy for error recovery */ interface IErrorRecoveryStrategy { /** * Whether to retry the operation */ retry: boolean; /** * Number of retry attempts */ maxRetries: number; /** * Delay between retry attempts (in milliseconds) */ retryDelay: number; /** * Whether to use exponential backoff for retries */ useExponentialBackoff: boolean; /** * Whether to restart the server before retrying */ restartServerBeforeRetry: boolean; /** * Whether to reconnect before retrying */ reconnectBeforeRetry: boolean; } /** * Enum for error codes used throughout the MCP toolkit */ declare enum ErrorCode { SERVER_START_FAILED = "server_start_failed", SERVER_STOP_FAILED = "server_stop_failed", SERVER_NOT_RUNNING = "server_not_running", SERVER_NOT_FOUND = "server_not_found", SERVER_RESTART_FAILED = "server_restart_failed", SERVER_SPAWN_FAILED = "server_spawn_failed", SERVER_START_TIMEOUT = "server_start_timeout", CONNECTION_FAILED = "connection_failed", CONNECTION_LOST = "connection_lost", CONNECTION_CLOSED = "connection_closed", CONNECTION_NOT_ESTABLISHED = "connection_not_established", REQUEST_TIMEOUT = "request_timeout", REQUEST_FAILED = "request_failed", NOTIFICATION_FAILED = "notification_failed", DISCONNECT_FAILED = "disconnect_failed", RESPONSE_ERROR = "response_error", INVALID_RESPONSE = "invalid_response", TRANSPORT_SEND_FAILED = "transport_send_failed", TRANSPORT_RECEIVE_FAILED = "transport_receive_failed", TRANSPORT_CLOSE_FAILED = "transport_close_failed", TRANSPORT_NOT_OPEN = "transport_not_open", TOOL_NOT_FOUND = "tool_not_found", TOOL_EXECUTION_FAILED = "tool_execution_failed", INVALID_TOOL_ARGUMENTS = "invalid_tool_arguments", RESOURCE_NOT_FOUND = "resource_not_found", RESOURCE_READ_FAILED = "resource_read_failed", PROTOCOL_ERROR = "protocol_error", INVALID_MESSAGE = "invalid_message", VALIDATION_FAILED = "validation_failed", INVALID_CONFIGURATION = "invalid_configuration" } type ErrorData = Record; /** * Base error class for all MCP toolkit errors */ declare class MCPToolkitError extends Error { /** * Error code */ code: ErrorCode; /** * Additional data about the error */ data?: ErrorData; /** * Create a new MCPToolkitError * @param code Error code * @param message Error message * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, data?: ErrorData); } /** * Error class for server-related errors */ declare class ServerError extends MCPToolkitError { /** * Name of the server that caused the error */ serverName: string; /** * Create a new ServerError * @param code Error code * @param message Error message * @param serverName Name of the server * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, serverName: string, data?: ErrorData); } /** * Error class for connection-related errors */ declare class ConnectionError extends MCPToolkitError { /** * Name of the server for which the connection failed */ serverName: string; /** * Create a new ConnectionError * @param code Error code * @param message Error message * @param serverName Name of the server * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, serverName: string, data?: ErrorData); } /** * Error class for tool-related errors */ declare class ToolError extends MCPToolkitError { /** * Name of the tool that caused the error */ toolName: string; /** * Create a new ToolError * @param code Error code * @param message Error message * @param toolName Name of the tool * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, toolName: string, data?: ErrorData); } /** * Error class for resource-related errors */ declare class ResourceError extends MCPToolkitError { /** * URI of the resource that caused the error */ resourceUri: string; /** * Create a new ResourceError * @param code Error code * @param message Error message * @param resourceUri URI of the resource * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, resourceUri: string, data?: ErrorData); } /** * Error class for protocol-related errors */ declare class ProtocolError extends MCPToolkitError { /** * Method that caused the error */ method?: string; /** * Create a new ProtocolError * @param code Error code * @param message Error message * @param method Method that caused the error * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, method?: string, data?: ErrorData); } /** * Error class for configuration-related errors */ declare class ConfigurationError extends MCPToolkitError { /** * Path in the configuration that caused the error */ configPath?: string; /** * Create a new ConfigurationError * @param code Error code * @param message Error message * @param configPath Path in the configuration * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, configPath?: string, data?: ErrorData); } /** * Error class for transport-related errors */ declare class TransportError extends MCPToolkitError { /** * Type of transport that caused the error */ transportType: string; /** * Create a new TransportError * @param code Error code * @param message Error message * @param transportType Type of transport * @param data Additional data about the error */ constructor(code: ErrorCode, message: string, transportType: string, data?: ErrorData); } /** * Interface for the error service */ interface IErrorService { /** * Register an error handler for a specific error code * @param code Error code * @param handler Function to handle the error */ registerErrorHandler(code: ErrorCode, handler: (error: MCPToolkitError) => Promise): void; /** * Handle an error * @param error Error to handle */ handleError(error: MCPToolkitError): Promise; /** * Get a recovery strategy for an error * @param error Error to get recovery strategy for */ getRecoveryStrategy(error: MCPToolkitError): IErrorRecoveryStrategy; /** * Log an error * @param error Error to log */ logError(error: MCPToolkitError): void; /** * Create a specific error * @param type Type of error * @param code Error code * @param message Error message * @param context Additional context */ createError(type: 'server' | 'connection' | 'tool' | 'resource' | 'protocol' | 'configuration' | 'transport', code: ErrorCode, message: string, context?: ErrorData): MCPToolkitError; } /** * Enum for server events */ declare enum ServerEventType$1 { STARTING = "starting", STARTED = "started", STOPPING = "stopping", STOPPED = "stopped", RESTARTING = "restarting", HEALTHY = "healthy", UNHEALTHY = "unhealthy", STATUS_CHANGED = "status_changed", EXITED = "exited", OUTPUT = "output", ERROR = "error" } /** * Interface for server event data */ interface ServerEvent$1 { type: ServerEventType$1; serverName: string; timestamp: number; data?: any; } /** * Enum for connection events */ declare enum ConnectionEventType$1 { CONNECTING = "connecting", CONNECTED = "connected", DISCONNECTING = "disconnecting", DISCONNECTED = "disconnected", RECONNECTING = "reconnecting", ERROR = "error" } /** * Interface for connection event data */ interface ConnectionEvent$1 { type: ConnectionEventType$1; serverName: string; timestamp: number; data?: any; } /** * Enum for tool events */ declare enum ToolEventType$1 { TOOLS_CHANGED = "tools_changed", EXECUTION_STARTED = "execution_started", EXECUTION_SUCCEEDED = "execution_succeeded", EXECUTION_FAILED = "execution_failed", EXECUTION_RETRYING = "execution_retrying" } /** * Interface for tool event data */ interface ToolEvent$1 { type: ToolEventType$1; toolName?: string; serverName?: string; timestamp: number; data?: any; } /** * Enum for resource events */ declare enum ResourceEventType$1 { RESOURCES_CHANGED = "resources_changed", RESOURCE_UPDATED = "resource_updated", SUBSCRIPTION_SUCCEEDED = "subscription_succeeded", SUBSCRIPTION_FAILED = "subscription_failed" } /** * Interface for resource event data */ interface ResourceEvent$1 { type: ResourceEventType$1; resourceUri?: string; serverName?: string; timestamp: number; data?: any; } /** * Interface for logger service */ interface ILoggerService { /** * Log a debug message * @param message The message to log * @param meta Additional metadata */ debug(message: string, meta?: Record): void; /** * Log an info message * @param message The message to log * @param meta Additional metadata */ info(message: string, meta?: Record): void; /** * Log a warning message * @param message The message to log * @param meta Additional metadata */ warn(message: string, meta?: Record): void; /** * Log an error message * @param message The message to log * @param meta Additional metadata */ error(message: string, meta?: Record): void; /** * Set the log level * @param level The log level */ setLevel(level: 'debug' | 'info' | 'warn' | 'error'): void; } /** * Interface for a request message */ interface Request { method: string; params?: any; } /** * Interface for a response message */ interface Response { result?: any; error?: { code: number; message: string; data?: any; }; } /** * Interface for a notification message */ interface Notification { method: string; params?: any; } /** * Interface for the initialize request */ interface InitializeRequest extends Request { method: 'initialize'; params: { protocolVersion: string; client: { name: string; version: string; }; capabilities: { resources?: Record; tools?: Record; prompts?: Record; sampling?: Record; }; }; } /** * Interface for the initialized notification */ interface InitializedNotification extends Notification { method: 'initialized'; } /** * Interface for the close request */ interface CloseRequest extends Request { method: 'close'; } /** * Interface for the list tools request */ interface ListToolsRequest extends Request { method: 'tools/list'; } /** * Interface for the call tool request */ interface CallToolRequest extends Request { method: 'tools/call'; params: { name: string; arguments?: any; parameters?: any; }; } /** * Interface for the list resources request */ interface ListResourcesRequest extends Request { method: 'resources/list'; } /** * Interface for the read resource request */ interface ReadResourceRequest extends Request { method: 'resources/read'; params: { uri: string; }; } /** * Interface for the subscribe resource request */ interface SubscribeResourceRequest extends Request { method: 'resources/subscribe'; params: { uri: string; }; } /** * Interface for the resource updated notification */ interface ResourceUpdatedNotification extends Notification { method: 'notifications/resources/updated'; params: { uri: string; }; } /** * Interface representing a resource available on an MCP server */ interface Resource { /** * The URI of the resource */ uri: string; /** * The server that provides this resource */ serverName: string; /** * The type of the resource */ type: string; /** * Description of the resource */ description?: string; } /** * Interface representing the content of a resource */ interface ResourceContent { /** * The URI of the resource */ uri: string; /** * The content type */ contentType: string; /** * The content of the resource */ content: any; /** * Timestamp of when the content was last updated */ lastUpdated: number; } /** * Interface for managing resources on MCP servers */ interface IResourceManagement { /** * List all available resources */ listResources(): Promise; /** * Read a resource * @param uri The URI of the resource to read */ readResource(uri: string): Promise; /** * Subscribe to resource updates * @param uri The URI of the resource to subscribe to */ subscribeToResource(uri: string): Promise; /** * Unsubscribe from resource updates * @param uri The URI of the resource to unsubscribe from */ unsubscribeFromResource(uri: string): Promise; /** * Listen for resource updates * @param listener Function to be called when a resource is updated */ onResourceUpdated(listener: (uri: string) => void): void; } /** * Interface for managing connections to MCP servers */ interface IServerConnection { /** * Connect to the server */ connect(): Promise; /** * Disconnect from the server */ disconnect(): Promise; /** * Check if connected to the server */ isConnected(): boolean; /** * Send a request to the server and await a response * @param method The method name * @param params The parameters for the method * @param resultSchema Optional schema for validating the response */ request(method: string, params?: any, resultSchema?: Schema): Promise; /** * Send a notification to the server (no response expected) * @param method The method name * @param params The parameters for the method */ notify(method: string, params?: any): Promise; /** * Register a handler for server requests * @param method The method name to handle * @param handler The handler function */ handleRequest(method: string, handler: (params: any) => Promise): void; /** * Register a handler for server notifications * @param method The method name to handle * @param handler The handler function */ handleNotification(method: string, handler: (params: any) => Promise): void; /** * Listen for connection events * @param listener Function to be called when an event occurs */ onConnectionEvent(listener: (event: ConnectionEvent$1) => void): void; } /** * Enum representing the possible states of a server */ declare enum ServerStatus { STOPPED = "stopped", STARTING = "starting", RUNNING = "running", STOPPING = "stopping", ERROR = "error" } /** * Interface for managing the lifecycle of an MCP server */ interface IServerLifecycle { /** * Start the server process */ start(): Promise; /** * Stop the server process */ stop(): Promise; /** * Restart the server process */ restart(): Promise; /** * Check if the server is running */ isRunning(): boolean; /** * Get the current status of the server */ getStatus(): ServerStatus; /** * Listen for status changes * @param listener Function to be called when the status changes */ onStatusChange(listener: (status: ServerStatus) => void): void; } /** * Interface representing a tool available on an MCP server */ interface Tool { /** * The name of the tool */ name: string; /** * The server that provides this tool */ serverName: string; /** * Description of the tool */ description?: string; /** * Schema of the tool's parameters */ parameters?: Record; /** * Schema of the tool's return value */ returns?: Record; } /** * Interface representing a tool call */ interface ToolCall { /** * The name of the tool to call */ function_name: string; /** * Parameters to pass to the tool */ parameters: Record; } /** * Interface representing the result of a tool call */ interface ToolResult { /** * Whether the tool call succeeded */ success: boolean; /** * The result of the tool call */ result?: any; /** * Error information if the tool call failed */ error?: { code: string; message: string; data?: any; }; } /** * Interface for options when executing tool calls */ interface ExecutionOptions { /** * Timeout in milliseconds */ timeout?: number; /** * Whether to retry on failure */ retry?: boolean; /** * Maximum number of retries */ maxRetries?: number; /** * Delay between retries in milliseconds */ retryDelay?: number; } /** * Interface for discovering tools on MCP servers */ interface IToolDiscovery { /** * Get all available tools across all servers */ getAvailableTools(): Promise; /** * Get tools for a specific server * @param serverName The name of the server */ getServerTools(serverName: string): Promise; /** * Listen for changes in available tools * @param listener Function to be called when tools change */ onToolsChanged(listener: (tools: Tool[]) => void): void; } /** * Interface for executing tool calls on MCP servers */ interface IToolExecution { /** * Execute a tool call * @param call The tool call to execute */ executeToolCall(call: ToolCall): Promise; /** * Execute multiple tool calls in parallel * @param calls The tool calls to execute */ executeToolCalls(calls: ToolCall[]): Promise; /** * Execute a tool call with specific options * @param call The tool call to execute * @param options Options for execution */ executeToolCallWithOptions(call: ToolCall, options: ExecutionOptions): Promise; } /** * Interface for the transport layer used to communicate with MCP servers */ interface ITransport { /** * Send a message to the server * @param message The message to send */ send(message: string): Promise; /** * Receive a message from the server * @returns A promise that resolves with the received message */ receive(): Promise; /** * Close the transport */ close(): Promise; /** * Check if the transport is open */ isOpen(): boolean; /** * Listen for transport closure * @param listener Function to be called when the transport closes */ onClose(listener: () => void): void; } /** * Interface for server manager service */ interface IServerManagerService { /** * Register a server configuration * @param name Name of the server * @param config Server configuration */ registerServer(name: string, config: ServerConfig$1): void; /** * Start a server * @param name Name of the server */ startServer(name: string): Promise; /** * Stop a server * @param name Name of the server */ stopServer(name: string): Promise; /** * Restart a server * @param name Name of the server */ restartServer(name: string): Promise; /** * Get the status of a server * @param name Name of the server */ getServerStatus(name: string): ServerStatus; /** * Check if a server is running * @param name Name of the server */ isServerRunning(name: string): boolean; /** * Start all registered servers */ startAllServers(): Promise; /** * Stop all registered servers */ stopAllServers(): Promise; /** * Get the status of all registered servers */ getAllServerStatuses(): Record; /** * Listen for server events * @param listener Function to be called when an event occurs */ onServerEvent(listener: (event: ServerEvent$1) => void): void; /** * Get the process for a server * @param name Name of the server */ getServerProcess(name: string): ChildProcess | undefined; } /** * Interface for the connection manager service */ interface IConnectionManagerService { /** * Get connection for a server * @param serverName Name of the server */ getConnection(serverName: string): IServerConnection; /** * Connect to a server * @param serverName Name of the server */ connect(serverName: string): Promise; /** * Disconnect from a server * @param serverName Name of the server */ disconnect(serverName: string): Promise; /** * Check if connected to a server * @param serverName Name of the server */ isConnected(serverName: string): boolean; /** * Connect to all available servers */ connectAll(): Promise; /** * Disconnect from all servers */ disconnectAll(): Promise; /** * Get a list of all server connections */ getAllConnections(): Record; /** * Listen for connection events * @param listener Function to be called when an event occurs */ onConnectionEvent(listener: (event: ConnectionEvent$1) => void): void; } /** * Base abstract class for transport implementations * Note: This class is abstract and should not be directly instantiated. * The @injectable decorator must be applied to derived classes. */ declare abstract class BaseTransport implements ITransport { protected errorService: IErrorService; protected logger: ILoggerService; /** * Whether the transport is open */ protected _isOpen: boolean; /** * List of listeners to call when the transport closes */ protected closeListeners: Array<() => void>; /** * Constructor * @param errorService Error service for handling errors * @param logger Logger service */ constructor(errorService: IErrorService, logger: ILoggerService); /** * Send a message to the server * @param message The message to send */ send(message: string): Promise; /** * Receive a message from the server * @returns A promise that resolves with the received message */ receive(): Promise; /** * Close the transport */ close(): Promise; /** * Check if the transport is open */ isOpen(): boolean; /** * Listen for transport closure * @param listener Function to be called when the transport closes */ onClose(listener: () => void): void; /** * Notify all close listeners */ protected notifyCloseListeners(): void; /** * Get the type of transport */ abstract getTransportType(): string; /** * Implementation-specific send logic * @param message The message to send */ protected abstract doSend(message: string): Promise; /** * Implementation-specific receive logic */ protected abstract doReceive(): Promise; /** * Implementation-specific close logic */ protected abstract doClose(): Promise; } /** * Interface for StdioTransport configuration */ interface StdioTransportConfig { /** * Child process to communicate with */ childProcess: ChildProcess; /** * Whether to inherit stdio from the parent process */ inherit?: boolean; } /** * Transport implementation using standard input/output for child process communication */ declare class StdioTransport extends BaseTransport { /** * The child process to communicate with */ private childProcess; /** * The stdin stream to write to */ private stdin; /** * The stdout stream to read from */ private stdout; /** * Buffer for storing incoming data */ private buffer; /** * Resolvers for pending receive calls */ private receiveResolvers; /** * Whether the transport should inherit stdio from the parent process */ private inherit; /** * Constructor * @param config Configuration for the stdio transport * @param errorService Error service for handling errors * @param logger Logger service */ constructor(config: StdioTransportConfig, errorService: IErrorService, logger: ILoggerService); /** * Get the transport type */ getTransportType(): string; /** * Send a message to the server * @param message The message to send */ protected doSend(message: string): Promise; /** * Receive a message from the server */ protected doReceive(): Promise; /** * Close the transport */ protected doClose(): Promise; /** * Setup event handlers for the child process */ private setupEventHandlers; /** * Remove event handlers */ private removeEventHandlers; /** * Handle data from stdout */ private handleStdoutData; /** * Handle process exit */ private handleProcessExit; /** * Handle process error */ private handleProcessError; } /** * Interface for SSETransport configuration */ interface SSETransportConfig { /** * Base URL for the SSE endpoint */ baseUrl: string; /** * Headers to include in requests */ headers?: Record; /** * Timeout for requests (in milliseconds) */ requestTimeout?: number; } /** * Transport implementation using Server-Sent Events (SSE) for server communication */ declare class SSETransport extends BaseTransport { /** * Base URL for the SSE endpoint */ private baseUrl; /** * Headers to include in requests */ private headers; /** * Timeout for requests (in milliseconds) */ private requestTimeout; /** * The SSE event source */ private eventSource; /** * Resolvers for pending receive calls */ private receiveResolvers; /** * Queue of received messages */ private messageQueue; /** * AbortController for fetch requests */ private abortController; /** * Constructor * @param config Configuration for the SSE transport * @param errorService Error service for handling errors * @param logger Logger service */ constructor(config: SSETransportConfig, errorService: IErrorService, logger: ILoggerService); /** * Get the transport type */ getTransportType(): string; /** * Initialize the SSE connection */ private initConnection; /** * Send a message to the server * @param message The message to send */ protected doSend(message: string): Promise; /** * Receive a message from the server */ protected doReceive(): Promise; /** * Close the transport */ protected doClose(): Promise; /** * Setup event handlers for the SSE event source */ private setupEventHandlers; /** * Handle SSE message event */ private handleMessage; /** * Handle SSE error event */ private handleError; /** * Handle SSE open event */ private handleOpen; } /** * Interface for creating transports */ interface ITransportFactory { /** * Create a transport for communicating with a server * @param type Type of transport to create * @param config Configuration for the transport */ createTransport(type: 'stdio' | 'sse', config: StdioTransportConfig | SSETransportConfig): ITransport; } /** * Types for the MCP Toolkit */ /** * Server type enum */ declare enum ServerType { /** * Python server */ PYTHON = "python", /** * JavaScript server */ JAVASCRIPT = "javascript", /** * Custom server */ CUSTOM = "custom" } /** * This file defines the configuration interfaces for the MCPToolkit. */ /** * Server configuration */ interface ServerConfig { /** * Command to start the server */ command: string; /** * Arguments to pass to the command */ args?: string[]; /** * Environment variables to set */ env?: Record; /** * Working directory for the server process */ cwd?: string; /** * Timeout for server startup (in milliseconds) */ startupTimeout?: number; /** * Whether to restart the server automatically on failure */ autoRestart?: boolean; /** * Maximum number of restart attempts */ maxRestarts?: number; /** * Delay between restart attempts (in milliseconds) */ restartDelay?: number; } /** * Connection configuration */ interface ConnectionConfig { /** * Type of transport to use (stdio, sse) */ transportType: 'stdio' | 'sse'; /** * Configuration for stdio transport */ stdio?: { /** * Whether to inherit stdio from the parent process */ inherit?: boolean; }; /** * Configuration for SSE transport */ sse?: { /** * Base URL for the SSE endpoint */ baseUrl: string; /** * Headers to include in requests */ headers?: Record; }; /** * Timeout for requests (in milliseconds) */ requestTimeout?: number; /** * Whether to reconnect automatically on disconnection */ autoReconnect?: boolean; /** * Maximum number of reconnection attempts */ maxReconnects?: number; /** * Delay between reconnection attempts (in milliseconds) */ reconnectDelay?: number; } /** * Tool executor configuration */ interface ToolExecutorConfig { /** * Maximum number of retries for tool execution */ maxRetries?: number; /** * Delay between retry attempts (in milliseconds) */ retryDelay?: number; /** * Whether to use exponential backoff for retries */ useExponentialBackoff?: boolean; /** * Timeout for tool execution (in milliseconds) */ executionTimeout?: number; /** * Whether to cache tool results */ cacheResults?: boolean; /** * Time-to-live for cached results (in milliseconds) */ cacheTtl?: number; } /** * Resource manager configuration */ interface ResourceManagerConfig { /** * Maximum size of resource content to cache (in bytes) */ maxCacheSize?: number; /** * Time-to-live for cached resources (in milliseconds) */ cacheTtl?: number; } /** * Logger configuration */ interface LoggerConfig { /** * Log level (debug, info, warn, error) */ level?: 'debug' | 'info' | 'warn' | 'error'; /** * Whether to log to console */ console?: boolean; /** * File to log to */ file?: string; } /** * Main toolkit configuration */ interface MCPToolkitConfig { /** * Server configurations */ servers: Record; /** * Connection configurations (defaults applied to all servers) */ connections?: { /** * Default connection configuration */ defaults?: ConnectionConfig; /** * Server-specific connection configuration overrides */ overrides?: Record; }; /** * Tool executor configuration */ toolExecutor?: ToolExecutorConfig; /** * Resource manager configuration */ resourceManager?: ResourceManagerConfig; /** * Logger configuration */ logger?: LoggerConfig; } /** * This file defines the event types and interfaces for the MCPToolkit. */ /** * Server event types */ declare enum ServerEventType { ServerStatusChange = "server:status:change", ServerStarting = "server:starting", ServerStarted = "server:started", ServerStopping = "server:stopping", ServerStopped = "server:stopped", ServerRestarting = "server:restarting", ServerError = "server:error" } /** * Connection event types */ declare enum ConnectionEventType { ConnectionStatusChange = "connection:status:change", ConnectionConnecting = "connection:connecting", ConnectionConnected = "connection:connected", ConnectionDisconnecting = "connection:disconnecting", ConnectionDisconnected = "connection:disconnected", ConnectionReconnecting = "connection:reconnecting", ConnectionError = "connection:error" } /** * Tool event types */ declare enum ToolEventType { ToolsChanged = "tool:changed", ToolExecutionStarted = "tool:execution:started", ToolExecutionSucceeded = "tool:execution:succeeded", ToolExecutionFailed = "tool:execution:failed", ToolExecutionRetrying = "tool:execution:retrying" } /** * Resource event types */ declare enum ResourceEventType { ResourcesChanged = "resource:changed", ResourceUpdated = "resource:updated", ResourceSubscriptionSucceeded = "resource:subscription:succeeded", ResourceSubscriptionFailed = "resource:subscription:failed" } /** * All event types in the toolkit */ type MCPToolkitEventType = ServerEventType | ConnectionEventType | ToolEventType | ResourceEventType; /** * Base event interface */ interface BaseEvent { type: MCPToolkitEventType; timestamp: number; correlationId?: string; } /** * Server event interface */ interface ServerEvent extends BaseEvent { type: ServerEventType; serverName: string; status?: ServerStatus; error?: Error; } /** * Connection event interface */ interface ConnectionEvent extends BaseEvent { type: ConnectionEventType; serverName: string; connected?: boolean; error?: Error; } /** * Tool event interface */ interface ToolEvent extends BaseEvent { type: ToolEventType; tools?: Tool[]; toolCall?: ToolCall; toolResult?: ToolResult; error?: Error; serverName?: string; } /** * Resource event interface */ interface ResourceEvent extends BaseEvent { type: ResourceEventType; resources?: Resource[]; resourceUri?: string; error?: Error; serverName?: string; } /** * Union type for all event types */ type MCPToolkitEvent = ServerEvent | ConnectionEvent | ToolEvent | ResourceEvent; /** * Type for event callbacks */ type MCPToolkitEventCallback = (event: Extract) => void; /** * This file defines the IMCPToolkit interface, which is the main entry point for the MCP Toolkit. * It provides a unified API for all toolkit functionality. */ /** * Main interface for the MCP Toolkit. * Provides a unified API for all toolkit functionality. */ interface IMCPToolkit { /** * Configure the toolkit with the provided configuration. * @param config The configuration to apply */ configure(config: MCPToolkitConfig): void; /** * Start the toolkit (starts servers and establishes connections). */ start(): Promise; /** * Stop the toolkit (stops servers and closes connections). */ stop(): Promise; /** * Get all available tools across all servers. * @returns Promise resolving to an array of tools */ getAvailableTools(): Promise; /** * Execute a tool call. * @param call The tool call to execute * @returns Promise resolving to the tool result */ executeToolCall(call: ToolCall): Promise; /** * Execute multiple tool calls in parallel. * @param calls The tool calls to execute * @returns Promise resolving to an array of tool results */ executeToolCalls(calls: ToolCall[]): Promise; /** * Execute a tool call with specific options. * @param call The tool call to execute * @param options The execution options * @returns Promise resolving to the tool result */ executeToolCallWithOptions(call: ToolCall, options: ExecutionOptions): Promise; /** * List all available resources across all servers. * @returns Promise resolving to an array of resources */ listResources(): Promise; /** * Read a resource. * @param uri The URI of the resource to read * @returns Promise resolving to the resource content */ readResource(uri: string): Promise; /** * Subscribe to resource updates. * @param uri The URI of the resource to subscribe to */ subscribeToResource(uri: string): Promise; /** * Unsubscribe from resource updates. * @param uri The URI of the resource to unsubscribe from */ unsubscribeFromResource(uri: string): Promise; /** * Get the status of all servers. * @returns Record mapping server names to their status */ getServerStatuses(): Record; /** * Get the status of a specific server. * @param name The name of the server * @returns The status of the server */ getServerStatus(name: string): ServerStatus; /** * Start a server * @param serverType Type of server to start */ startServer(serverType: string): Promise; /** * Stop a server * @param serverType Type of server to stop */ stopServer(serverType: string): Promise; /** * Check if a server is running * @param serverType Type of server to check */ isServerRunning(serverType: string): boolean; /** * Connect to a server * @param serverType Type of server to connect to */ connectToServer(serverType: string): Promise; /** * Disconnect from a server * @param serverType Type of server to disconnect from */ disconnectFromServer(serverType: string): Promise; /** * Check if connected to a server * @param serverType Type of server to check */ isConnectedToServer(serverType: string): boolean; /** * Add an event listener for a specific event type. * @param eventType The type of event to listen for * @param callback The callback to invoke when the event occurs * @returns A function that removes the event listener when called */ on(eventType: T, callback: MCPToolkitEventCallback): () => void; /** * Remove all event listeners for a specific event type. * @param eventType The type of event to remove listeners for */ removeAllListeners(eventType?: MCPToolkitEventType): void; } /** * Toolkit interfaces module */ type index_ConnectionConfig = ConnectionConfig; type index_ConnectionEvent = ConnectionEvent; type index_ConnectionEventType = ConnectionEventType; declare const index_ConnectionEventType: typeof ConnectionEventType; type index_IMCPToolkit = IMCPToolkit; type index_LoggerConfig = LoggerConfig; type index_MCPToolkitConfig = MCPToolkitConfig; type index_MCPToolkitEvent = MCPToolkitEvent; type index_MCPToolkitEventCallback = MCPToolkitEventCallback; type index_MCPToolkitEventType = MCPToolkitEventType; type index_ResourceEvent = ResourceEvent; type index_ResourceEventType = ResourceEventType; declare const index_ResourceEventType: typeof ResourceEventType; type index_ResourceManagerConfig = ResourceManagerConfig; type index_ServerConfig = ServerConfig; type index_ServerEvent = ServerEvent; type index_ServerEventType = ServerEventType; declare const index_ServerEventType: typeof ServerEventType; type index_ToolEvent = ToolEvent; type index_ToolEventType = ToolEventType; declare const index_ToolEventType: typeof ToolEventType; type index_ToolExecutorConfig = ToolExecutorConfig; declare namespace index { export { index_ConnectionConfig as ConnectionConfig, index_ConnectionEvent as ConnectionEvent, index_ConnectionEventType as ConnectionEventType, index_IMCPToolkit as IMCPToolkit, index_LoggerConfig as LoggerConfig, index_MCPToolkitConfig as MCPToolkitConfig, index_MCPToolkitEvent as MCPToolkitEvent, index_MCPToolkitEventCallback as MCPToolkitEventCallback, index_MCPToolkitEventType as MCPToolkitEventType, index_ResourceEvent as ResourceEvent, index_ResourceEventType as ResourceEventType, index_ResourceManagerConfig as ResourceManagerConfig, index_ServerConfig as ServerConfig, index_ServerEvent as ServerEvent, index_ServerEventType as ServerEventType, index_ToolEvent as ToolEvent, index_ToolEventType as ToolEventType, index_ToolExecutorConfig as ToolExecutorConfig, }; } /** * Configure the dependency injection container * @param setupFn Function to register dependencies * @param skipDefaults Whether to skip registering default services * @returns The configured DI container */ declare function configureDI(setupFn?: (container: DependencyContainer) => void, skipDefaults?: boolean): DependencyContainer; /** * Reset the DI container (mainly for testing) * @returns void */ declare function resetDI(): void; /** * Get the global DI container * @returns The global DI container */ declare function getDI(): DependencyContainer; /** * Register default services in the DI container * @param container The DI container */ declare function registerDefaultServices(container: DependencyContainer): void; /** * Default values used throughout the MCP toolkit */ declare const DEFAULT_SERVER_STARTUP_TIMEOUT = 30000; declare const DEFAULT_SERVER_RESTART_DELAY = 1000; declare const DEFAULT_SERVER_MAX_RESTARTS = 3; declare const DEFAULT_CONNECTION_REQUEST_TIMEOUT = 10000; declare const DEFAULT_CONNECTION_RECONNECT_DELAY = 1000; declare const DEFAULT_CONNECTION_MAX_RECONNECTS = 3; declare const DEFAULT_TOOL_EXECUTION_TIMEOUT = 30000; declare const DEFAULT_TOOL_RETRY_DELAY = 500; declare const DEFAULT_TOOL_MAX_RETRIES = 2; declare const DEFAULT_TOOL_CACHE_TTL = 60000; declare const DEFAULT_RESOURCE_CACHE_SIZE: number; declare const DEFAULT_RESOURCE_CACHE_TTL = 300000; declare const PROTOCOL_VERSION = "1.0"; declare const DEFAULT_REQUEST_ID_PREFIX = "mcp-"; /** * Service for handling errors in the MCP toolkit */ declare class ErrorService implements IErrorService { private logger; /** * Map of error handlers by error code */ private errorHandlers; /** * Map of recovery strategies by error code */ private recoveryStrategies; /** * Constructor * @param logger Logger service */ constructor(logger: ILoggerService); /** * Register an error handler for a specific error code * @param code Error code * @param handler Function to handle the error */ registerErrorHandler(code: ErrorCode, handler: (error: MCPToolkitError) => Promise): void; /** * Register a recovery strategy for a specific error code * @param code Error code * @param strategy Recovery strategy */ registerRecoveryStrategy(code: ErrorCode, strategy: IErrorRecoveryStrategy): void; /** * Handle an error * @param error Error to handle */ handleError(error: MCPToolkitError): Promise; /** * Get a recovery strategy for an error * @param error Error to get recovery strategy for */ getRecoveryStrategy(error: MCPToolkitError): IErrorRecoveryStrategy; /** * Log an error * @param error Error to log */ logError(error: MCPToolkitError): void; /** * Create a specific error * @param type Type of error * @param code Error code * @param message Error message * @param context Additional context */ createError(type: 'server' | 'connection' | 'tool' | 'resource' | 'protocol' | 'configuration' | 'transport', code: ErrorCode, message: string, context?: ErrorData): MCPToolkitError; } /** * Default recovery strategy with no recovery attempts */ declare const DEFAULT_RECOVERY_STRATEGY: IErrorRecoveryStrategy; /** * Recovery strategy for transient server errors */ declare const SERVER_RECOVERY_STRATEGY: IErrorRecoveryStrategy; /** * Recovery strategy for connection errors */ declare const CONNECTION_RECOVERY_STRATEGY: IErrorRecoveryStrategy; /** * Recovery strategy for transport errors */ declare const TRANSPORT_RECOVERY_STRATEGY: IErrorRecoveryStrategy; /** * Recovery strategy for tool execution errors */ declare const TOOL_RECOVERY_STRATEGY: IErrorRecoveryStrategy; /** * Recovery strategy for resource errors */ declare const RESOURCE_RECOVERY_STRATEGY: IErrorRecoveryStrategy; /** * Default recovery strategies by error code */ declare const DEFAULT_RECOVERY_STRATEGIES: Record; /** * Implementation of server manager service */ declare class ServerManagerService implements IServerManagerService { private errorService; private logger; private readonly transportFactory; private config?; [key: string]: any; /** * Map of server names to their configurations */ private servers; /** * Map of server names to their process handlers */ private processes; /** * Map of server names to their status */ private statuses; /** * Event emitter for server events */ private eventEmitter; /** * Default configuration for all servers */ private defaultConfig; /** * Constructor * @param errorService Error service * @param logger Logger service * @param transportFactory Transport factory * @param config Server manager configuration */ constructor(errorService: IErrorService, logger: ILoggerService, transportFactory: ITransportFactory, config?: ServerManagerConfig | undefined); /** * Register a server configuration * @param name Name of the server * @param config Server configuration */ registerServer(name: string, config: ServerConfig$1): void; /** * Start a server * @param name Name of the server */ startServer(name: string): Promise; /** * Stop a server * @param name Name of the server */ stopServer(name: string): Promise; /** * Restart a server * @param name Name of the server */ restartServer(name: string): Promise; /** * Get the status of a server * @param name Name of the server */ getServerStatus(name: string): ServerStatus; /** * Check if a server is running * @param name Name of the server */ isServerRunning(name: string): boolean; /** * Start all registered servers */ startAllServers(): Promise; /** * Stop all registered servers */ stopAllServers(): Promise; /** * Get the status of all registered servers */ getAllServerStatuses(): Record; /** * Listen for server events * @param listener Function to be called when an event occurs */ onServerEvent(listener: (event: ServerEvent$1) => void): void; /** * Get the process for a server * @param name Name of the server */ getServerProcess(name: string): ChildProcess | undefined; /** * Spawn a server process * @param name Name of the server * @param config Server configuration */ private spawnServerProcess; /** * Set up event handlers for a server process * @param name Name of the server * @param childProcess Process to set up handlers for * @param config Server configuration */ private setupProcessEventHandlers; /** * Wait for a server to be ready * @param name Name of the server * @param childProcess Server process * @param timeout Timeout in milliseconds */ private waitForServerReady; /** * Kill a server process * @param name Name of the server */ private killProcess; /** * Update the status of a server * @param name Name of the server * @param status New status */ private updateServerStatus; /** * Emit a server event * @param serverName Name of the server * @param type Type of event * @param data Additional data */ private emitServerEvent; /** * Validate a server configuration * @param name Server name * @param config Configuration to validate */ private validateServerConfig; /** * Get server metadata * @param name Server name * @param key Metadata key */ private getServerMetadata; /** * Set server metadata * @param name Server name * @param key Metadata key * @param value Metadata value */ private setServerMetadata; /** * Get or create server metadata store * @param name Server name */ private getServerMetadataStore; } /** * Implementation of a server connection */ declare class ServerConnection implements IServerConnection { private errorService; private logger; /** * The name of the server this connection is for */ private serverName; /** * The transport to use for communication */ private transport; /** * Whether the connection is currently established */ private connected; /** * Map of request ID to pending request */ private pendingRequests; /** * Map of method name to request handler */ private requestHandlers; /** * Map of method name to notification handler */ private notificationHandlers; /** * Counter for generating request IDs */ private nextRequestId; /** * Event emitter for connection events */ private eventEmitter; /** * Interval for checking request timeouts */ private timeoutCheckInterval; /** * Connection configuration */ private config; /** * Timer for auto-reconnect */ private reconnectTimer; /** * Number of reconnection attempts */ private reconnectAttempts; /** * Whether the connection is currently attempting to reconnect */ private isReconnecting; /** * Whether the connection has been manually disconnected */ private manuallyDisconnected; /** * Whether the message listener is active */ private messageListenerActive; /** * Constructor * @param serverName Name of the server * @param transport Transport to use for communication * @param config Connection configuration * @param errorService Error service * @param logger Logger service */ constructor(serverName: string, transport: ITransport, config: ConnectionConfig$1, errorService: IErrorService, logger: ILoggerService); /** * Connect to the server */ connect(): Promise; /** * Disconnect from the server */ disconnect(): Promise; /** * Check if connected to the server */ isConnected(): boolean; /** * Send a request to the server and await a response * @param method The method name * @param params The parameters for the method * @param resultSchema Optional schema for validating the response */ request(method: string, params?: any, resultSchema?: Schema): Promise; /** * Send a notification to the server (no response expected) * @param method The method name * @param params The parameters for the method */ notify(method: string, params?: any): Promise; /** * Register a handler for server requests * @param method The method name to handle * @param handler The handler function */ handleRequest(method: string, handler: (params: any) => Promise): void; /** * Register a handler for server notifications * @param method The method name to handle * @param handler The handler function */ handleNotification(method: string, handler: (params: any) => Promise): void; /** * Listen for connection events * @param listener Function to be called when an event occurs */ onConnectionEvent(listener: (event: ConnectionEvent$1) => void): void; /** * Start listening for messages from the server */ private startMessageListener; /** * Process a message from the server * @param message The message to process */ private processMessage; /** * Handle a response from the server * @param response The response to handle */ private handleResponse; /** * Handle a request from the server * @param request The request to handle */ private handleServerRequest; /** * Handle a notification from the server * @param notification The notification to handle */ private handleServerNotification; /** * Send a response to the server * @param id The request ID * @param result The result to send * @param error The error to send */ private sendResponse; /** * Generate a unique request ID */ private generateRequestId; /** * Handle a timeout for a request * @param id The request ID */ private handleRequestTimeout; /** * Start checking for request timeouts */ private startTimeoutChecking; /** * Check for request timeouts */ private checkRequestTimeouts; /** * Handle transport closure */ private handleTransportClosure; /** * Reject all pending requests * @param reason The reason for rejection */ private rejectAllPendingRequests; /** * Schedule a reconnection attempt */ private scheduleReconnect; /** * Cancel a pending reconnection attempt */ private cancelReconnect; /** * Emit a connection event * @param type Type of event * @param data Additional data */ private emitEvent; /** * Handle a message from the server * @param message The message to handle */ private handleMessage; /** * Method alias for stopReconnectionTimer to maintain backward compatibility * This is the same as cancelReconnect */ private stopReconnectionTimer; /** * Fix errors in the connect method */ private handleConnectError; /** * Fix type errors in other error handling methods */ private handleTransportError; private handleProtocolError; /** * Fix the request method error handling */ private handleRequestError; /** * Fix the rest of unknown error types */ private logError; } /** * Implementation of the connection manager service */ declare class ConnectionManagerService implements IConnectionManagerService { private serverManager; private transportFactory; private errorService; private logger; private config?; /** * Map of server names to connections */ private connections; /** * Event emitter for connection events */ private eventEmitter; /** * Default connection configuration */ private defaultConfig; /** * Constructor * @param serverManager Server manager service * @param transportFactory Transport factory * @param errorService Error service * @param logger Logger service * @param config Connection manager configuration */ constructor(serverManager: IServerManagerService, transportFactory: ITransportFactory, errorService: IErrorService, logger: ILoggerService, config?: ConnectionManagerConfig | undefined); /** * Get connection for a server * @param serverName Name of the server */ getConnection(serverName: string): IServerConnection; /** * Connect to a server * @param serverName Name of the server */ connect(serverName: string): Promise; /** * Disconnect from a server * @param serverName Name of the server */ disconnect(serverName: string): Promise; /** * Check if connected to a server * @param serverName Name of the server */ isConnected(serverName: string): boolean; /** * Connect to all available servers */ connectAll(): Promise; /** * Disconnect from all servers */ disconnectAll(): Promise; /** * Get a list of all server connections */ getAllConnections(): Record; /** * Listen for connection events * @param listener Function to be called when an event occurs */ onConnectionEvent(listener: (event: ConnectionEvent$1) => void): void; /** * Create a new connection to a server * @param serverName Name of the server */ private createConnection; /** * Create a transport for a server * @param serverName Name of the server * @param config Connection configuration */ private createTransport; /** * Get the process for a server * @param serverName Name of the server */ private getServerProcess; /** * Get the connection configuration for a server * @param serverName Name of the server */ private getConnectionConfig; /** * Set up handlers for server events */ private setupServerEventHandlers; /** * Handle a server event * @param event The server event */ private handleServerEvent; } /** * Interface for the tool executor service */ interface IToolExecutorService extends IToolExecution, IToolDiscovery { /** * Listen for tool events * @param listener Function to be called when an event occurs */ onToolEvent(listener: (event: ToolEvent$1) => void): void; } /** * Implementation of the tool executor service */ declare class ToolExecutorService implements IToolExecutorService { private connectionManager; private errorService; private logger; private config?; /** * Cache of available tools */ private toolsCache; /** * Cache of tool results */ private resultCache; /** * Event emitter for tool events */ private eventEmitter; /** * Default options for tool execution */ private defaultOptions; /** * Constructor * @param connectionManager Connection manager service * @param errorService Error service * @param logger Logger service * @param config Tool executor configuration */ constructor(connectionManager: IConnectionManagerService, errorService: IErrorService, logger: ILoggerService, config?: ToolExecutorConfig$1 | undefined); /** * Get all available tools across all servers */ getAvailableTools(): Promise; /** * Get tools for a specific server * @param serverName The name of the server */ getServerTools(serverName: string): Promise; /** * Listen for changes in available tools * @param listener Function to be called when tools change */ onToolsChanged(listener: (tools: Tool[]) => void): void; /** * Execute a tool call * @param call The tool call to execute */ executeToolCall(call: ToolCall): Promise; /** * Execute multiple tool calls in parallel * @param calls The tool calls to execute */ executeToolCalls(calls: ToolCall[]): Promise; /** * Execute a tool call with specific options * @param call The tool call to execute * @param options Options for execution */ executeToolCallWithOptions(call: ToolCall, options: ExecutionOptions): Promise; /** * Listen for tool events * @param listener Function to be called when an event occurs */ onToolEvent(listener: (event: ToolEvent$1) => void): void; /** * Find the server that provides a specific tool * @param toolName Name of the tool to find */ private findToolServer; /** * Execute a tool call with retry logic * @param serverName Name of the server * @param toolName Name of the tool * @param parameters Parameters for the tool * @param options Execution options */ private executeWithRetry; /** * Generate a cache key for a tool call * @param call The tool call */ private generateCacheKey; /** * Emit a tool event * @param type Type of the event * @param toolName Name of the tool * @param serverName Name of the server * @param data Additional event data */ private emitToolEvent; /** * Sleep for a specified duration * @param ms Number of milliseconds to sleep */ private sleep; /** * Execute a tool on a specific server * @param serverName Name of the server * @param toolName Name of the tool * @param parameters Parameters for the tool * @internal Used for direct server execution */ private executeToolOnServer; } /** * Implementation of the resource management interface */ declare class ResourceManagerService implements IResourceManagement { private connectionManager; private errorService; private logger; private serverResources; private resourceContentCache; private currentCacheSize; private eventEmitter; private resourceUpdateListeners; private config; constructor(connectionManager: IConnectionManagerService, errorService: IErrorService, logger: ILoggerService, config?: ResourceManagerConfig$1); /** * Get resources from a specific server * @param serverName The name of the server */ getServerResources(serverName: string): Promise; /** * List all available resources across all servers */ listResources(): Promise; /** * Extract server name from a resource URI * @param uri The URI of the resource */ private extractServerName; /** * Read a resource by its URI * @param uri The URI of the resource to read */ readResource(uri: string): Promise; /** * Subscribe to resource updates * @param uri The URI of the resource to subscribe to */ subscribeToResource(uri: string): Promise; /** * Unsubscribe from resource updates * @param uri The URI of the resource to unsubscribe from */ unsubscribeFromResource(uri: string): Promise; /** * Handler for resource updated notifications * @param notification The notification message * @internal Used when handling resource events from the server */ private handleResourceUpdated; /** * Register a listener for resource update events * @param listener Function to be called when a resource is updated */ onResourceUpdated(listener: (uri: string) => void): void; /** * Notify all registered listeners about a resource update * @param uri The URI of the updated resource */ private notifyResourceUpdated; /** * Register a listener for resource events * @param listener Function to be called when a resource event occurs */ onResourceEvent(listener: (event: ResourceEvent$1) => void): void; /** * Emit a resource event * @param event The event to emit */ private emitResourceEvent; /** * Handle connection events * @param event The connection event */ private handleConnectionEvent; /** * Clear resources for a specific server * @param serverName The name of the server */ private clearServerResources; /** * Clear resource content cache for a specific server * @param serverName The name of the server */ private clearServerResourceContent; /** * Get cached resource content * @param uri The URI of the resource */ private getCachedResourceContent; /** * Cache resource content * @param content The resource content to cache */ private cacheResourceContent; /** * Enforce cache size limit by removing oldest entries first * @param requiredSize Additional size needed in the cache */ private enforceCacheSize; /** * Invalidate resource cache for a specific URI * @param uri The URI of the resource */ private invalidateResourceCache; /** * Estimate the size of resource content in bytes * @param content The resource content */ private estimateContentSize; } /** * Implementation of the MCPToolkit service */ declare class MCPToolkitService implements IMCPToolkit { private readonly serverManager; private readonly connectionManager; private readonly toolExecutor; private readonly toolDiscovery; private readonly resourceManager; private readonly errorService; private config; private readonly eventEmitter; private readonly eventUnsubscribers; private isStarted; /** * Create a new MCPToolkit instance */ constructor(serverManager: IServerManagerService, connectionManager: IConnectionManagerService, toolExecutor: IToolExecution, toolDiscovery: IToolDiscovery, resourceManager: IResourceManagement, errorService: IErrorService); /** * Configure the toolkit */ configure(config: MCPToolkitConfig): void; /** * Start the toolkit */ start(): Promise; /** * Stop the toolkit */ stop(): Promise; /** * Get all available tools */ getAvailableTools(): Promise; /** * Execute a tool call */ executeToolCall(call: ToolCall): Promise; /** * Execute multiple tool calls */ executeToolCalls(calls: ToolCall[]): Promise; /** * Execute a tool call with options */ executeToolCallWithOptions(call: ToolCall, options: ExecutionOptions): Promise; /** * List all resources */ listResources(): Promise; /** * Read a resource */ readResource(uri: string): Promise; /** * Subscribe to resource updates */ subscribeToResource(uri: string): Promise; /** * Unsubscribe from resource updates */ unsubscribeFromResource(uri: string): Promise; /** * Get all server statuses */ getServerStatuses(): Record; /** * Get a specific server status */ getServerStatus(name: string): ServerStatus; /** * Start a server * @param serverType Type of server to start */ startServer(serverType: string): Promise; /** * Stop a server * @param serverType Type of server to stop */ stopServer(serverType: string): Promise; /** * Check if a server is running * @param serverType Type of server to check */ isServerRunning(serverType: string): boolean; /** * Restart a server * @param serverType Type of server to restart */ restartServer(serverType: string): Promise; /** * Connect to a server * @param serverType Type of server to connect to */ connectToServer(serverType: string): Promise; /** * Disconnect from a server * @param serverType Type of server to disconnect from */ disconnectFromServer(serverType: string): Promise; /** * Check if connected to a server * @param serverType Type of server to check */ isConnectedToServer(serverType: string): boolean; /** * Add an event listener */ on(eventType: T, callback: MCPToolkitEventCallback): () => void; /** * Remove all event listeners */ removeAllListeners(eventType?: MCPToolkitEventType): void; /** * Alias for isConnectedToServer * @deprecated Use isConnectedToServer instead */ isConnected(serverName: string): boolean; /** * Alias for on with ServerStatusChange event type * @deprecated Use on method instead */ onServerStatusChange(callback: (serverName: string, status: ServerStatus) => void): () => void; /** * Set up event listeners for all services */ private setupEventListeners; /** * Clean up all event listeners */ private cleanupEventListeners; /** * Emit an event */ private emitEvent; /** * Ensure the toolkit is configured */ private ensureConfigured; /** * Ensure the toolkit is started */ private ensureStarted; private getServerForToolCall; } /** * Configuration validation for the MCPToolkit. */ /** * Server configuration schema */ declare const serverConfigSchema: z.ZodObject<{ command: z.ZodString; args: z.ZodOptional>; env: z.ZodOptional>; cwd: z.ZodOptional; startupTimeout: z.ZodOptional; autoRestart: z.ZodOptional; maxRestarts: z.ZodOptional; restartDelay: z.ZodOptional; }, "strip", z.ZodTypeAny, { command: string; args?: string[] | undefined; env?: Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }, { command: string; args?: string[] | undefined; env?: Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }>; /** * Connection configuration schema */ declare const connectionConfigSchema: z.ZodEffects; stdio: z.ZodOptional; }, "strip", z.ZodTypeAny, { inherit?: boolean | undefined; }, { inherit?: boolean | undefined; }>>; sse: z.ZodOptional>; }, "strip", z.ZodTypeAny, { baseUrl: string; headers?: Record | undefined; }, { baseUrl: string; headers?: Record | undefined; }>>; requestTimeout: z.ZodOptional; autoReconnect: z.ZodOptional; maxReconnects: z.ZodOptional; reconnectDelay: z.ZodOptional; }, "strip", z.ZodTypeAny, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }>, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }>; /** * Tool executor configuration schema */ declare const toolExecutorConfigSchema: z.ZodObject<{ maxRetries: z.ZodOptional; retryDelay: z.ZodOptional; useExponentialBackoff: z.ZodOptional; executionTimeout: z.ZodOptional; cacheResults: z.ZodOptional; cacheTtl: z.ZodOptional; }, "strip", z.ZodTypeAny, { executionTimeout?: number | undefined; maxRetries?: number | undefined; retryDelay?: number | undefined; cacheResults?: boolean | undefined; useExponentialBackoff?: boolean | undefined; cacheTtl?: number | undefined; }, { executionTimeout?: number | undefined; maxRetries?: number | undefined; retryDelay?: number | undefined; cacheResults?: boolean | undefined; useExponentialBackoff?: boolean | undefined; cacheTtl?: number | undefined; }>; /** * Resource manager configuration schema */ declare const resourceManagerConfigSchema: z.ZodObject<{ maxCacheSize: z.ZodOptional; cacheTtl: z.ZodOptional; }, "strip", z.ZodTypeAny, { cacheTtl?: number | undefined; maxCacheSize?: number | undefined; }, { cacheTtl?: number | undefined; maxCacheSize?: number | undefined; }>; /** * Logger configuration schema */ declare const loggerConfigSchema: z.ZodObject<{ level: z.ZodOptional>; console: z.ZodOptional; file: z.ZodOptional; }, "strip", z.ZodTypeAny, { level?: "debug" | "info" | "warn" | "error" | undefined; console?: boolean | undefined; file?: string | undefined; }, { level?: "debug" | "info" | "warn" | "error" | undefined; console?: boolean | undefined; file?: string | undefined; }>; /** * Main toolkit configuration schema */ declare const mcpToolkitConfigSchema: z.ZodObject<{ servers: z.ZodEffects>; env: z.ZodOptional>; cwd: z.ZodOptional; startupTimeout: z.ZodOptional; autoRestart: z.ZodOptional; maxRestarts: z.ZodOptional; restartDelay: z.ZodOptional; }, "strip", z.ZodTypeAny, { command: string; args?: string[] | undefined; env?: Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }, { command: string; args?: string[] | undefined; env?: Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }>>, Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }>, Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }>>; connections: z.ZodOptional; stdio: z.ZodOptional; }, "strip", z.ZodTypeAny, { inherit?: boolean | undefined; }, { inherit?: boolean | undefined; }>>; sse: z.ZodOptional>; }, "strip", z.ZodTypeAny, { baseUrl: string; headers?: Record | undefined; }, { baseUrl: string; headers?: Record | undefined; }>>; requestTimeout: z.ZodOptional; autoReconnect: z.ZodOptional; maxReconnects: z.ZodOptional; reconnectDelay: z.ZodOptional; }, "strip", z.ZodTypeAny, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }>, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }>>; overrides: z.ZodOptional; stdio: z.ZodOptional; }, "strip", z.ZodTypeAny, { inherit?: boolean | undefined; }, { inherit?: boolean | undefined; }>>; sse: z.ZodOptional>; }, "strip", z.ZodTypeAny, { baseUrl: string; headers?: Record | undefined; }, { baseUrl: string; headers?: Record | undefined; }>>; requestTimeout: z.ZodOptional; autoReconnect: z.ZodOptional; maxReconnects: z.ZodOptional; reconnectDelay: z.ZodOptional; }, "strip", z.ZodTypeAny, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }>, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }, { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }>>>; }, "strip", z.ZodTypeAny, { defaults?: { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; } | undefined; overrides?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }> | undefined; }, { defaults?: { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; } | undefined; overrides?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }> | undefined; }>>; toolExecutor: z.ZodOptional; retryDelay: z.ZodOptional; useExponentialBackoff: z.ZodOptional; executionTimeout: z.ZodOptional; cacheResults: z.ZodOptional; cacheTtl: z.ZodOptional; }, "strip", z.ZodTypeAny, { executionTimeout?: number | undefined; maxRetries?: number | undefined; retryDelay?: number | undefined; cacheResults?: boolean | undefined; useExponentialBackoff?: boolean | undefined; cacheTtl?: number | undefined; }, { executionTimeout?: number | undefined; maxRetries?: number | undefined; retryDelay?: number | undefined; cacheResults?: boolean | undefined; useExponentialBackoff?: boolean | undefined; cacheTtl?: number | undefined; }>>; resourceManager: z.ZodOptional; cacheTtl: z.ZodOptional; }, "strip", z.ZodTypeAny, { cacheTtl?: number | undefined; maxCacheSize?: number | undefined; }, { cacheTtl?: number | undefined; maxCacheSize?: number | undefined; }>>; logger: z.ZodOptional>; console: z.ZodOptional; file: z.ZodOptional; }, "strip", z.ZodTypeAny, { level?: "debug" | "info" | "warn" | "error" | undefined; console?: boolean | undefined; file?: string | undefined; }, { level?: "debug" | "info" | "warn" | "error" | undefined; console?: boolean | undefined; file?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { servers: Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }>; logger?: { level?: "debug" | "info" | "warn" | "error" | undefined; console?: boolean | undefined; file?: string | undefined; } | undefined; connections?: { defaults?: { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; } | undefined; overrides?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }> | undefined; } | undefined; toolExecutor?: { executionTimeout?: number | undefined; maxRetries?: number | undefined; retryDelay?: number | undefined; cacheResults?: boolean | undefined; useExponentialBackoff?: boolean | undefined; cacheTtl?: number | undefined; } | undefined; resourceManager?: { cacheTtl?: number | undefined; maxCacheSize?: number | undefined; } | undefined; }, { servers: Record | undefined; cwd?: string | undefined; startupTimeout?: number | undefined; autoRestart?: boolean | undefined; maxRestarts?: number | undefined; restartDelay?: number | undefined; }>; logger?: { level?: "debug" | "info" | "warn" | "error" | undefined; console?: boolean | undefined; file?: string | undefined; } | undefined; connections?: { defaults?: { transportType: "stdio" | "sse"; stdio?: { inherit?: boolean | undefined; } | undefined; sse?: { baseUrl: string; headers?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; } | undefined; overrides?: Record | undefined; } | undefined; maxReconnects?: number | undefined; requestTimeout?: number | undefined; autoReconnect?: boolean | undefined; reconnectDelay?: number | undefined; }> | undefined; } | undefined; toolExecutor?: { executionTimeout?: number | undefined; maxRetries?: number | undefined; retryDelay?: number | undefined; cacheResults?: boolean | undefined; useExponentialBackoff?: boolean | undefined; cacheTtl?: number | undefined; } | undefined; resourceManager?: { cacheTtl?: number | undefined; maxCacheSize?: number | undefined; } | undefined; }>; /** * Validate toolkit configuration */ declare function validateConfig(config: unknown): void; /** * Type guard for the toolkit configuration */ declare function isValidConfig(config: unknown): config is z.infer; /** * Default configuration for the MCPToolkit. */ /** * Default connection configuration */ declare const DEFAULT_CONNECTION_CONFIG: { transportType: "stdio"; stdio: { inherit: boolean; }; requestTimeout: number; autoReconnect: boolean; maxReconnects: number; reconnectDelay: number; }; /** * Default tool executor configuration */ declare const DEFAULT_TOOL_EXECUTOR_CONFIG: { maxRetries: number; retryDelay: number; useExponentialBackoff: boolean; executionTimeout: number; cacheResults: boolean; cacheTtl: number; }; /** * Default resource manager configuration */ declare const DEFAULT_RESOURCE_MANAGER_CONFIG: { maxCacheSize: number; cacheTtl: number; }; /** * Default logger configuration */ declare const DEFAULT_LOGGER_CONFIG: { level: "info"; console: boolean; file: undefined; }; /** * Default toolkit configuration (without servers) */ declare const DEFAULT_CONFIG: Omit; /** * Get default configuration with the specified servers */ declare function getDefaultConfig(servers: MCPToolkitConfig$1['servers']): MCPToolkitConfig$1; /** * Merge user configuration with defaults */ declare function mergeWithDefaults(config: MCPToolkitConfig$1): MCPToolkitConfig$1; /** * Extract server-specific configuration by merging defaults with overrides */ declare function getServerConfig(config: MCPToolkitConfig$1, serverName: string): { server: MCPToolkitConfig$1['servers'][string]; connection: ConnectionConfig$1; }; /** * Factory for creating transports */ declare class TransportFactory implements ITransportFactory { private errorService; private logger; /** * Constructor * @param errorService Error service for handling errors * @param logger Logger service */ constructor(errorService: IErrorService, logger: ILoggerService); /** * Create a transport for communicating with a server * @param type Type of transport to create * @param config Configuration for the transport */ createTransport(type: 'stdio' | 'sse', config: StdioTransportConfig | SSETransportConfig): ITransport; /** * Create a stdio transport * @param config Configuration for the stdio transport */ private createStdioTransport; /** * Create an SSE transport * @param config Configuration for the SSE transport */ private createSSETransport; } /** * Register all services in the DI container * @param config MCP toolkit configuration */ declare function registerServices(config: MCPToolkitConfig$1): void; /** * Reset container (useful for testing) */ declare function resetContainer(): void; /** * Public-facing MCPToolkit class * This serves as the main entry point for the MCP Toolkit */ declare class MCPToolkit implements IMCPToolkit { private toolkit; /** * Create a new MCPToolkit instance * @param config Optional configuration */ constructor(config?: MCPToolkitConfig); /** * Configure the toolkit * @param config Configuration to apply */ configure(config: MCPToolkitConfig): void; /** * Start the toolkit */ start(): Promise; /** * Stop the toolkit */ stop(): Promise; /** * Start a server * @param serverType Type of server to start */ startServer(serverType: string): Promise; /** * Stop a server * @param serverType Type of server to stop */ stopServer(serverType: string): Promise; /** * Check if a server is running * @param serverType Type of server to check */ isServerRunning(serverType: string): boolean; /** * Connect to a server * @param serverType Type of server to connect to */ connectToServer(serverType: string): Promise; /** * Disconnect from a server * @param serverType Type of server to disconnect from */ disconnectFromServer(serverType: string): Promise; /** * Check if connected to a server * @param serverType Type of server to check */ isConnectedToServer(serverType: string): boolean; /** * Get all available tools */ getAvailableTools(): Promise; /** * Execute a tool call * @param call Tool call to execute */ executeToolCall(call: ToolCall): Promise; /** * Execute multiple tool calls in parallel * @param calls Tool calls to execute */ executeToolCalls(calls: ToolCall[]): Promise; /** * Execute a tool call with specific options * @param call Tool call to execute * @param options Execution options */ executeToolCallWithOptions(call: ToolCall, options: ExecutionOptions): Promise; /** * List all available resources */ listResources(): Promise; /** * Get the content of a resource * @param uri URI of the resource */ readResource(uri: string): Promise; /** * Subscribe to resource updates * @param uri URI of the resource */ subscribeToResource(uri: string): Promise; /** * Unsubscribe from resource updates * @param uri URI of the resource */ unsubscribeFromResource(uri: string): Promise; /** * Get the status of all servers */ getServerStatuses(): Record; /** * Get the status of a specific server * @param name Name of the server */ getServerStatus(name: string): ServerStatus; /** * Listen for toolkit events * @param eventType Type of event to listen for * @param callback Callback to execute when the event occurs */ on(eventType: T, callback: MCPToolkitEventCallback): () => void; /** * Remove all event listeners * @param eventType Optional event type to remove listeners for */ removeAllListeners(eventType?: MCPToolkitEventType): void; } declare const VERSION = "0.1.0"; declare const PACKAGE_INFO: { name: string; version: string; }; export { BaseTransport, CONNECTION_RECOVERY_STRATEGY, CallToolRequest, CloseRequest, ConfigurationError, ConnectionConfig$1 as ConnectionConfig, ConnectionError, ConnectionEvent$1 as ConnectionEvent, ConnectionEventType$1 as ConnectionEventType, ConnectionManagerConfig, ConnectionManagerService, DEFAULT_CONFIG, DEFAULT_CONNECTION_CONFIG, DEFAULT_CONNECTION_MAX_RECONNECTS, DEFAULT_CONNECTION_RECONNECT_DELAY, DEFAULT_CONNECTION_REQUEST_TIMEOUT, DEFAULT_LOGGER_CONFIG, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_RECOVERY_STRATEGY, DEFAULT_REQUEST_ID_PREFIX, DEFAULT_RESOURCE_CACHE_SIZE, DEFAULT_RESOURCE_CACHE_TTL, DEFAULT_RESOURCE_MANAGER_CONFIG, DEFAULT_SERVER_MAX_RESTARTS, DEFAULT_SERVER_RESTART_DELAY, DEFAULT_SERVER_STARTUP_TIMEOUT, DEFAULT_TOOL_CACHE_TTL, DEFAULT_TOOL_EXECUTION_TIMEOUT, DEFAULT_TOOL_EXECUTOR_CONFIG, DEFAULT_TOOL_MAX_RETRIES, DEFAULT_TOOL_RETRY_DELAY, ErrorCode, ErrorData, ErrorService, ExecutionOptions, IConnectionManagerService, IErrorRecoveryStrategy, IErrorService, ILoggerService, IResourceManagement, IServerConnection, IServerLifecycle, IServerManagerService, IToolDiscovery, IToolExecution, IToolExecutorService, ITransport, ITransportFactory, InitializeRequest, InitializedNotification, ListResourcesRequest, ListToolsRequest, LoggerConfig$1 as LoggerConfig, MCPToolkit, MCPToolkitConfig$1 as MCPToolkitConfig, MCPToolkitError, MCPToolkitService, Notification, PACKAGE_INFO, PROTOCOL_VERSION, ProtocolError, RESOURCE_RECOVERY_STRATEGY, ReadResourceRequest, Request, Resource, ResourceContent, ResourceError, ResourceEvent$1 as ResourceEvent, ResourceEventType$1 as ResourceEventType, ResourceManagerConfig$1 as ResourceManagerConfig, ResourceManagerService, ResourceUpdatedNotification, Response, SERVER_RECOVERY_STRATEGY, SSETransport, SSETransportConfig, ServerConfig$1 as ServerConfig, ServerConnection, ServerError, ServerEvent$1 as ServerEvent, ServerEventType$1 as ServerEventType, ServerManagerConfig, ServerManagerService, ServerStatus, ServerType, StdioTransport, StdioTransportConfig, SubscribeResourceRequest, TOOL_RECOVERY_STRATEGY, TRANSPORT_RECOVERY_STRATEGY, Tool, ToolCall, ToolError, ToolEvent$1 as ToolEvent, ToolEventType$1 as ToolEventType, ToolExecutorConfig$1 as ToolExecutorConfig, ToolExecutorService, ToolResult, index as ToolkitInterfaces, TransportError, TransportFactory, VERSION, configureDI, connectionConfigSchema, getDI, getDefaultConfig, getServerConfig, isValidConfig, loggerConfigSchema, mcpToolkitConfigSchema, mergeWithDefaults, registerDefaultServices, registerServices, resetContainer, resetDI, resourceManagerConfigSchema, serverConfigSchema, toolExecutorConfigSchema, validateConfig };