import React from 'react'; import { RefreshCw } from 'lucide-react'; import { Button, Spinner } from '@librechat/client'; import { useMCPServerManager } from '~/hooks/MCP/useMCPServerManager'; import { useLocalize } from '~/hooks'; interface ServerInitializationSectionProps { sidePanel?: boolean; serverName: string; requiresOAuth: boolean; hasCustomUserVars?: boolean; conversationId?: string | null; } export default function ServerInitializationSection({ serverName, requiresOAuth, conversationId, sidePanel = false, hasCustomUserVars = false, }: ServerInitializationSectionProps) { const localize = useLocalize(); const { initializeServer, connectionStatus, cancelOAuthFlow, isInitializing, isCancellable, getOAuthUrl, } = useMCPServerManager({ conversationId }); const serverStatus = connectionStatus[serverName]; const isConnected = serverStatus?.connectionState === 'connected'; const canCancel = isCancellable(serverName); const isServerInitializing = isInitializing(serverName); const serverOAuthUrl = getOAuthUrl(serverName); const shouldShowReinit = isConnected && (requiresOAuth || hasCustomUserVars); const shouldShowInit = !isConnected && !serverOAuthUrl; if (!shouldShowReinit && !shouldShowInit && !serverOAuthUrl) { return null; } if (serverOAuthUrl) { return ( <>