diff --git a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx index dba080a57d5..66241b6a12a 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx @@ -66,7 +66,7 @@ const CreateMCPServer: React.FC = ({ return (
+ +
+ ), + }, + { + header: "Server Name", + accessorKey: "alias", + cell: ({ getValue }) => {getValue() as string}, + }, + { + header: "Description", + accessorKey: "description", + cell: ({ getValue }) => {getValue() as string}, + }, + { + header: "Transport", + accessorKey: "transport", + cell: ({ getValue }) => {handleTransport(getValue() as string)}, + }, + { + header: "Auth Type", + accessorKey: "auth_type", + cell: ({ getValue }) => {handleAuth(getValue() as string)}, + }, + { + header: "Url", + accessorKey: "url", + cell: ({ getValue }) => ( +
+ + + {displayFriendlyUrl(getValue() as string)} + + +
+ ), + }, + { + header: "Created", + accessorKey: "created_at", + cell: ({ getValue }) => ( + + {getValue() ? new Date(getValue() as string).toLocaleDateString() : "N/A"} + + ), + }, + { + id: "actions", + header: "Info", + cell: ({ row }) => + isAdminRole(userRole || "") ? ( + <> + onEdit(row.original.server_id)} + /> + onDelete(row.original.server_id)} + icon={TrashIcon} + size="sm" + /> + + ) : null, + }, +]; diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.tsx index 6922788d0a4..86ad1b7434b 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.tsx @@ -1,7 +1,5 @@ import React, { useState } from "react"; -import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; - -import { PencilAltIcon, TrashIcon } from "@heroicons/react/outline"; +import { useQuery } from "@tanstack/react-query"; import { Modal, @@ -10,19 +8,12 @@ import { } from "antd"; import { - Table, - TableBody, - TableCell, - TableHead, - TableHeaderCell, - TableRow, - Icon, - Button, Grid, Col, Title, - TextInput, } from "@tremor/react"; +import { DataTable } from "../view_logs/table"; +import { mcpServerColumns } from "./mcp_server_columns"; import { deleteMCPServer, @@ -38,12 +29,6 @@ import { isAdminRole } from "@/utils/roles"; import { MCPServerView } from "./mcp_server_view"; import CreateMCPServer from "./create_mcp_server"; -const displayFriendlyId = (id: string) => { - return `${id.slice(0, 7)}...`; -}; - - - interface DeleteModalProps { isModalOpen: boolean; title: string; @@ -105,11 +90,25 @@ const MCPServers: React.FC = ({ const [selectedServerId, setSelectedServerId] = useState(null); const [editServer, setEditServer] = useState(false); - const handleDelete = (server_id: string) => { + const columns = React.useMemo( + () => + mcpServerColumns( + userRole, + (serverId: string) => setSelectedServerId(serverId), + (serverId: string) => { + setSelectedServerId(serverId); + setEditServer(true); + }, + handleDelete + ), + [userRole, handleDelete] + ); + + function handleDelete(server_id: string) { // Set the team to delete and open the confirmation modal setServerToDelete(server_id); setIsDeleteModalOpen(true); - }; + } const confirmDelete = async () => { if (serverIdToDelete == null || accessToken == null) { @@ -163,133 +162,28 @@ const MCPServers: React.FC = ({ /> ) : (
-
+

MCP Servers

- - - - Server ID - Server Name - Description - Transport - Auth Type - Url - Created - Info - - - - - {!mcpServers || mcpServers.length == 0 - ? [] - : mcpServers.map((mcpServer: MCPServer) => ( - - -
- - - -
-
- - {mcpServer.alias} - - - {mcpServer.description} - - - {handleTransport(mcpServer.transport)} - - - {handleAuth(mcpServer.auth_type)} - - -
- - {mcpServer.url} - -
-
- - {mcpServer.created_at - ? new Date(mcpServer.created_at).toLocaleDateString() - : "N/A"} - - - {isAdminRole(userRole) ? ( - <> - { - setSelectedServerId(mcpServer.server_id); - setEditServer(true); - }} - /> - handleDelete(mcpServer.server_id)} - icon={TrashIcon} - size="sm" - /> - - ) : null} - -
- ))} -
-
+ + <>} + getRowCanExpand={() => false} + isLoading={isLoadingServers} + noDataMessage="No MCP Servers found" + /> -
)}