🛡️ fix: Handle MCP Tool Cache Lookup Failures (#12910)

* Handle MCP tool cache lookup failures

* Harden MCP cached tool lookup

* Cover full MCP tool cache outage

* Guard MCP tool cache store lookup
This commit is contained in:
Danny Avila 2026-05-02 09:21:28 +09:00 committed by GitHub
parent 74307e6dcc
commit 5b5e2b0286
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 150 additions and 12 deletions

View file

@ -1,4 +1,5 @@
const { CacheKeys, Time } = require('librechat-data-provider');
const { logger } = require('@librechat/data-schemas');
const getLogStores = require('~/cache/getLogStores');
/**
@ -89,14 +90,13 @@ async function invalidateCachedTools(options = {}) {
* @returns {Promise<LCAvailableTools|null>} The available tools for the server
*/
async function getMCPServerTools(userId, serverName) {
const cache = getLogStores(CacheKeys.TOOL_CACHE);
const serverTools = await cache.get(ToolCacheKeys.MCP_SERVER(userId, serverName));
if (serverTools) {
return serverTools;
try {
const cache = getLogStores(CacheKeys.TOOL_CACHE);
return (await cache.get(ToolCacheKeys.MCP_SERVER(userId, serverName))) || null;
} catch (error) {
logger.error(`[getMCPServerTools] Error fetching cached tools for ${serverName}:`, error);
return null;
}
return null;
}
module.exports = {