diff --git a/src/lib/components/AddToolServerModal.svelte b/src/lib/components/AddToolServerModal.svelte index 572b7fd3ab..f5ed25449b 100644 --- a/src/lib/components/AddToolServerModal.svelte +++ b/src/lib/components/AddToolServerModal.svelte @@ -77,11 +77,15 @@ 'bg-transparent outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700'; const selectClass = 'bg-transparent pr-5 outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700'; - const isMcpOAuth = () => type === 'mcp' && ['oauth_2.1', 'oauth_2.1_static'].includes(auth_type); + const oauthAuthTypes = ['oauth_2.1', 'oauth_2.1_static']; const verifyLabel = () => - isMcpOAuth() ? $i18n.t('Check OAuth Discovery') : $i18n.t('Verify Connection'); + oauthAuthTypes.includes(auth_type) + ? $i18n.t('Check OAuth Discovery') + : $i18n.t('Verify Connection'); const verifySuccessMessage = () => - isMcpOAuth() ? $i18n.t('OAuth discovery successful') : $i18n.t('Connection successful'); + oauthAuthTypes.includes(auth_type) + ? $i18n.t('OAuth discovery successful') + : $i18n.t('Connection successful'); const authorizeOAuthHandler = () => { if (!id) { @@ -213,7 +217,7 @@ id, name, description, - ...(isMcpOAuth() + ...(oauthAuthTypes.includes(auth_type) ? { ...(oauthServerUrl ? { oauth_server_url: oauthServerUrl } : {}), ...(oauthScope ? { oauth_scope: oauthScope } : {}), @@ -335,11 +339,7 @@ return; } - if ( - type === 'mcp' && - ['oauth_2.1', 'oauth_2.1_static'].includes(auth_type) && - !oauthClientInfo - ) { + if (type === 'mcp' && oauthAuthTypes.includes(auth_type) && !oauthClientInfo) { toast.error($i18n.t('Please register the OAuth client')); loading = false; return; @@ -392,7 +392,7 @@ id: id, name: name, description: description, - ...(type === 'mcp' && ['oauth_2.1', 'oauth_2.1_static'].includes(auth_type) + ...(type === 'mcp' && oauthAuthTypes.includes(auth_type) ? { ...(oauthScope ? { oauth_scope: oauthScope } : {}), oauth_resource_parameter: oauthResourceParameter @@ -684,7 +684,7 @@ - {#if isMcpOAuth()} + {#if oauthAuthTypes.includes(auth_type)}