LibreChat/api/server/services/Config/mcp.js
Danny Avila 1bccc2bc18
📡 fix: Refresh MCP Tools After List-Changed Notifications (#14686)
* fix(mcp): handle dynamic tool list changes

Co-authored-by: Pascal Garber <pascal@artandcode.studio>

* test(mcp): fix CI validation

* fix(mcp): keep dynamic tool catalogs live

* fix(mcp): harden dynamic catalog lifecycle

* test(mcp): use typed startup connection

* test(mcp): isolate dynamic e2e fixtures

* fix(mcp): refresh tools after reconnect

* fix(mcp): close dynamic catalog cache gaps

* test(mcp): update OAuth connection mocks

* fix(mcp): preserve app snapshot ownership

* style(mcp): sort connection imports

* fix(mcp): close review race conditions

* fix(mcp): preserve cache ownership edges

* fix(mcp): harden recovery lifecycle

* fix(mcp): guard tool-less app refresh

* fix(mcp): fence distributed cache races

* fix(mcp): retire stale connection state

* fix(mcp): keep tool snapshots authoritative

* fix(mcp): fence stale app tool publications

* style(mcp): sort repository test imports

* test(mcp): mock empty startup publication

* fix(mcp): preserve app publication generations

* fix(mcp): harden publication recovery races

* fix(mcp): address tool catalogs by runtime config

* fix(mcp): load scoped catalogs for assistant writes

* fix(mcp): harden catalog publication recovery

* fix(mcp): serialize forced connection replacement

* fix(mcp): serialize ordinary creation with replacements

* fix(mcp): harden catalog fallback boundaries

* fix(mcp): close lifecycle fencing gaps

* fix(mcp): preserve catalog authority on failures

* fix(mcp): compensate failed catalog mutations

* fix(mcp): fence catalog refresh ordering

* style(mcp): sort agent loader imports

* fix(mcp): cancel stale connection creation

* fix(mcp): fence catalog coordination

* fix(mcp): close catalog race windows

* fix(mcp): harden cross-pod catalog fencing

* fix(mcp): close catalog lifecycle edges

* style(mcp): sort assistant imports

* fix(mcp): reject stale recovery authority

* fix(mcp): restore static catalog on every startup

* fix(mcp): order app catalog publications

* style(mcp): sort catalog revision imports

* fix(mcp): separate catalog allocation and commit fences

---------

Co-authored-by: Pascal Garber <pascal@artandcode.studio>
2026-08-08 13:50:21 -04:00

43 lines
1.2 KiB
JavaScript

const { createMCPToolCacheService, MCPServersRegistry } = require('@librechat/api');
const {
getCachedTools,
updateCachedGlobalTools,
setCachedToolsWithinGlobalLock,
getCachedAppServerTools,
setCachedAppServerTools,
setCachedToolsIfCurrent,
getMCPToolsCacheGeneration,
renewMCPToolsCacheGeneration,
getNextAppToolsPublicationRevision,
} = require('./getCachedTools');
const {
syncStaticTools,
mergeAppTools,
cacheMCPServerTools,
updateMCPServerTools,
getMCPServerTools,
} = createMCPToolCacheService({
getCachedTools,
updateCachedGlobalTools,
setCachedTools: setCachedToolsWithinGlobalLock,
setCachedToolsIfCurrent,
getCachedAppServerTools,
setCachedAppServerTools,
getServerConfig: (serverName, userId) =>
MCPServersRegistry.getInstance().getServerConfig(serverName, userId),
getAllServerConfigs: () => MCPServersRegistry.getInstance().getAllServerConfigs(),
isAppServerConfig: (serverName, effectiveConfig) =>
MCPServersRegistry.getInstance().isAppServerConfig(serverName, effectiveConfig),
});
module.exports = {
syncStaticTools,
mergeAppTools,
getMCPServerTools,
cacheMCPServerTools,
updateMCPServerTools,
getMCPToolsCacheGeneration,
renewMCPToolsCacheGeneration,
getNextAppToolsPublicationRevision,
};