From f99ea619da713d557f5cc04e31e0cf3e249b2b0d Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Fri, 20 Feb 2026 13:57:58 +0530 Subject: [PATCH] Add search bar for enabling and calling tool --- .../mcp_tools/mcp_tool_configuration.tsx | 38 ++++++++++-- .../src/components/mcp_tools/mcp_tools.tsx | 61 +++++++++++++++---- ui/litellm-dashboard/tsconfig.json | 2 +- 3 files changed, 83 insertions(+), 18 deletions(-) diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tool_configuration.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tool_configuration.tsx index 8cdc67030c..84967f7a83 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tool_configuration.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tool_configuration.tsx @@ -1,7 +1,7 @@ -import React, { useEffect, useRef } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { Card, Title, Text } from "@tremor/react"; -import { ToolOutlined, CheckCircleOutlined } from "@ant-design/icons"; -import { Badge, Spin, Checkbox } from "antd"; +import { ToolOutlined, CheckCircleOutlined, SearchOutlined } from "@ant-design/icons"; +import { Badge, Spin, Checkbox, Input } from "antd"; import { useTestMCPConnection } from "../../hooks/useTestMCPConnection"; interface MCPToolConfigurationProps { @@ -22,6 +22,7 @@ const MCPToolConfiguration: React.FC = ({ onAllowedToolsChange, }) => { const previousToolsLengthRef = useRef(0); + const [toolSearchTerm, setToolSearchTerm] = useState(""); const { tools, isLoadingTools, toolsError, canFetchTools } = useTestMCPConnection({ accessToken, @@ -30,6 +31,15 @@ const MCPToolConfiguration: React.FC = ({ enabled: true, }); + // Filter tools based on search term + const filteredTools = tools.filter((tool) => { + const searchLower = toolSearchTerm.toLowerCase(); + return ( + tool.name.toLowerCase().includes(searchLower) || + (tool.description && tool.description.toLowerCase().includes(searchLower)) + ); + }); + // Auto-select tools when tools are first loaded useEffect(() => { // Only auto-select if: @@ -168,9 +178,26 @@ const MCPToolConfiguration: React.FC = ({ + {/* Search bar */} + } + value={toolSearchTerm} + onChange={(e) => setToolSearchTerm(e.target.value)} + allowClear + className="rounded-lg" + size="large" + /> + {/* Tool list with checkboxes */}
- {tools.map((tool, index) => ( + {filteredTools.length === 0 ? ( +
+ + No tools found matching "{toolSearchTerm}" +
+ ) : ( + filteredTools.map((tool, index) => (
= ({
- ))} + )) + )} )} diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx index 7ee1e64a22..1cc505ec02 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx @@ -5,7 +5,8 @@ import { MCPTool, MCPToolsViewerProps, MCPContent, CallMCPToolResponse } from ". import { listMCPTools, callMCPTool } from "../networking"; import { Card, Title, Text } from "@tremor/react"; -import { RobotOutlined, ToolOutlined } from "@ant-design/icons"; +import { RobotOutlined, ToolOutlined, SearchOutlined } from "@ant-design/icons"; +import { Input } from "antd"; const MCPToolsViewer = ({ serverId, @@ -18,6 +19,7 @@ const MCPToolsViewer = ({ const [selectedTool, setSelectedTool] = useState(null); const [toolResult, setToolResult] = useState(null); const [toolError, setToolError] = useState(null); + const [toolSearchTerm, setToolSearchTerm] = useState(""); // Query to fetch MCP tools const { @@ -58,6 +60,16 @@ const MCPToolsViewer = ({ const toolsData = mcpToolsResponse?.tools || []; + // Filter tools based on search term + const filteredTools = toolsData.filter((tool: MCPTool) => { + const searchLower = toolSearchTerm.toLowerCase(); + return ( + tool.name.toLowerCase().includes(searchLower) || + (tool.description && tool.description.toLowerCase().includes(searchLower)) || + (tool.mcp_info.server_name && tool.mcp_info.server_name.toLowerCase().includes(searchLower)) + ); + }); + return (
@@ -78,6 +90,21 @@ const MCPToolsViewer = ({ )} + {/* Search Bar */} + {toolsData.length > 0 && ( +
+ } + value={toolSearchTerm} + onChange={(e) => setToolSearchTerm(e.target.value)} + allowClear + className="rounded-lg" + size="middle" + /> +
+ )} + {/* Loading State */} {isLoadingTools && (
@@ -116,15 +143,23 @@ const MCPToolsViewer = ({ {/* Tools List */} {!isLoadingTools && !mcpToolsResponse?.error && toolsData.length > 0 && ( -
- {toolsData.map((tool: MCPTool) => ( + <> + {filteredTools.length === 0 ? ( +
+ +

No tools found

+

No tools match "{toolSearchTerm}"

+
+ ) : ( +
+ {filteredTools.map((tool: MCPTool) => (
)}
- ))} -
+ ))} +
+ )} + )}
diff --git a/ui/litellm-dashboard/tsconfig.json b/ui/litellm-dashboard/tsconfig.json index d24bdd340f..5b0352feb9 100644 --- a/ui/litellm-dashboard/tsconfig.json +++ b/ui/litellm-dashboard/tsconfig.json @@ -14,7 +14,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "react-jsx", + "jsx": "preserve", "incremental": true, "plugins": [ {