diff --git a/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/hooks/useMCPServerForm.ts b/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/hooks/useMCPServerForm.ts index 9522f450df..5f74b48864 100644 --- a/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/hooks/useMCPServerForm.ts +++ b/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/hooks/useMCPServerForm.ts @@ -53,11 +53,17 @@ export interface MCPServerFormData { interface UseMCPServerFormProps { server?: MCPServerDefinition | null; + initialValues?: Partial; onSuccess?: (serverName: string, isOAuth: boolean) => void; onClose?: () => void; } -export function useMCPServerForm({ server, onSuccess, onClose }: UseMCPServerFormProps) { +export function useMCPServerForm({ + server, + initialValues, + onSuccess, + onClose, +}: UseMCPServerFormProps) { const localize = useLocalize(); const { showToast } = useToastContext(); @@ -111,11 +117,11 @@ export function useMCPServerForm({ server, onSuccess, onClose }: UseMCPServerFor } return { - title: '', - description: '', - url: '', - type: 'streamable-http', - icon: '', + title: initialValues?.title ?? '', + description: initialValues?.description ?? '', + url: initialValues?.url ?? '', + type: initialValues?.type ?? 'streamable-http', + icon: initialValues?.icon ?? '', auth: { auth_type: AuthTypeEnum.None, api_key: '', @@ -130,7 +136,7 @@ export function useMCPServerForm({ server, onSuccess, onClose }: UseMCPServerFor }, trust: false, }; - }, [server]); + }, [server, initialValues]); // Form instance const methods = useForm({ @@ -142,8 +148,6 @@ export function useMCPServerForm({ server, onSuccess, onClose }: UseMCPServerFor // Watch URL for auto-fill const watchedUrl = watch('url'); - const watchedTitle = watch('title'); - // Auto-fill title from URL when title is empty const handleUrlChange = useCallback( (url: string) => { diff --git a/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/index.tsx b/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/index.tsx index c9d3473d60..c37ef4223d 100644 --- a/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/index.tsx +++ b/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/index.tsx @@ -23,6 +23,7 @@ import { } from 'librechat-data-provider'; import { useAuthContext, useHasAccess, useResourcePermissions, MCPServerDefinition } from '~/hooks'; import { GenericGrantAccessDialog } from '~/components/Sharing'; +import type { MCPServerFormData } from './hooks/useMCPServerForm'; import { useMCPServerForm } from './hooks/useMCPServerForm'; import { useLocalize, useCopyToClipboard } from '~/hooks'; import MCPServerForm from './MCPServerForm'; @@ -33,6 +34,7 @@ interface MCPServerDialogProps { children?: React.ReactNode; triggerRef?: React.MutableRefObject; server?: MCPServerDefinition | null; + initialValues?: Partial; } export default function MCPServerDialog({ @@ -41,6 +43,7 @@ export default function MCPServerDialog({ children, triggerRef, server, + initialValues, }: MCPServerDialogProps) { const localize = useLocalize(); const { user } = useAuthContext(); @@ -55,6 +58,7 @@ export default function MCPServerDialog({ // Form hook const formHook = useMCPServerForm({ server, + initialValues, onSuccess: (serverName, isOAuth) => { if (isOAuth) { setCreatedServerId(serverName);