You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ToolSearch server grouping crashes on inherited property names and blocks unrelated tools #607
A deferred MCP tool from a server named constructor prevents createToolSearch() from initializing, even if the intended search is for a different server. toString and hasOwnProperty produce the same error.
const{ createToolSearch }=require('@librechat/agents');consttoolRegistry=newMap([['weather_mcp_weather',{name: 'weather_mcp_weather',description: 'Read the weather forecast',defer_loading: true,}],['status_mcp_constructor',{name: 'status_mcp_constructor',description: 'Read service status',defer_loading: true,}],]);constsearch=createToolSearch({mode: 'local', toolRegistry });// TypeError: toolsByServer[serverName].push is not a function
Replacing constructor with status allows initialization and a weather search returns weather_mcp_weather with score 1. All input is local metadata; no MCP server, model API, or external tool is called.
Cause and expected behavior
getDeferredToolsListing() groups server names into {} and uses serverName in toolsByServer. Inherited properties count as existing groups, so .push() is attempted on a function. formatServerListing() uses the same pattern and fails when formatting a preview.
These identifiers should be ordinary server keys, or explicitly rejected as invalid configuration. They should not make an unrelated server's ranked search unavailable. Using dictionaries without inherited properties fixes both grouping sites without changing search or ranking.
Versions and downstream path
Reproduced on current SDK main 97b2db3a329c105c39a250fd39534701b6c9ddb1 and the published npm bundles @librechat/agents@4.0.4 and 4.0.1, with Node 24.11.1. Published-bundle checks used dependencies installed from the current SDK lockfile.
LibreChat current main locks 4.0.4, and LibreChat v0.8.8 locks 4.0.1. Both versions of api/server/services/ToolService.js call createToolSearch({ mode: 'local', toolRegistry }). This is an SDK-level local reproduction, not a full LibreChat deployment test or an estimate of affected users.
Regression and fix
Eleven native tests cover ordinary controls and the three server names across initialization, listing, and preview. On unpatched main, nine fail and the two controls pass. A two-line fix makes all eleven pass; the existing ToolSearch suite also passes (136 tests combined). TypeScript checking passes. Targeted ESLint reports no errors and the same unrelated warning at ToolSearch.ts:1352 on both baseline and patched code.
This came from an ARDGuard-motivated audit of whether one server's discovery state can suppress unrelated candidates. The reduced case and correction are entirely native to this SDK; ARDGuard is not required to reproduce or fix it.
Activity