diff --git a/ui/litellm-dashboard/src/components/playground/chat_ui/ChatUI.tsx b/ui/litellm-dashboard/src/components/playground/chat_ui/ChatUI.tsx index 9918040ef64..f747b5b2599 100644 --- a/ui/litellm-dashboard/src/components/playground/chat_ui/ChatUI.tsx +++ b/ui/litellm-dashboard/src/components/playground/chat_ui/ChatUI.tsx @@ -84,10 +84,7 @@ interface ChatUIProps { }; } -const MCP_SUPPORTED_ENDPOINTS = new Set([ - EndpointType.CHAT, - EndpointType.RESPONSES, -]); +const MCP_SUPPORTED_ENDPOINTS = new Set([EndpointType.CHAT, EndpointType.RESPONSES]); const ChatUI: React.FC = ({ accessToken, @@ -131,7 +128,7 @@ const ChatUI: React.FC = ({ }); const [apiKey, setApiKey] = useState(() => sessionStorage.getItem("apiKey") || ""); const [customProxyBaseUrl, setCustomProxyBaseUrl] = useState( - () => sessionStorage.getItem("customProxyBaseUrl") || "" + () => sessionStorage.getItem("customProxyBaseUrl") || "", ); const [inputMessage, setInputMessage] = useState(""); const [chatHistory, setChatHistory] = useState(() => { @@ -215,7 +212,7 @@ const ChatUI: React.FC = ({ const [temperature, setTemperature] = useState(1.0); const [maxTokens, setMaxTokens] = useState(2048); const [useAdvancedParams, setUseAdvancedParams] = useState(false); - + // Code Interpreter state (using custom hook) const codeInterpreter = useCodeInterpreter(); @@ -244,16 +241,15 @@ const ChatUI: React.FC = ({ try { const response = await listMCPTools(userApiKey, serverId); - setServerToolsMap(prev => ({ + setServerToolsMap((prev) => ({ ...prev, - [serverId]: response.tools || [] + [serverId]: response.tools || [], })); } catch (error) { console.error(`Error fetching tools for server ${serverId}:`, error); } }; - useEffect(() => { if (isGetCodeModalVisible) { const code = generateCodeSnippet({ @@ -1007,7 +1003,7 @@ const ChatUI: React.FC = ({ traceId, selectedVectorStores.length > 0 ? selectedVectorStores : undefined, selectedGuardrails.length > 0 ? selectedGuardrails : undefined, - selectedMCPTools, // Pass the selected tools array + selectedMCPServers, // Pass the selected tools array customProxyBaseUrl || undefined, ); } else if (endpointType === EndpointType.EMBEDDINGS) { @@ -1205,9 +1201,7 @@ const ChatUI: React.FC = ({ icon={ApiOutlined} /> {customProxyBaseUrl && ( - - API calls will be sent to: {customProxyBaseUrl} - + API calls will be sent to: {customProxyBaseUrl} )} @@ -1382,7 +1376,11 @@ const ChatUI: React.FC = ({ optionLabelProp="label" > {agentInfo.map((agent) => ( - +
{agent.agent_name || agent.agent_id} {agent.agent_card_params?.description && ( @@ -1416,10 +1414,7 @@ const ChatUI: React.FC = ({
MCP Servers - + @@ -1435,15 +1430,15 @@ const ChatUI: React.FC = ({ } else { setSelectedMCPServers(value); // Clean up tool restrictions for removed servers - setMCPServerToolRestrictions(prev => { + setMCPServerToolRestrictions((prev) => { const updated = { ...prev }; - Object.keys(updated).forEach(serverId => { + Object.keys(updated).forEach((serverId) => { if (!value.includes(serverId)) delete updated[serverId]; }); return updated; }); // Load tools for newly selected servers - value.forEach(serverId => { + value.forEach((serverId) => { if (!serverToolsMap[serverId]) { loadServerTools(serverId); } @@ -1474,12 +1469,8 @@ const ChatUI: React.FC = ({ disabled={selectedMCPServers.includes("__all__")} >
- - {server.alias || server.server_name || server.server_id} - - {server.description && ( - {server.description} - )} + {server.alias || server.server_name || server.server_id} + {server.description && {server.description}}
))} @@ -1489,40 +1480,40 @@ const ChatUI: React.FC = ({ {selectedMCPServers.length > 0 && !selectedMCPServers.includes("__all__") && MCP_SUPPORTED_ENDPOINTS.has(endpointType as EndpointType) && ( -
- {selectedMCPServers.map(serverId => { - const server = mcpServers.find(s => s.server_id === serverId); - const tools = serverToolsMap[serverId] || []; - if (tools.length === 0) return null; +
+ {selectedMCPServers.map((serverId) => { + const server = mcpServers.find((s) => s.server_id === serverId); + const tools = serverToolsMap[serverId] || []; + if (tools.length === 0) return null; - return ( -
- - Limit tools for {server?.alias || server?.server_name || serverId}: - - { + setMCPServerToolRestrictions((prev) => ({ + ...prev, + [serverId]: selectedTools, + })); + }} + options={tools.map((tool) => ({ + value: tool.name, + label: tool.name, + }))} + maxTagCount={2} + /> +
+ ); + })} +
+ )}
@@ -2073,7 +2064,13 @@ const ChatUI: React.FC = ({ )} {/* Quick Code Interpreter toggle for Responses */} {endpointType === EndpointType.RESPONSES && ( - +