import React from 'react'; import { Avatar, theme } from 'antd'; import { Globe, FileSearch, Plug } from 'lucide-react'; import { useResolvedAvatarSrc } from '@/hooks/useResolvedAvatarSrc'; import type { McpServer } from '@/types'; /** Icons for builtin MCP servers, keyed by server name. Returns icon at given size. */ const BUILTIN_ICON_FACTORY: Record React.ReactNode> = { '@boosapi/fetch': (s) => , '@boosapi/search-file': (s) => , }; /** Static 16px icons for external use. */ export const BUILTIN_ICONS: Record = { '@boosapi/fetch': , '@boosapi/search-file': , }; /** * Renders the appropriate icon for an MCP server: * - Builtin servers → fixed icon from BUILTIN_ICONS * - Custom servers with emoji/url/file iconType → user-chosen icon * - Default → Plug icon */ export function McpServerIcon({ server, size = 24 }: { server: McpServer; size?: number }) { const resolvedSrc = useResolvedAvatarSrc( (server.iconType as 'icon' | 'emoji' | 'url' | 'file') ?? 'icon', server.iconValue ?? '', ); const { token } = theme.useToken(); // Builtin servers: use fixed icon if (server.source === 'builtin' && BUILTIN_ICON_FACTORY[server.name]) { return ( {BUILTIN_ICON_FACTORY[server.name](size * 0.7)} ); } // Custom: emoji if (server.iconType === 'emoji' && server.iconValue) { return ( {server.iconValue} ); } // Custom: url or file image if ((server.iconType === 'url' || server.iconType === 'file') && server.iconValue) { const src = server.iconType === 'file' ? resolvedSrc : server.iconValue; return ; } // Default: plug icon return ( ); }