refactor: replace getMCPAuthMap with getUserMCPAuthMap and remove unused getCustomConfig file

This commit is contained in:
Danny Avila 2025-08-19 00:46:38 -04:00
parent 71a14517cd
commit c0d6404385
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
3 changed files with 5 additions and 37 deletions

View file

@ -8,6 +8,7 @@ const {
Tokenizer, Tokenizer,
checkAccess, checkAccess,
hasCustomUserVars, hasCustomUserVars,
getUserMCPAuthMap,
memoryInstructions, memoryInstructions,
formatContentStrings, formatContentStrings,
createMemoryProcessor, createMemoryProcessor,
@ -40,10 +41,10 @@ const {
deleteMemory, deleteMemory,
setMemory, setMemory,
} = require('~/models'); } = require('~/models');
const { checkCapability, getMCPAuthMap, getAppConfig } = require('~/server/services/Config');
const { addCacheControl, createContextHandlers } = require('~/app/clients/prompts'); const { addCacheControl, createContextHandlers } = require('~/app/clients/prompts');
const { initializeAgent } = require('~/server/services/Endpoints/agents/agent'); const { initializeAgent } = require('~/server/services/Endpoints/agents/agent');
const { spendTokens, spendStructuredTokens } = require('~/models/spendTokens'); const { spendTokens, spendStructuredTokens } = require('~/models/spendTokens');
const { checkCapability, getAppConfig } = require('~/server/services/Config');
const { encodeAndFormat } = require('~/server/services/Files/images/encode'); const { encodeAndFormat } = require('~/server/services/Files/images/encode');
const { getProviderConfig } = require('~/server/services/Endpoints'); const { getProviderConfig } = require('~/server/services/Endpoints');
const BaseClient = require('~/app/clients/BaseClient'); const BaseClient = require('~/app/clients/BaseClient');
@ -913,10 +914,10 @@ class AgentClient extends BaseClient {
} }
try { try {
if (hasCustomUserVars(appConfig)) { if (agent.tools?.length && hasCustomUserVars(appConfig)) {
config.configurable.userMCPAuthMap = await getMCPAuthMap({ config.configurable.userMCPAuthMap = await getUserMCPAuthMap({
tools: agent.tools,
userId: this.options.req.user.id, userId: this.options.req.user.id,
tools: agent.tools,
findPluginAuthsByKeys, findPluginAuthsByKeys,
}); });
} }

View file

@ -1,31 +0,0 @@
const { logger } = require('@librechat/data-schemas');
const { getUserMCPAuthMap } = require('@librechat/api');
/**
* @param {Object} params
* @param {string} params.userId
* @param {GenericTool[]} [params.tools]
* @param {import('@librechat/data-schemas').PluginAuthMethods['findPluginAuthsByKeys']} params.findPluginAuthsByKeys
* @returns {Promise<Record<string, Record<string, string>> | undefined>}
*/
async function getMCPAuthMap({ userId, tools, findPluginAuthsByKeys }) {
try {
if (!tools || tools.length === 0) {
return;
}
return await getUserMCPAuthMap({
tools,
userId,
findPluginAuthsByKeys,
});
} catch (err) {
logger.error(
`[api/server/controllers/agents/client.js #chatCompletion] Error getting custom user vars for agent`,
err,
);
}
}
module.exports = {
getMCPAuthMap,
};

View file

@ -1,7 +1,6 @@
const appConfig = require('./app'); const appConfig = require('./app');
const { config } = require('./EndpointService'); const { config } = require('./EndpointService');
const getCachedTools = require('./getCachedTools'); const getCachedTools = require('./getCachedTools');
const getCustomConfig = require('./getCustomConfig');
const loadCustomConfig = require('./loadCustomConfig'); const loadCustomConfig = require('./loadCustomConfig');
const loadConfigModels = require('./loadConfigModels'); const loadConfigModels = require('./loadConfigModels');
const loadDefaultModels = require('./loadDefaultModels'); const loadDefaultModels = require('./loadDefaultModels');
@ -18,6 +17,5 @@ module.exports = {
loadAsyncEndpoints, loadAsyncEndpoints,
...appConfig, ...appConfig,
...getCachedTools, ...getCachedTools,
...getCustomConfig,
...getEndpointsConfig, ...getEndpointsConfig,
}; };