mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🔃 refactor: Simplify Plugin Deduplication and Clear Cache Post-MCP Initialization
- Replaced manual deduplication of tools with the dedicated `filterUniquePlugins` function for improved readability. - Added back cache clearing for tools after MCP initialization to ensure fresh data is used. - Removed unused exports from `PluginController.js` to clean up the codebase.
This commit is contained in:
parent
b6c8aabcac
commit
b39b60c012
2 changed files with 6 additions and 12 deletions
|
|
@ -146,11 +146,7 @@ const getAvailableTools = async (req, res) => {
|
|||
const userPlugins = convertMCPToolsToPlugins(cachedUserTools, customConfig);
|
||||
|
||||
if (cachedToolsArray && userPlugins) {
|
||||
const dedupedTools = [
|
||||
...new Map(
|
||||
[...userPlugins, ...cachedToolsArray].map((tool) => [tool.pluginKey, tool]),
|
||||
).values(),
|
||||
];
|
||||
const dedupedTools = filterUniquePlugins([...userPlugins, ...cachedToolsArray]);
|
||||
res.status(200).json(dedupedTools);
|
||||
return;
|
||||
}
|
||||
|
|
@ -230,9 +226,7 @@ const getAvailableTools = async (req, res) => {
|
|||
const finalTools = filterUniquePlugins(toolsOutput);
|
||||
await cache.set(CacheKeys.TOOLS, finalTools);
|
||||
|
||||
const dedupedTools = [
|
||||
...new Map([...userPlugins, ...finalTools].map((tool) => [tool.pluginKey, tool])).values(),
|
||||
];
|
||||
const dedupedTools = filterUniquePlugins([...userPlugins, ...finalTools]);
|
||||
|
||||
res.status(200).json(dedupedTools);
|
||||
} catch (error) {
|
||||
|
|
@ -295,8 +289,4 @@ function convertMCPToolsToPlugins(functionTools, customConfig) {
|
|||
module.exports = {
|
||||
getAvailableTools,
|
||||
getAvailablePluginsController,
|
||||
filterUniquePlugins,
|
||||
checkPluginAuth,
|
||||
createServerToolsCallback,
|
||||
createGetServerTools,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue