mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-09-02 03:52:45 +00:00
* fix: stabilize MCP OAuth readiness across pods * fix: harden MCP readiness review findings * fix: resolve CI type check and terminal OAuth polling * fix: address MCP OAuth readiness review * fix: align MCP OAuth readiness state * test: stabilize MCP OAuth readiness assertion * fix: reject stale MCP OAuth callbacks * fix: close distributed MCP OAuth readiness gaps * style: sort Redis MCP test imports * fix: preserve MCP OAuth polling across rolling pods * fix: finalize distributed MCP OAuth readiness * fix: preserve runtime-detected MCP OAuth * fix: report runtime MCP OAuth readiness * fix: preserve live MCP OAuth classification * style: sort MCP connection imports
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
const { EventSource } = require('eventsource');
|
|
const { Time } = require('librechat-data-provider');
|
|
const {
|
|
mcpConfig,
|
|
MCPManager,
|
|
FlowStateManager,
|
|
MCPServersRegistry,
|
|
OAuthReconnectionManager,
|
|
} = require('@librechat/api');
|
|
|
|
global.EventSource = EventSource;
|
|
|
|
/** @type {FlowStateManager} */
|
|
let flowManager = null;
|
|
/** @type {FlowStateManager} */
|
|
let actionFlowManager = null;
|
|
|
|
/**
|
|
* Flow manager for MCP OAuth flows. Uses the longer MCP OAuth TTL so the auth
|
|
* button and flow state outlive the user-completion window.
|
|
* @param {Keyv} flowsCache
|
|
* @returns {FlowStateManager}
|
|
*/
|
|
function getFlowStateManager(flowsCache) {
|
|
if (!flowManager) {
|
|
flowManager = new FlowStateManager(flowsCache, {
|
|
ttl: mcpConfig.OAUTH_FLOW_TTL,
|
|
monitorTimeout: mcpConfig.OAUTH_HANDLING_TIMEOUT,
|
|
retainedFailureTypes: ['mcp_oauth'],
|
|
});
|
|
}
|
|
return flowManager;
|
|
}
|
|
|
|
/**
|
|
* Flow manager for Action (custom tool) OAuth flows. Kept on the shorter TTL so an
|
|
* unclicked action login does not leave the tool call waiting for the MCP OAuth window.
|
|
* @param {Keyv} flowsCache
|
|
* @returns {FlowStateManager}
|
|
*/
|
|
function getActionFlowStateManager(flowsCache) {
|
|
if (!actionFlowManager) {
|
|
actionFlowManager = new FlowStateManager(flowsCache, {
|
|
ttl: Time.ONE_MINUTE * 3,
|
|
});
|
|
}
|
|
return actionFlowManager;
|
|
}
|
|
|
|
module.exports = {
|
|
createMCPServersRegistry: MCPServersRegistry.createInstance,
|
|
getMCPServersRegistry: MCPServersRegistry.getInstance,
|
|
createMCPManager: MCPManager.createInstance,
|
|
getMCPManager: MCPManager.getInstance,
|
|
getFlowStateManager,
|
|
getActionFlowStateManager,
|
|
createOAuthReconnectionManager: OAuthReconnectionManager.createInstance,
|
|
getOAuthReconnectionManager: OAuthReconnectionManager.getInstance,
|
|
};
|