diff --git a/web/app/components/tools/mcp/headers-input.tsx b/web/app/components/tools/mcp/headers-input.tsx index 81d62993c9..2d7598729b 100644 --- a/web/app/components/tools/mcp/headers-input.tsx +++ b/web/app/components/tools/mcp/headers-input.tsx @@ -113,7 +113,7 @@ const HeadersInput = ({ className='flex-1 rounded-none border-0' readOnly={readonly} /> - {!readonly && headerItems.length > 1 && ( + {!readonly && !!headerItems.length && ( handleRemoveItem(index)} className='mr-2' diff --git a/web/app/components/tools/mcp/modal.tsx b/web/app/components/tools/mcp/modal.tsx index 6b4c99e17a..2286620a2e 100644 --- a/web/app/components/tools/mcp/modal.tsx +++ b/web/app/components/tools/mcp/modal.tsx @@ -33,9 +33,17 @@ export type DuplicateAppModalProps = { icon: string icon_background?: string | null server_identifier: string - timeout: number - sse_read_timeout: number headers?: Record + is_dynamic_registration?: boolean + authentication?: { + client_id?: string + client_secret?: string + grant_type?: string + } + configurations: { + timeout: number + sse_read_timeout: number + } }) => void onHide: () => void } @@ -96,9 +104,9 @@ const MCPModal = ({ const appIconRef = useRef(null) const isHovering = useHover(appIconRef) const [authMethod, setAuthMethod] = useState(MCPAuthMethod.authentication) - const [useDynamicClientRegistration, setUseDynamicClientRegistration] = useState(data?.use_dynamic_client_registration || false) - const [clientID, setClientID] = useState(data?.client_id || '') - const [credentials, setCredentials] = useState(data?.credentials || '') + const [isDynamicRegistration, setIsDynamicRegistration] = useState(data?.is_dynamic_registration || false) + const [clientID, setClientID] = useState(data?.authentication?.client_id || '') + const [credentials, setCredentials] = useState(data?.authentication?.client_secret || '') // Update states when data changes (for edit mode) React.useEffect(() => { @@ -178,9 +186,17 @@ const MCPModal = ({ icon: appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId, icon_background: appIcon.type === 'emoji' ? appIcon.background : undefined, server_identifier: serverIdentifier.trim(), - timeout: timeout || 30, - sse_read_timeout: sseReadTimeout || 300, headers: Object.keys(headers).length > 0 ? headers : undefined, + is_dynamic_registration: isDynamicRegistration, + authentication: { + client_id: clientID, + client_secret: credentials, + grant_type: 'client_credentials', + }, + configurations: { + timeout: timeout || 30, + sse_read_timeout: sseReadTimeout || 300, + }, }) if(isCreate) onHide() @@ -279,14 +295,15 @@ const MCPModal = ({
{t('tools.mcp.modal.useDynamicClientRegistration')}
-
+
{t('tools.mcp.modal.clientID')}
setClientID(e.target.value)} onBlur={e => handleBlur(e.target.value.trim())} placeholder={t('tools.mcp.modal.clientID')} + disabled={isDynamicRegistration} />
-
+
{t('tools.mcp.modal.credentials')}
setCredentials(e.target.value)} onBlur={e => handleBlur(e.target.value.trim())} placeholder={t('tools.mcp.modal.credentialsPlaceholder')} + disabled={isDynamicRegistration} />
diff --git a/web/app/components/tools/types.ts b/web/app/components/tools/types.ts index 858b29ea03..be54954f0b 100644 --- a/web/app/components/tools/types.ts +++ b/web/app/components/tools/types.ts @@ -64,6 +64,16 @@ export type Collection = { masked_headers?: Record is_authorized?: boolean provider?: string + is_dynamic_registration?: boolean + authentication?: { + client_id?: string + client_secret?: string + grant_type?: string + } + configurations?: { + timeout?: number + sse_read_timeout?: number + } } export type ToolParameter = {