/** * ProviderRegistry — lifecycle manager for MCP providers. * * Holds all registered Provider instances and orchestrates bulk operations: * tool/resource registration, readiness checks, and graceful shutdown. * * Design notes: * - Zero MCP SDK imports. Providers are wired through the ToolRegistrar port. * - shutdownAll() is intentionally fault-tolerant: every provider's shutdown() * is called regardless of earlier failures. Errors are collected and the * first is re-thrown after all shutdowns complete. * - readyAll() is non-throwing: per-provider errors are captured into the * returned ProviderReadyResult array so callers can inspect partial failures. */ import { Provider, ToolRegistrar } from './types.js'; /** * Result of a single provider's readiness check. * * When `ready` is true the `error` property is absent. * When `ready` is false the `error` property contains the rejection reason. */ export interface ProviderReadyResult { /** The provider's stable identifier. */ name: string; /** Whether the provider is ready to serve requests. */ ready: boolean; /** The error thrown by ready(), present only when ready is false. */ error?: Error; } /** * Registry that manages Provider instances and their lifecycle. * * Providers are stored by name. Registering a provider with an existing name * overwrites the previous registration (last-write-wins). */ export declare class ProviderRegistry { private readonly providers; /** * Register a provider by its name. * * If a provider with the same name is already registered it is overwritten. * * @param provider - The provider to register. */ register(provider: Provider): void; /** * Retrieve a provider by name. * * @param name - The provider's stable identifier. * @returns The provider, or undefined if no provider with that name exists. */ get(name: string): Provider | undefined; /** * Return a snapshot of all registered providers. * * The returned array is a new array; mutating it does not affect the registry. */ getAll(): Provider[]; /** * Register all tools and resources from every provider via the ToolRegistrar port. * * Called once at server startup before the first MCP client connects. * For each provider, registerTools() is called before registerResources(). * * @param registrar - The ToolRegistrar port implementation (never the raw McpServer). */ registerAll(registrar: ToolRegistrar): void; /** * Check the readiness of all registered providers. * * Does NOT throw on individual provider failures. Instead, every provider's * result — success or failure — is captured in the returned array. Callers * should inspect the results to decide whether to start the MCP server. * * @returns A result for each registered provider, in registration order. */ readyAll(): Promise; /** * Shut down all registered providers, collecting any errors along the way. * * Graceful degradation: every provider's shutdown() is called even if a * preceding provider throws. After all shutdowns complete, if any errors * were collected the first error is re-thrown so callers are notified of * partial failure. * * @throws The first error encountered during shutdown, if any. */ shutdownAll(): Promise; } //# sourceMappingURL=registry.d.ts.map