Repository navigation
🔤 feat: Sort MCP Tools by Name in the Agent Editor - #17349
Open
VascoSch92 wants to merge 3 commits into
Open
VascoSch92 wants to merge 3 commits into
VascoSch92 wants to merge 3 commits into
Conversation
The agent editor listed an MCP server's tools in whatever order the server's tools/list returned them, which makes a specific tool hard to find on servers with many tools. Sort the checklist by the displayed name, case-insensitively and with numeric collation (tool2 before tool10). Select all, deselect all and the bulk toggles read the same array, so they follow the new order. Related to LibreChat-AI#16428
VascoSch92
marked this pull request as ready for review
October 22, 2026 20:11
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
When you open an MCP server in the agent editor (Agent Builder → Add tools → the server's gear), the tool checklist comes up in whatever order the server's
tools/listreturned. That order is picked by whoever wrote the server, so on a server with lots of tools you end up reading the whole list to find the one you want. This PR sorts the checklist by the tool's display name, ignoring case and comparing numbers by value (export_page_2beforeexport_page_10), which is what the issue asks for.This one was really interesting for me. It looks like a one-liner, but following the list back from
/api/mcp/toolsthroughAgentPanelContextandmcpServersMapintoMcpSection, and checking that Select all and the bulk toggles all read from the same array, taught me a lot about how the agent tools panel fits together.Related to #16428
How it works
I copy the array before sorting so the query data behind
mcpServersMapdoesn't get mutated. Everything else in the section (select all, deselect all, the bulk defer/programmatic/background/intent toggles) reads this sametoolsarray, so it follows the new order with no other changes. The one side effect is that "Select all" now writes the tool ids intoagent.toolsin sorted order, which doesn't change anything at runtime. Nothing the model or the API sees is different.Type of change
Testing
I ran LibreChat locally (backend plus the Vite dev client, MongoDB 7 in Docker) with a small stdio MCP server that registers eight tools in a deliberately scrambled order, with mixed case and numeric suffixes. Then I opened Agent Builder → Add tools → issue-tracker → gear and compared the checklist on
devand on this branch (screenshots below).Tested environments/configuration:
librechat.yamlAutomated tests:
lists tools by display name, ignoring case and comparing numbers by valuetoMcpSection.spec.tsx. It fails ondev(it gets the server's order back) and passes on this branch.{ tool_id, metadata: { name } }shape, since the sort readsmetadata.name.npx jest src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/McpSection.spec.tsx: 40/40 pass.npx jestinclient: 812 suites, 12,741 tests, all passing.npx tsc --noEmitinclientandnpm run static-checks -- --against origin/devare clean.Screenshots / recordings
Before
after
Risk / compatibility
None. Only the display order changes; saved agents and tool ids are untouched.
#16359 (sorting the MCP server lists) could reuse the same comparison, and I'm happy to pick that up next if it helps.
Checklist