From 992cb83b1ebf99385b5c38a083fc745b91da3c55 Mon Sep 17 00:00:00 2001 From: Chris Scott Date: Fri, 12 Dec 2025 20:24:33 -0500 Subject: [PATCH] Add MCP server card component for settings UI --- .../src/components/settings/McpServerCard.tsx | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 frontend/src/components/settings/McpServerCard.tsx diff --git a/frontend/src/components/settings/McpServerCard.tsx b/frontend/src/components/settings/McpServerCard.tsx new file mode 100644 index 00000000..eb87066d --- /dev/null +++ b/frontend/src/components/settings/McpServerCard.tsx @@ -0,0 +1,145 @@ +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' +import { Badge } from '@/components/ui/badge' +import { Switch } from '@/components/ui/switch' +import { Button } from '@/components/ui/button' +import { Trash2, XCircle, AlertCircle, Key } from 'lucide-react' +import type { McpStatus } from '@/api/mcp' + +interface McpServerConfig { + type: 'local' | 'remote' + enabled?: boolean + command?: string[] + url?: string + environment?: Record + timeout?: number +} + +interface McpServerCardProps { + serverId: string + serverConfig: McpServerConfig + status?: McpStatus + isConnected: boolean + errorMessage: string | null + isAnyOperationPending: boolean + togglingServerId: string | null + onToggleServer: (serverId: string) => void + onDeleteServer: (serverId: string, serverName: string) => void +} + +function getStatusBadge(status: McpStatus) { + switch (status.status) { + case 'connected': + return Connected + case 'disabled': + return Disabled + case 'failed': + return ( + + + Failed + + ) + case 'needs_auth': + return ( + + + Auth Required + + ) + case 'needs_client_registration': + return ( + + + Registration Required + + ) + default: + return Unknown + } +} + +function getServerDisplayName(serverId: string): string { + const name = serverId.replace(/[-_]/g, ' ') + return name.charAt(0).toUpperCase() + name.slice(1) +} + +function getServerDescription(serverConfig: McpServerConfig): string { + if (serverConfig.type === 'local' && serverConfig.command) { + const command = serverConfig.command.join(' ') + if (command.includes('filesystem')) return 'File system access' + if (command.includes('git')) return 'Git repository operations' + if (command.includes('sqlite')) return 'SQLite database access' + if (command.includes('postgres')) return 'PostgreSQL database access' + if (command.includes('brave-search')) return 'Web search via Brave' + if (command.includes('github')) return 'GitHub repository access' + if (command.includes('slack')) return 'Slack integration' + if (command.includes('puppeteer')) return 'Web automation' + if (command.includes('fetch')) return 'HTTP requests' + if (command.includes('memory')) return 'Persistent memory' + return `Local command: ${command}` + } else if (serverConfig.type === 'remote' && serverConfig.url) { + return `Remote server: ${serverConfig.url}` + } + return 'MCP server' +} + +export function McpServerCard({ + serverId, + serverConfig, + status, + isConnected, + errorMessage, + isAnyOperationPending, + togglingServerId, + onToggleServer, + onDeleteServer +}: McpServerCardProps) { + return ( + + +
+
+ {getServerDisplayName(serverId)} +
+ {status ? getStatusBadge(status) : ( + Loading... + )} +
+
+
+ onToggleServer(serverId)} + disabled={isAnyOperationPending || togglingServerId === serverId} + /> + +
+
+
+ +
+

{getServerDescription(serverConfig)}

+ {serverConfig.timeout && ( +

Timeout: {serverConfig.timeout}ms

+ )} + {serverConfig.environment && Object.keys(serverConfig.environment).length > 0 && ( +

Environment variables: {Object.keys(serverConfig.environment).length} configured

+ )} + {errorMessage && ( +
+ + {errorMessage} +
+ )} +
+
+
+ ) +}