'use client'; import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { HugeiconsIcon } from "@hugeicons/react"; import type { IconSvgElement } from "@hugeicons/react"; import { Delete02Icon, PencilIcon, ServerStack01Icon, Wifi01Icon, GlobeIcon } from "@hugeicons/core-free-icons"; import { useTranslation } from '@/hooks/useTranslation'; import type { MCPServer } from '@/types'; interface McpServerListProps { servers: Record; onEdit: (name: string, server: MCPServer) => void; onDelete: (name: string) => void; } function getServerTypeInfo(server: MCPServer) { const type = server.type || 'stdio'; switch (type) { case 'sse': return { label: 'SSE', icon: Wifi01Icon, color: 'text-blue-500' }; case 'http': return { label: 'HTTP', icon: GlobeIcon, color: 'text-green-500' }; default: return { label: 'stdio', icon: ServerStack01Icon, color: 'text-muted-foreground' }; } } export function McpServerList({ servers, onEdit, onDelete }: McpServerListProps) { const { t } = useTranslation(); const entries = Object.entries(servers); if (entries.length === 0) { return (

{t('mcp.noServers')}

{t('mcp.noServersDesc')}

); } return (
{entries.map(([name, server]) => { const typeInfo = getServerTypeInfo(server); return (
{name} {typeInfo.label} {t('provider.configured')}
{server.url ? server.url : `${server.command} ${server.args?.join(' ') || ''}`}
{(server.env && Object.keys(server.env).length > 0) || (server.args && server.args.length > 0) ? ( {server.args && server.args.length > 0 && (

{t('mcp.arguments')}

{server.args.map((arg, i) => ( {arg} ))}
)} {server.env && Object.keys(server.env).length > 0 && (

{t('mcp.environment')}

{Object.keys(server.env).map((key) => ( {key} ))}
)}
) : null}
); })}
); }