mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
Fix MCP server search in playground (#22824)
- Added showSearch prop to enable search input in MCP server selector - Added filterOption to search across server name, alias, server_id, and description - Search is case-insensitive and filters in real-time - Added test to verify search input appears when dropdown opens - Updated tsconfig.json with Next.js auto-configuration (jsx: react-jsx) Fixes issue where MCP server search was not working in the playground. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
parent
07cb6d5bec
commit
614a9fe9b7
3 changed files with 58 additions and 1 deletions
|
|
@ -373,4 +373,43 @@ describe("ChatUI", () => {
|
|||
const customProxyInput = screen.getByPlaceholderText("Optional: Enter custom proxy URL (e.g., http://localhost:5000)");
|
||||
expect(customProxyInput).toHaveValue(testProxyUrl);
|
||||
});
|
||||
|
||||
it("should enable search functionality for MCP server selector", async () => {
|
||||
render(
|
||||
<ChatUI
|
||||
accessToken="1234567890"
|
||||
token="1234567890"
|
||||
userRole="user"
|
||||
userID="1234567890"
|
||||
disabledPersonalKeyCreation={false}
|
||||
/>
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Test Key")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const mcpServersText = screen.queryByText("MCP Servers");
|
||||
expect(mcpServersText).toBeInTheDocument();
|
||||
|
||||
if (mcpServersText) {
|
||||
const selectContainer = mcpServersText.parentElement?.nextElementSibling;
|
||||
const selectElement = selectContainer?.querySelector(".ant-select-selector");
|
||||
expect(selectElement).toBeInTheDocument();
|
||||
|
||||
if (selectElement) {
|
||||
fireEvent.mouseDown(selectElement);
|
||||
|
||||
await waitFor(() => {
|
||||
const allServersOption = screen.queryByText("All MCP Servers");
|
||||
if (allServersOption) {
|
||||
expect(allServersOption).toBeInTheDocument();
|
||||
}
|
||||
});
|
||||
|
||||
const searchInput = document.querySelector(".ant-select-selection-search-input");
|
||||
expect(searchInput).toBeInTheDocument();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1636,9 +1636,27 @@ const ChatUI: React.FC<ChatUIProps> = ({
|
|||
loading={isLoadingMCPServers}
|
||||
className="mb-2"
|
||||
allowClear
|
||||
showSearch
|
||||
optionLabelProp="label"
|
||||
disabled={!MCP_SUPPORTED_ENDPOINTS.has(endpointType as EndpointType)}
|
||||
maxTagCount={endpointType === EndpointType.MCP ? 1 : "responsive"}
|
||||
filterOption={(input, option) => {
|
||||
if (option?.value === "__all__") {
|
||||
return "All MCP Servers".toLowerCase().includes(input.toLowerCase());
|
||||
}
|
||||
const server = mcpServers.find((s) => s.server_id === option?.value);
|
||||
if (!server) return false;
|
||||
const searchText = [
|
||||
server.server_name,
|
||||
server.alias,
|
||||
server.server_id,
|
||||
server.description,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ")
|
||||
.toLowerCase();
|
||||
return searchText.includes(input.toLowerCase());
|
||||
}}
|
||||
>
|
||||
{/* All MCP Servers option - hidden for MCP direct mode */}
|
||||
{endpointType !== EndpointType.MCP && (
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue