mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 11:20:15 +01:00
refactor: remove getCustomConfig dependency and use getAppConfig in PluginController, multer, and MCP services
This commit is contained in:
parent
e0980e796a
commit
b0256510b5
3 changed files with 10 additions and 11 deletions
|
|
@ -6,7 +6,7 @@ const {
|
||||||
filterUniquePlugins,
|
filterUniquePlugins,
|
||||||
convertMCPToolsToPlugins,
|
convertMCPToolsToPlugins,
|
||||||
} = require('@librechat/api');
|
} = require('@librechat/api');
|
||||||
const { getCustomConfig, getCachedTools, getAppConfig } = require('~/server/services/Config');
|
const { getCachedTools, getAppConfig } = require('~/server/services/Config');
|
||||||
const { availableTools, toolkits } = require('~/app/clients/tools');
|
const { availableTools, toolkits } = require('~/app/clients/tools');
|
||||||
const { getMCPManager, getFlowStateManager } = require('~/config');
|
const { getMCPManager, getFlowStateManager } = require('~/config');
|
||||||
const { getLogStores } = require('~/cache');
|
const { getLogStores } = require('~/cache');
|
||||||
|
|
@ -102,7 +102,7 @@ function createGetServerTools() {
|
||||||
const getAvailableTools = async (req, res) => {
|
const getAvailableTools = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const userId = req.user?.id;
|
const userId = req.user?.id;
|
||||||
const customConfig = await getCustomConfig();
|
const appConfig = await getAppConfig();
|
||||||
const cache = getLogStores(CacheKeys.CONFIG_STORE);
|
const cache = getLogStores(CacheKeys.CONFIG_STORE);
|
||||||
const cachedToolsArray = await cache.get(CacheKeys.TOOLS);
|
const cachedToolsArray = await cache.get(CacheKeys.TOOLS);
|
||||||
const cachedUserTools = await getCachedTools({ userId });
|
const cachedUserTools = await getCachedTools({ userId });
|
||||||
|
|
@ -117,7 +117,7 @@ const getAvailableTools = async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let pluginManifest = availableTools;
|
let pluginManifest = availableTools;
|
||||||
if (customConfig?.mcpServers != null) {
|
if (appConfig?.mcpConfig != null) {
|
||||||
try {
|
try {
|
||||||
const flowsCache = getLogStores(CacheKeys.FLOWS);
|
const flowsCache = getLogStores(CacheKeys.FLOWS);
|
||||||
const flowManager = flowsCache ? getFlowStateManager(flowsCache) : null;
|
const flowManager = flowsCache ? getFlowStateManager(flowsCache) : null;
|
||||||
|
|
@ -172,7 +172,7 @@ const getAvailableTools = async (req, res) => {
|
||||||
|
|
||||||
const parts = plugin.pluginKey.split(Constants.mcp_delimiter);
|
const parts = plugin.pluginKey.split(Constants.mcp_delimiter);
|
||||||
const serverName = parts[parts.length - 1];
|
const serverName = parts[parts.length - 1];
|
||||||
const serverConfig = customConfig?.mcpServers?.[serverName];
|
const serverConfig = appConfig?.mcpConfig?.[serverName];
|
||||||
|
|
||||||
if (!serverConfig?.customUserVars) {
|
if (!serverConfig?.customUserVars) {
|
||||||
toolsOutput.push(toolToAdd);
|
toolsOutput.push(toolToAdd);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ const crypto = require('crypto');
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const { sanitizeFilename } = require('@librechat/api');
|
const { sanitizeFilename } = require('@librechat/api');
|
||||||
const { fileConfig: defaultFileConfig, mergeFileConfig } = require('librechat-data-provider');
|
const { fileConfig: defaultFileConfig, mergeFileConfig } = require('librechat-data-provider');
|
||||||
const { getCustomConfig, getAppConfig } = require('~/server/services/Config');
|
const { getAppConfig } = require('~/server/services/Config');
|
||||||
|
|
||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
destination: function (req, file, cb) {
|
destination: function (req, file, cb) {
|
||||||
|
|
@ -74,8 +74,8 @@ const createFileFilter = (customFileConfig) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const createMulterInstance = async () => {
|
const createMulterInstance = async () => {
|
||||||
const customConfig = await getCustomConfig();
|
const appConfig = await getAppConfig();
|
||||||
const fileConfig = mergeFileConfig(customConfig?.fileConfig);
|
const fileConfig = mergeFileConfig(appConfig?.fileConfig);
|
||||||
const fileFilter = createFileFilter(fileConfig);
|
const fileFilter = createFileFilter(fileConfig);
|
||||||
return multer({
|
return multer({
|
||||||
storage,
|
storage,
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ const {
|
||||||
} = require('librechat-data-provider');
|
} = require('librechat-data-provider');
|
||||||
const { findToken, createToken, updateToken } = require('~/models');
|
const { findToken, createToken, updateToken } = require('~/models');
|
||||||
const { getMCPManager, getFlowStateManager } = require('~/config');
|
const { getMCPManager, getFlowStateManager } = require('~/config');
|
||||||
const { getCachedTools, loadCustomConfig } = require('./Config');
|
const { getCachedTools, getAppConfig } = require('./Config');
|
||||||
const { getLogStores } = require('~/cache');
|
const { getLogStores } = require('~/cache');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -252,9 +252,8 @@ async function createMCPTool({ req, res, toolKey, provider: _provider }) {
|
||||||
* @returns {Object} Object containing mcpConfig, appConnections, userConnections, and oauthServers
|
* @returns {Object} Object containing mcpConfig, appConnections, userConnections, and oauthServers
|
||||||
*/
|
*/
|
||||||
async function getMCPSetupData(userId) {
|
async function getMCPSetupData(userId) {
|
||||||
const printConfig = false;
|
const config = await getAppConfig();
|
||||||
const config = await loadCustomConfig(printConfig);
|
const mcpConfig = config?.mcpConfig;
|
||||||
const mcpConfig = config?.mcpServers;
|
|
||||||
|
|
||||||
if (!mcpConfig) {
|
if (!mcpConfig) {
|
||||||
throw new Error('MCP config not found');
|
throw new Error('MCP config not found');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue