mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
* Refactor: MCPServersRegistry Singleton Pattern with Dependency Injection for DB methods consumption * refactor: error handling in MCP initialization and improve logging for MCPServersRegistry instance creation. - Added checks for mongoose instance in ServerConfigsDB constructor and refined error messages for clarity. - Reorder and use type imports --------- Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com> Co-authored-by: Danny Avila <danny@librechat.ai>
38 lines
1,009 B
JavaScript
38 lines
1,009 B
JavaScript
const { EventSource } = require('eventsource');
|
|
const { Time } = require('librechat-data-provider');
|
|
const {
|
|
MCPManager,
|
|
FlowStateManager,
|
|
MCPServersRegistry,
|
|
OAuthReconnectionManager,
|
|
} = require('@librechat/api');
|
|
const logger = require('./winston');
|
|
|
|
global.EventSource = EventSource;
|
|
|
|
/** @type {MCPManager} */
|
|
let flowManager = null;
|
|
|
|
/**
|
|
* @param {Keyv} flowsCache
|
|
* @returns {FlowStateManager}
|
|
*/
|
|
function getFlowStateManager(flowsCache) {
|
|
if (!flowManager) {
|
|
flowManager = new FlowStateManager(flowsCache, {
|
|
ttl: Time.ONE_MINUTE * 3,
|
|
});
|
|
}
|
|
return flowManager;
|
|
}
|
|
|
|
module.exports = {
|
|
logger,
|
|
createMCPServersRegistry: MCPServersRegistry.createInstance,
|
|
getMCPServersRegistry: MCPServersRegistry.getInstance,
|
|
createMCPManager: MCPManager.createInstance,
|
|
getMCPManager: MCPManager.getInstance,
|
|
getFlowStateManager,
|
|
createOAuthReconnectionManager: OAuthReconnectionManager.createInstance,
|
|
getOAuthReconnectionManager: OAuthReconnectionManager.getInstance,
|
|
};
|