From 99a7ded2953e8cc85b7b2b83be896f0784deb802 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sun, 8 Nov 2026 00:34:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20fix:=20Show=20MCP=20Ser?= =?UTF-8?q?ver=20Titles=20in=20the=20Tool=20Library=20(#17883)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Show MCP Server Titles in the Tool Library and Search by Them Tool Library cards and agent tool rows showed the MCP server's config key because buildCatalog named each item after it, and search could only match that key. Name items from the resolved title in server.metadata, falling back to the key. Search also matches the key through the item id, as the MCP Servers panel does, so existing key searches keep working. * test: Cover MCP Server Titles in the Tool Library and Agent Tool Rows * test: Find the E2E Memory Card and Row by Title in MCP Specs --- .../Tools/items/__tests__/catalog.spec.ts | 20 ++++++ .../Tools/items/__tests__/filtering.spec.ts | 30 ++++++++ .../SidePanel/Agents/Tools/items/catalog.ts | 2 +- .../SidePanel/Agents/Tools/items/filtering.ts | 6 +- e2e/specs/mock/mcp.spec.ts | 10 ++- .../mock/scenarios/mcp-server-titles.spec.ts | 68 +++++++++++++++++++ .../mock/scenarios/verified-tool-mark.spec.ts | 6 +- 7 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 e2e/specs/mock/scenarios/mcp-server-titles.spec.ts diff --git a/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts b/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts index a131a52241..96e70c5e73 100644 --- a/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts +++ b/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts @@ -123,6 +123,26 @@ describe('buildCatalog', () => { } }); + test('names MCP items by their resolved title while keeping the key as id', () => { + const map = new Map(); + map.set('gh-tools-v2', { + serverName: 'gh-tools-v2', + isConfigured: true, + tools: [], + metadata: { name: 'GitHub', pluginKey: 'gh-tools-v2' }, + }); + const mcp = buildCatalog({ ...emptyInputs, mcpServersMap: map }).find((i) => i.kind === 'mcp'); + expect(mcp?.name).toBe('GitHub'); + expect(mcp?.id).toBe('gh-tools-v2'); + }); + + test('falls back to the server key when an MCP server has no metadata', () => { + const map = new Map(); + map.set('everything', { serverName: 'everything', isConfigured: true, tools: [] }); + const mcp = buildCatalog({ ...emptyInputs, mcpServersMap: map }).find((i) => i.kind === 'mcp'); + expect(mcp?.name).toBe('everything'); + }); + test('excludes consume-only MCP servers from the catalog', () => { const map = new Map(); map.set('attachable', { serverName: 'attachable', isConfigured: true, tools: [] }); diff --git a/client/src/components/SidePanel/Agents/Tools/items/__tests__/filtering.spec.ts b/client/src/components/SidePanel/Agents/Tools/items/__tests__/filtering.spec.ts index 7e87b3653a..1ded54ed13 100644 --- a/client/src/components/SidePanel/Agents/Tools/items/__tests__/filtering.spec.ts +++ b/client/src/components/SidePanel/Agents/Tools/items/__tests__/filtering.spec.ts @@ -43,6 +43,36 @@ describe('applyFilter', () => { expect(applyFilter(items, {}).length).toBe(4); }); + describe('MCP servers', () => { + const server: AgentItem = { + kind: 'mcp', + id: 'gh-tools-v2', + name: 'GitHub', + description: 'Repositories and issues', + iconKey: 'mcp', + server: { + serverName: 'gh-tools-v2', + tools: [], + isConfigured: true, + isConnected: false, + metadata: makePlugin({ name: 'GitHub', pluginKey: 'gh-tools-v2' }), + }, + toolCount: 0, + }; + + test('search matches the title', () => { + expect(applyFilter([server], { search: 'github' })).toEqual([server]); + }); + + test('search still matches the server key', () => { + expect(applyFilter([server], { search: 'gh-tools' })).toEqual([server]); + }); + + test('search does not match the id of other item kinds', () => { + expect(applyFilter(items, { search: 's2' })).toEqual([]); + }); + }); + test('search filters by name', () => { const result = applyFilter(items, { search: 'code' }); expect(result.map((i) => i.id)).toEqual(['execute_code', 's1']); diff --git a/client/src/components/SidePanel/Agents/Tools/items/catalog.ts b/client/src/components/SidePanel/Agents/Tools/items/catalog.ts index 0b2b62e593..a4f95b90a5 100644 --- a/client/src/components/SidePanel/Agents/Tools/items/catalog.ts +++ b/client/src/components/SidePanel/Agents/Tools/items/catalog.ts @@ -200,7 +200,7 @@ export function buildCatalog(inputs: BuildCatalogInputs): AgentItem[] { items.push({ kind: 'mcp', id: name, - name, + name: server.metadata?.name ?? name, description: server.metadata?.description ?? '', iconKey: 'mcp', server, diff --git a/client/src/components/SidePanel/Agents/Tools/items/filtering.ts b/client/src/components/SidePanel/Agents/Tools/items/filtering.ts index ede1e4e374..5f8aa6b950 100644 --- a/client/src/components/SidePanel/Agents/Tools/items/filtering.ts +++ b/client/src/components/SidePanel/Agents/Tools/items/filtering.ts @@ -25,7 +25,11 @@ function getCategory(item: AgentItem): string | undefined { function matchesSearch(item: AgentItem, search: string): boolean { if (!search) return true; const term = search.toLowerCase(); - return item.name.toLowerCase().includes(term) || item.description.toLowerCase().includes(term); + if (item.name.toLowerCase().includes(term) || item.description.toLowerCase().includes(term)) { + return true; + } + /** An MCP item's name is its title, so its config key is only reachable through the id. */ + return item.kind === 'mcp' && item.id.toLowerCase().includes(term); } function matchesKind(item: AgentItem, kind: ItemFilter['kind']): boolean { diff --git a/e2e/specs/mock/mcp.spec.ts b/e2e/specs/mock/mcp.spec.ts index bdce5b151b..9f74f0f26a 100644 --- a/e2e/specs/mock/mcp.spec.ts +++ b/e2e/specs/mock/mcp.spec.ts @@ -17,6 +17,8 @@ import { } from './helpers'; const MCP_SERVER_NAME = 'e2e-memory'; +/** The Tool Library and the agent's tool rows label the server by its config `title`. */ +const MCP_SERVER_TITLE = 'E2E Memory'; const MCP_TOOL_NAME = 'remember_fact'; const MCP_SERVER_TOOL_ID = `sys__server__sys_mcp_${MCP_SERVER_NAME}`; const MCP_TOOL_ID = `${MCP_TOOL_NAME}_mcp_${MCP_SERVER_NAME}`; @@ -65,7 +67,9 @@ async function addMCPServerTools(page: Page, form: Locator) { await expect(dialog).toBeVisible(); await dialog.getByRole('textbox', { name: 'Search tools…' }).fill(MCP_SERVER_NAME); - const serverCard = dialog.getByRole('button', { name: new RegExp(MCP_SERVER_NAME) }).first(); + const serverCard = dialog + .getByRole('button', { name: new RegExp(`^${MCP_SERVER_TITLE}\\b`) }) + .first(); await expect(serverCard).toBeVisible(); await serverCard.click(); @@ -73,11 +77,11 @@ async function addMCPServerTools(page: Page, form: Locator) { await dialog.getByRole('button', { name: /^Close( dialog)?$/ }).click(); await expect(dialog).toBeHidden(); - await expect(form.getByText(MCP_SERVER_NAME, { exact: true })).toBeVisible(); + await expect(form.getByText(MCP_SERVER_TITLE, { exact: true })).toBeVisible(); } async function expectSelectedMCPServerTools(form: Locator) { - await expect(form.getByText(MCP_SERVER_NAME, { exact: true })).toBeVisible(); + await expect(form.getByText(MCP_SERVER_TITLE, { exact: true })).toBeVisible(); } test.describe('agent builder MCP tools', () => { diff --git a/e2e/specs/mock/scenarios/mcp-server-titles.spec.ts b/e2e/specs/mock/scenarios/mcp-server-titles.spec.ts new file mode 100644 index 0000000000..5f103bc6a2 --- /dev/null +++ b/e2e/specs/mock/scenarios/mcp-server-titles.spec.ts @@ -0,0 +1,68 @@ +import { expect, test } from '@playwright/test'; +import type { Locator, Page } from '@playwright/test'; +import { openAgentBuilder } from '../agents.helpers'; + +/** `librechat.e2e.yaml` gives this server a `title` that differs from its key. */ +const SERVER_KEY = 'e2e-memory'; +const SERVER_TITLE = 'E2E Memory'; + +async function openToolLibrary(page: Page): Promise<{ form: Locator; library: Locator }> { + const form = await openAgentBuilder(page); + await form.getByRole('button', { name: 'Add tools', exact: true }).click(); + const library = page.getByRole('dialog', { name: 'Tool Library', exact: true }); + await expect(library).toBeVisible(); + return { form, library }; +} + +/** A card is a toggle button whose accessible name starts with the item's label. */ +function card(library: Locator, label: string): Locator { + return library.getByRole('button', { name: new RegExp(`^${label}`) }); +} + +function search(library: Locator): Locator { + return library.getByRole('textbox', { name: 'Search tools…' }); +} + +test.describe('MCP server titles in the Tool Library', () => { + test('@scenario:tool-library-card-shows-mcp-title an MCP card is labelled with the server title, not its key', async ({ + page, + }) => { + test.setTimeout(120000); + const { library } = await openToolLibrary(page); + + await expect(card(library, SERVER_TITLE)).toBeVisible(); + await expect(card(library, SERVER_KEY)).toHaveCount(0); + }); + + test('@scenario:tool-library-search-matches-mcp-title-and-key searching by the title or the key finds the server', async ({ + page, + }) => { + test.setTimeout(120000); + const { library } = await openToolLibrary(page); + + await search(library).fill(SERVER_TITLE); + await expect(card(library, SERVER_TITLE)).toBeVisible(); + + await search(library).fill(SERVER_KEY); + await expect(card(library, SERVER_TITLE)).toBeVisible(); + }); + + test('@scenario:agent-tool-row-shows-mcp-title an added MCP server is listed on the agent by its title', async ({ + page, + }) => { + test.setTimeout(120000); + const { form, library } = await openToolLibrary(page); + + const server = card(library, SERVER_TITLE); + await server.click(); + await expect(server).toHaveAttribute('aria-pressed', 'true'); + await library.getByRole('button', { name: 'Close', exact: true }).click(); + await expect(library).toBeHidden(); + + const row = form + .getByRole('listitem') + .filter({ has: page.getByText(SERVER_TITLE, { exact: true }) }); + await expect(row).toBeVisible(); + await expect(form.getByText(SERVER_KEY, { exact: true })).toHaveCount(0); + }); +}); diff --git a/e2e/specs/mock/scenarios/verified-tool-mark.spec.ts b/e2e/specs/mock/scenarios/verified-tool-mark.spec.ts index 3a60c4d54e..b5e4b354bc 100644 --- a/e2e/specs/mock/scenarios/verified-tool-mark.spec.ts +++ b/e2e/specs/mock/scenarios/verified-tool-mark.spec.ts @@ -4,6 +4,8 @@ import { openAgentBuilder } from '../agents.helpers'; import { NEW_CHAT_PATH, fetchJson, getAccessToken } from '../helpers'; const MCP_SERVER_NAME = 'e2e-memory'; +/** The Tool Library labels the server by its config `title`. */ +const MCP_SERVER_TITLE = 'E2E Memory'; const MCP_TOOL_ID = `remember_fact_mcp_${MCP_SERVER_NAME}`; /** WCAG 1.4.11: a graphical object owes 3:1 against what it sits on. */ const MARK_FLOOR = 3; @@ -179,7 +181,9 @@ test.describe('native tool verified mark', () => { const dialog = await openToolLibrary(page); await dialog.getByRole('textbox', { name: 'Search tools…' }).fill(MCP_SERVER_NAME); - const serverCard = dialog.getByRole('button', { name: new RegExp(MCP_SERVER_NAME) }).first(); + const serverCard = dialog + .getByRole('button', { name: new RegExp(`^${MCP_SERVER_TITLE}\\b`) }) + .first(); await expect(serverCard).toBeVisible(); await expect(serverCard.locator('svg[aria-label="Native"]')).toHaveCount(0); });