Fix MCP server search in playground

- 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: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-03-05 01:09:16 +00:00
parent 28fe9fabae
commit 7fb71d70be
3 changed files with 58 additions and 1 deletions

View file

@ -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();
}
}
});
});

View file

@ -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 && (

View file

@ -14,7 +14,7 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{