/** * Configuration Manager for MCP Hub Lite system. * * This class provides comprehensive configuration management capabilities including: * - Loading and parsing configuration from JSON files * - Runtime configuration updates with validation * - Server and server instance lifecycle management * - Automatic configuration persistence to disk * - Type conversion and compatibility handling (e.g., 'http' to 'streamable-http') * - Configuration change logging and tracking * * This is a thin wrapper around modular utilities for better maintainability. * * @example * ```typescript * // Get the config manager instance * const configManager = getConfigManager(); * * // Get all servers (v1.1 format) * const servers = configManager.getServers(); * * // Add a new server with template and default instance * await configManager.addServer('my-server', { * type: 'stdio', * command: 'npx my-mcp-server', * enabled: true * }); * ``` */ import { SystemConfigSchema, ServerInstanceSchema, ServerConfigSchema } from './config.schema.js'; import type { SystemConfig, ServerTemplate, ServerInstance, ServerConfig } from './config.schema.js'; export { ServerConfig, SystemConfig, ServerInstance, ServerTemplate, SystemConfigSchema, ServerConfigSchema, ServerInstanceSchema }; export declare class ConfigManager { private configPath; private config; constructor(configPath?: string); /** * Retrieves the current system configuration. * * @returns A deep copy of the current system configuration */ getConfig(): SystemConfig; /** * Retrieves all configured servers with their configurations (v1.1 format). * * @param sortByName - Whether to sort servers by name * @returns Array of server objects with name and config */ getServers(sortByName?: boolean): Array<{ name: string; config: ServerConfig; }>; /** * Retrieves a server configuration by name (v1.1 format). * * @param name - The name of the server to retrieve * @returns The server configuration (v1.1) or undefined if not found */ getServerByName(name: string): ServerConfig | undefined; /** * Retrieves all server instances for a specific server by name. * * @param name - The name of the server to retrieve instances for * @returns Array of server instances, or empty array if none exist */ getServerInstancesByName(name: string): ServerInstance[]; /** * Retrieves a specific server instance by index. * * @param name - The name of the server * @param index - The index of the instance * @returns The server instance or undefined if not found */ getServerInstanceByIndex(name: string, index: number): ServerInstance | undefined; /** * Adds multiple server configurations to the system in a single operation. * * @param servers - Array of server objects containing name and partial template configuration */ addServers(servers: Array<{ name: string; config: Partial; }>): Promise; /** * Adds a new server configuration to the system (v1.1 format). * Creates a template and a default instance. * * @param name - The unique name for the server * @param config - The server template configuration * @returns The complete server configuration (v1.1) */ addServer(name: string, config: Partial): Promise; /** * Adds a new server instance for the specified server. * * @param name - The name of the server to add an instance for * @param instance - The server instance configuration * @returns The validated and complete server instance configuration */ addServerInstance(name: string, instance: Partial): Promise; /** * Updates an existing server template configuration. * * @param name - The name of the server to update * @param updates - The partial template updates to apply * @returns The updated server configuration or null if not found */ updateServer(name: string, updates: Partial): Promise; /** * Updates an existing server configuration. * * @param name - The name of the server to update * @param updates - The partial server template updates to apply * @returns The updated server configuration or null if not found */ updateServerConfig(name: string, updates: Partial): Promise; /** * Updates an existing server instance configuration. * * @param name - The name of the server containing the instance to update * @param index - The index of the instance to update * @param updates - The partial instance updates to apply * @returns True if the instance was updated */ updateServerInstance(name: string, index: number, updates: Partial): Promise; /** * Removes a server configuration and all its instances from the system. * * @param name - The name of the server to remove * @returns True if the server was removed */ removeServer(name: string): Promise; /** * Removes a specific server instance from the system. * * @param name - The name of the server containing the instance to remove * @param index - The index of the instance to remove * @returns True if the instance was removed */ removeServerInstance(name: string, index: number): Promise; /** * Reassigns server instance indexes to be consecutive (0, 1, 2, ...). * * @param name - The name of the server to reassign indexes for * @returns True if the server exists and indexes were reassigned */ reassignInstanceIndexes(name: string): Promise; /** * Updates the entire system configuration with the provided partial configuration. * * @param newConfig - Partial system configuration containing updates */ updateConfig(newConfig: Partial): Promise; private persistConfig; /** * Synchronizes the in-memory configuration with the on-disk configuration file. */ syncConfig(): Promise; } /** * Get the config manager instance * In test environment, always creates a new instance to prevent test pollution */ export declare function getConfigManager(): ConfigManager; export declare const configManager: ConfigManager; //# sourceMappingURL=config-manager.d.ts.map