-
+
+
@@ -110,8 +111,8 @@ function InitializingStatusIcon({ serverName, onCancel, canCancel }: Initializin
return (
-
@@ -121,8 +122,8 @@ function InitializingStatusIcon({ serverName, onCancel, canCancel }: Initializin
function ConnectingStatusIcon({ serverName }: StatusIconProps) {
return (
-
diff --git a/client/src/components/MCP/ServerInitializationSection.tsx b/client/src/components/MCP/ServerInitializationSection.tsx
index 0623ba1a2..5d793921e 100644
--- a/client/src/components/MCP/ServerInitializationSection.tsx
+++ b/client/src/components/MCP/ServerInitializationSection.tsx
@@ -1,23 +1,24 @@
-import React, { useCallback } from 'react';
-import { Button } from '@librechat/client';
-import { RefreshCw, Link } from 'lucide-react';
+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;
}
export default function ServerInitializationSection({
+ sidePanel = false,
serverName,
requiresOAuth,
hasCustomUserVars = false,
}: ServerInitializationSectionProps) {
const localize = useLocalize();
- // Use the centralized server manager instead of the old initialization hook so we can handle multiple oauth flows at once
const {
initializeServer,
connectionStatus,
@@ -33,99 +34,66 @@ export default function ServerInitializationSection({
const isServerInitializing = isInitializing(serverName);
const serverOAuthUrl = getOAuthUrl(serverName);
- const handleInitializeClick = useCallback(() => {
- initializeServer(serverName, false);
- }, [initializeServer, serverName]);
+ const shouldShowReinit = isConnected && (requiresOAuth || hasCustomUserVars);
+ const shouldShowInit = !isConnected && !serverOAuthUrl;
- const handleCancelClick = useCallback(() => {
- cancelOAuthFlow(serverName);
- }, [cancelOAuthFlow, serverName]);
-
- if (isConnected && (requiresOAuth || hasCustomUserVars)) {
- return (
-
-
-
- );
- }
-
- if (isConnected) {
+ if (!shouldShowReinit && !shouldShowInit && !serverOAuthUrl) {
return null;
}
- return (
-
-
+ if (serverOAuthUrl) {
+ return (
+ <>
-
- {requiresOAuth
- ? localize('com_ui_mcp_not_authenticated', { 0: serverName })
- : localize('com_ui_mcp_not_initialized', { 0: serverName })}
-
-
- {/* Only show authenticate button when OAuth URL is not present */}
- {!serverOAuthUrl && (
+
- )}
-
-
- {/* OAuth URL display */}
- {serverOAuthUrl && (
-
-
-
-
-
-
- {localize('com_ui_auth_url')}
-
-
-
-
-
-
-
- {localize('com_ui_oauth_flow_desc')}
-
- )}
+ >
+ );
+ }
+
+ // Unified button rendering
+ const isReinit = shouldShowReinit;
+ const outerClass = isReinit ? 'flex justify-start' : 'flex justify-end';
+ const buttonVariant = isReinit ? undefined : 'default';
+ const buttonText = isServerInitializing
+ ? localize('com_ui_loading')
+ : isReinit
+ ? localize('com_ui_reinitialize')
+ : requiresOAuth
+ ? localize('com_ui_authenticate')
+ : localize('com_ui_mcp_initialize');
+ const icon = isServerInitializing ? (
+
+ ) : (
+
+ );
+
+ return (
+
+
);
}
diff --git a/client/src/components/SidePanel/MCP/MCPPanel.tsx b/client/src/components/SidePanel/MCP/MCPPanel.tsx
index c67517278..b90efa197 100644
--- a/client/src/components/SidePanel/MCP/MCPPanel.tsx
+++ b/client/src/components/SidePanel/MCP/MCPPanel.tsx
@@ -6,8 +6,8 @@ import { Constants, QueryKeys } from 'librechat-data-provider';
import { useUpdateUserPluginsMutation } from 'librechat-data-provider/react-query';
import type { TUpdateUserPlugins } from 'librechat-data-provider';
import ServerInitializationSection from '~/components/MCP/ServerInitializationSection';
-import CustomUserVarsSection from '~/components/MCP/CustomUserVarsSection';
import { useMCPConnectionStatusQuery } from '~/data-provider/Tools/queries';
+import CustomUserVarsSection from '~/components/MCP/CustomUserVarsSection';
import BadgeRowProvider from '~/Providers/BadgeRowContext';
import { useGetStartupConfig } from '~/data-provider';
import MCPPanelSkeleton from './MCPPanelSkeleton';
@@ -127,20 +127,12 @@ function MCPPanelContent() {
const serverStatus = connectionStatus[selectedServerNameForEditing];
return (
-
-