mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
Merge branch 'deploy/dev' of github.com:langgenius/dify into deploy/dev
This commit is contained in:
commit
52b708aaad
@ -65,14 +65,46 @@ class HostedOpenAiConfig(BaseSettings):
|
|||||||
|
|
||||||
HOSTED_OPENAI_TRIAL_MODELS: str = Field(
|
HOSTED_OPENAI_TRIAL_MODELS: str = Field(
|
||||||
description="Comma-separated list of available models for trial access",
|
description="Comma-separated list of available models for trial access",
|
||||||
default="gpt-3.5-turbo,"
|
default="gpt-4,"
|
||||||
"gpt-3.5-turbo-1106,"
|
"gpt-4-turbo-preview,"
|
||||||
"gpt-3.5-turbo-instruct,"
|
"gpt-4-turbo-2024-04-09,"
|
||||||
|
"gpt-4-1106-preview,"
|
||||||
|
"gpt-4-0125-preview,"
|
||||||
|
"gpt-4-turbo,"
|
||||||
|
"gpt-4.1,"
|
||||||
|
"gpt-4.1-2025-04-14,"
|
||||||
|
"gpt-4.1-mini,"
|
||||||
|
"gpt-4.1-mini-2025-04-14,"
|
||||||
|
"gpt-4.1-nano,"
|
||||||
|
"gpt-4.1-nano-2025-04-14,"
|
||||||
|
"gpt-3.5-turbo,"
|
||||||
"gpt-3.5-turbo-16k,"
|
"gpt-3.5-turbo-16k,"
|
||||||
"gpt-3.5-turbo-16k-0613,"
|
"gpt-3.5-turbo-16k-0613,"
|
||||||
|
"gpt-3.5-turbo-1106,"
|
||||||
"gpt-3.5-turbo-0613,"
|
"gpt-3.5-turbo-0613,"
|
||||||
"gpt-3.5-turbo-0125,"
|
"gpt-3.5-turbo-0125,"
|
||||||
"text-davinci-003",
|
"gpt-3.5-turbo-instruct,"
|
||||||
|
"text-davinci-003,"
|
||||||
|
"chatgpt-4o-latest,"
|
||||||
|
"gpt-4o,"
|
||||||
|
"gpt-4o-2024-05-13,"
|
||||||
|
"gpt-4o-2024-08-06,"
|
||||||
|
"gpt-4o-2024-11-20,"
|
||||||
|
"gpt-4o-audio-preview,"
|
||||||
|
"gpt-4o-audio-preview-2025-06-03,"
|
||||||
|
"gpt-4o-mini,"
|
||||||
|
"gpt-4o-mini-2024-07-18,"
|
||||||
|
"o3-mini,"
|
||||||
|
"o3-mini-2025-01-31,"
|
||||||
|
"gpt-5-mini-2025-08-07,"
|
||||||
|
"gpt-5-mini,"
|
||||||
|
"o4-mini,"
|
||||||
|
"o4-mini-2025-04-16,"
|
||||||
|
"gpt-5-chat-latest,"
|
||||||
|
"gpt-5,"
|
||||||
|
"gpt-5-2025-08-07,"
|
||||||
|
"gpt-5-nano,"
|
||||||
|
"gpt-5-nano-2025-08-07",
|
||||||
)
|
)
|
||||||
|
|
||||||
HOSTED_OPENAI_PAID_ENABLED: bool = Field(
|
HOSTED_OPENAI_PAID_ENABLED: bool = Field(
|
||||||
@ -87,6 +119,13 @@ class HostedOpenAiConfig(BaseSettings):
|
|||||||
"gpt-4-turbo-2024-04-09,"
|
"gpt-4-turbo-2024-04-09,"
|
||||||
"gpt-4-1106-preview,"
|
"gpt-4-1106-preview,"
|
||||||
"gpt-4-0125-preview,"
|
"gpt-4-0125-preview,"
|
||||||
|
"gpt-4-turbo,"
|
||||||
|
"gpt-4.1,"
|
||||||
|
"gpt-4.1-2025-04-14,"
|
||||||
|
"gpt-4.1-mini,"
|
||||||
|
"gpt-4.1-mini-2025-04-14,"
|
||||||
|
"gpt-4.1-nano,"
|
||||||
|
"gpt-4.1-nano-2025-04-14,"
|
||||||
"gpt-3.5-turbo,"
|
"gpt-3.5-turbo,"
|
||||||
"gpt-3.5-turbo-16k,"
|
"gpt-3.5-turbo-16k,"
|
||||||
"gpt-3.5-turbo-16k-0613,"
|
"gpt-3.5-turbo-16k-0613,"
|
||||||
@ -94,7 +133,27 @@ class HostedOpenAiConfig(BaseSettings):
|
|||||||
"gpt-3.5-turbo-0613,"
|
"gpt-3.5-turbo-0613,"
|
||||||
"gpt-3.5-turbo-0125,"
|
"gpt-3.5-turbo-0125,"
|
||||||
"gpt-3.5-turbo-instruct,"
|
"gpt-3.5-turbo-instruct,"
|
||||||
"text-davinci-003",
|
"text-davinci-003,"
|
||||||
|
"chatgpt-4o-latest,"
|
||||||
|
"gpt-4o,"
|
||||||
|
"gpt-4o-2024-05-13,"
|
||||||
|
"gpt-4o-2024-08-06,"
|
||||||
|
"gpt-4o-2024-11-20,"
|
||||||
|
"gpt-4o-audio-preview,"
|
||||||
|
"gpt-4o-audio-preview-2025-06-03,"
|
||||||
|
"gpt-4o-mini,"
|
||||||
|
"gpt-4o-mini-2024-07-18,"
|
||||||
|
"o3-mini,"
|
||||||
|
"o3-mini-2025-01-31,"
|
||||||
|
"gpt-5-mini-2025-08-07,"
|
||||||
|
"gpt-5-mini,"
|
||||||
|
"o4-mini,"
|
||||||
|
"o4-mini-2025-04-16,"
|
||||||
|
"gpt-5-chat-latest,"
|
||||||
|
"gpt-5,"
|
||||||
|
"gpt-5-2025-08-07,"
|
||||||
|
"gpt-5-nano,"
|
||||||
|
"gpt-5-nano-2025-08-07",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -217,7 +276,7 @@ class HostedDeepseekConfig(BaseSettings):
|
|||||||
|
|
||||||
HOSTED_DEEPSEEK_PAID_MODELS: str = Field(
|
HOSTED_DEEPSEEK_PAID_MODELS: str = Field(
|
||||||
description="Comma-separated list of available models for paid access",
|
description="Comma-separated list of available models for paid access",
|
||||||
default="grok-3,grok-3-mini,grok-3-mini-fast",
|
default="deepseek-chat,deepseek-reasoner",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -275,7 +334,6 @@ class HostedAnthropicConfig(BaseSettings):
|
|||||||
HOSTED_ANTHROPIC_TRIAL_MODELS: str = Field(
|
HOSTED_ANTHROPIC_TRIAL_MODELS: str = Field(
|
||||||
description="Comma-separated list of available models for paid access",
|
description="Comma-separated list of available models for paid access",
|
||||||
default="claude-opus-4-20250514,"
|
default="claude-opus-4-20250514,"
|
||||||
"claude-opus-4-20250514,"
|
|
||||||
"claude-sonnet-4-20250514,"
|
"claude-sonnet-4-20250514,"
|
||||||
"claude-3-5-haiku-20241022,"
|
"claude-3-5-haiku-20241022,"
|
||||||
"claude-3-opus-20240229,"
|
"claude-3-opus-20240229,"
|
||||||
@ -285,7 +343,6 @@ class HostedAnthropicConfig(BaseSettings):
|
|||||||
HOSTED_ANTHROPIC_PAID_MODELS: str = Field(
|
HOSTED_ANTHROPIC_PAID_MODELS: str = Field(
|
||||||
description="Comma-separated list of available models for paid access",
|
description="Comma-separated list of available models for paid access",
|
||||||
default="claude-opus-4-20250514,"
|
default="claude-opus-4-20250514,"
|
||||||
"claude-opus-4-20250514,"
|
|
||||||
"claude-sonnet-4-20250514,"
|
"claude-sonnet-4-20250514,"
|
||||||
"claude-3-5-haiku-20241022,"
|
"claude-3-5-haiku-20241022,"
|
||||||
"claude-3-opus-20240229,"
|
"claude-3-opus-20240229,"
|
||||||
|
|||||||
@ -919,6 +919,7 @@ class ToolProviderMCPApi(Resource):
|
|||||||
parser.add_argument("server_identifier", type=str, required=True, nullable=False, location="json")
|
parser.add_argument("server_identifier", type=str, required=True, nullable=False, location="json")
|
||||||
parser.add_argument("configuration", type=dict, required=False, nullable=True, location="json")
|
parser.add_argument("configuration", type=dict, required=False, nullable=True, location="json")
|
||||||
parser.add_argument("authentication", type=dict, required=False, nullable=True, location="json")
|
parser.add_argument("authentication", type=dict, required=False, nullable=True, location="json")
|
||||||
|
parser.add_argument("headers", type=dict, required=False, nullable=True, location="json", default={})
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if not is_valid_url(args["server_url"]):
|
if not is_valid_url(args["server_url"]):
|
||||||
|
|||||||
@ -11,12 +11,14 @@ type Option = {
|
|||||||
type TabSliderProps = {
|
type TabSliderProps = {
|
||||||
className?: string
|
className?: string
|
||||||
value: string
|
value: string
|
||||||
|
itemClassName?: string | ((active: boolean) => string)
|
||||||
onChange: (v: string) => void
|
onChange: (v: string) => void
|
||||||
options: Option[]
|
options: Option[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabSlider: FC<TabSliderProps> = ({
|
const TabSlider: FC<TabSliderProps> = ({
|
||||||
className,
|
className,
|
||||||
|
itemClassName,
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
options,
|
options,
|
||||||
@ -58,6 +60,7 @@ const TabSlider: FC<TabSliderProps> = ({
|
|||||||
index === activeIndex
|
index === activeIndex
|
||||||
? 'text-text-primary'
|
? 'text-text-primary'
|
||||||
: 'text-text-tertiary',
|
: 'text-text-tertiary',
|
||||||
|
typeof itemClassName === 'function' ? itemClassName(index === activeIndex) : itemClassName,
|
||||||
)}
|
)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (index !== activeIndex) {
|
if (index !== activeIndex) {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useCallback } from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { v4 as uuid } from 'uuid'
|
||||||
import { RiAddLine, RiDeleteBinLine } from '@remixicon/react'
|
import { RiAddLine, RiDeleteBinLine } from '@remixicon/react'
|
||||||
import Input from '@/app/components/base/input'
|
import Input from '@/app/components/base/input'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
@ -8,57 +9,46 @@ import ActionButton from '@/app/components/base/action-button'
|
|||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
|
||||||
export type HeaderItem = {
|
export type HeaderItem = {
|
||||||
|
id: string
|
||||||
key: string
|
key: string
|
||||||
value: string
|
value: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
headers: Record<string, string>
|
headersItems: HeaderItem[]
|
||||||
onChange: (headers: Record<string, string>) => void
|
onChange: (headerItems: HeaderItem[]) => void
|
||||||
readonly?: boolean
|
readonly?: boolean
|
||||||
isMasked?: boolean
|
isMasked?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const HeadersInput = ({
|
const HeadersInput = ({
|
||||||
headers,
|
headersItems,
|
||||||
onChange,
|
onChange,
|
||||||
readonly = false,
|
readonly = false,
|
||||||
isMasked = false,
|
isMasked = false,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const headerItems = Object.entries(headers).map(([key, value]) => ({ key, value }))
|
const handleItemChange = (index: number, field: 'key' | 'value', value: string) => {
|
||||||
|
const newItems = [...headersItems]
|
||||||
const handleItemChange = useCallback((index: number, field: 'key' | 'value', value: string) => {
|
|
||||||
const newItems = [...headerItems]
|
|
||||||
newItems[index] = { ...newItems[index], [field]: value }
|
newItems[index] = { ...newItems[index], [field]: value }
|
||||||
|
|
||||||
const newHeaders = newItems.reduce((acc, item) => {
|
onChange(newItems)
|
||||||
if (item.key.trim())
|
}
|
||||||
acc[item.key.trim()] = item.value
|
|
||||||
return acc
|
|
||||||
}, {} as Record<string, string>)
|
|
||||||
|
|
||||||
onChange(newHeaders)
|
const handleRemoveItem = (index: number) => {
|
||||||
}, [headerItems, onChange])
|
const newItems = headersItems.filter((_, i) => i !== index)
|
||||||
|
|
||||||
const handleRemoveItem = useCallback((index: number) => {
|
onChange(newItems)
|
||||||
const newItems = headerItems.filter((_, i) => i !== index)
|
}
|
||||||
const newHeaders = newItems.reduce((acc, item) => {
|
|
||||||
if (item.key.trim())
|
|
||||||
acc[item.key.trim()] = item.value
|
|
||||||
|
|
||||||
return acc
|
const handleAddItem = () => {
|
||||||
}, {} as Record<string, string>)
|
const newItems = [...headersItems, { id: uuid(), key: '', value: '' }]
|
||||||
onChange(newHeaders)
|
|
||||||
}, [headerItems, onChange])
|
|
||||||
|
|
||||||
const handleAddItem = useCallback(() => {
|
onChange(newItems)
|
||||||
const newHeaders = { ...headers, '': '' }
|
}
|
||||||
onChange(newHeaders)
|
|
||||||
}, [headers, onChange])
|
|
||||||
|
|
||||||
if (headerItems.length === 0) {
|
if (headersItems.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className='space-y-2'>
|
<div className='space-y-2'>
|
||||||
<div className='body-xs-regular text-text-tertiary'>
|
<div className='body-xs-regular text-text-tertiary'>
|
||||||
@ -91,10 +81,10 @@ const HeadersInput = ({
|
|||||||
<div className='h-full w-1/2 border-r border-divider-regular pl-3'>{t('tools.mcp.modal.headerKey')}</div>
|
<div className='h-full w-1/2 border-r border-divider-regular pl-3'>{t('tools.mcp.modal.headerKey')}</div>
|
||||||
<div className='h-full w-1/2 pl-3 pr-1'>{t('tools.mcp.modal.headerValue')}</div>
|
<div className='h-full w-1/2 pl-3 pr-1'>{t('tools.mcp.modal.headerValue')}</div>
|
||||||
</div>
|
</div>
|
||||||
{headerItems.map((item, index) => (
|
{headersItems.map((item, index) => (
|
||||||
<div key={index} className={cn(
|
<div key={item.id} className={cn(
|
||||||
'flex items-center border-divider-regular',
|
'flex items-center border-divider-regular',
|
||||||
index < headerItems.length - 1 && 'border-b',
|
index < headersItems.length - 1 && 'border-b',
|
||||||
)}>
|
)}>
|
||||||
<div className='w-1/2 border-r border-divider-regular'>
|
<div className='w-1/2 border-r border-divider-regular'>
|
||||||
<Input
|
<Input
|
||||||
@ -113,7 +103,7 @@ const HeadersInput = ({
|
|||||||
className='flex-1 rounded-none border-0'
|
className='flex-1 rounded-none border-0'
|
||||||
readOnly={readonly}
|
readOnly={readonly}
|
||||||
/>
|
/>
|
||||||
{!readonly && headerItems.length > 1 && (
|
{!readonly && !!headersItems.length && (
|
||||||
<ActionButton
|
<ActionButton
|
||||||
onClick={() => handleRemoveItem(index)}
|
onClick={() => handleRemoveItem(index)}
|
||||||
className='mr-2'
|
className='mr-2'
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useRef, useState } from 'react'
|
import React, { useCallback, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { v4 as uuid } from 'uuid'
|
||||||
import { getDomain } from 'tldts'
|
import { getDomain } from 'tldts'
|
||||||
import { RiCloseLine, RiEditLine } from '@remixicon/react'
|
import { RiCloseLine, RiEditLine } from '@remixicon/react'
|
||||||
import { Mcp } from '@/app/components/base/icons/src/vender/other'
|
import { Mcp } from '@/app/components/base/icons/src/vender/other'
|
||||||
@ -11,6 +12,7 @@ import Modal from '@/app/components/base/modal'
|
|||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import Input from '@/app/components/base/input'
|
import Input from '@/app/components/base/input'
|
||||||
import HeadersInput from './headers-input'
|
import HeadersInput from './headers-input'
|
||||||
|
import type { HeaderItem } from './headers-input'
|
||||||
import type { AppIconType } from '@/types/app'
|
import type { AppIconType } from '@/types/app'
|
||||||
import type { ToolWithProvider } from '@/app/components/workflow/types'
|
import type { ToolWithProvider } from '@/app/components/workflow/types'
|
||||||
import { noop } from 'lodash-es'
|
import { noop } from 'lodash-es'
|
||||||
@ -19,6 +21,9 @@ import { uploadRemoteFileInfo } from '@/service/common'
|
|||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import { useHover } from 'ahooks'
|
import { useHover } from 'ahooks'
|
||||||
import { shouldUseMcpIconForAppIcon } from '@/utils/mcp'
|
import { shouldUseMcpIconForAppIcon } from '@/utils/mcp'
|
||||||
|
import TabSlider from '@/app/components/base/tab-slider'
|
||||||
|
import { MCPAuthMethod } from '@/app/components/tools/types'
|
||||||
|
import Switch from '@/app/components/base/switch'
|
||||||
|
|
||||||
export type DuplicateAppModalProps = {
|
export type DuplicateAppModalProps = {
|
||||||
data?: ToolWithProvider
|
data?: ToolWithProvider
|
||||||
@ -30,9 +35,17 @@ export type DuplicateAppModalProps = {
|
|||||||
icon: string
|
icon: string
|
||||||
icon_background?: string | null
|
icon_background?: string | null
|
||||||
server_identifier: string
|
server_identifier: string
|
||||||
timeout: number
|
|
||||||
sse_read_timeout: number
|
|
||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
|
is_dynamic_registration?: boolean
|
||||||
|
authentication?: {
|
||||||
|
client_id?: string
|
||||||
|
client_secret?: string
|
||||||
|
grant_type?: string
|
||||||
|
}
|
||||||
|
configuration: {
|
||||||
|
timeout: number
|
||||||
|
sse_read_timeout: number
|
||||||
|
}
|
||||||
}) => void
|
}) => void
|
||||||
onHide: () => void
|
onHide: () => void
|
||||||
}
|
}
|
||||||
@ -63,6 +76,20 @@ const MCPModal = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const isCreate = !data
|
const isCreate = !data
|
||||||
|
|
||||||
|
const authMethods = [
|
||||||
|
{
|
||||||
|
text: t('tools.mcp.modal.authentication'),
|
||||||
|
value: MCPAuthMethod.authentication,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: t('tools.mcp.modal.headers'),
|
||||||
|
value: MCPAuthMethod.headers,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: t('tools.mcp.modal.configurations'),
|
||||||
|
value: MCPAuthMethod.configurations,
|
||||||
|
},
|
||||||
|
]
|
||||||
const originalServerUrl = data?.server_url
|
const originalServerUrl = data?.server_url
|
||||||
const originalServerID = data?.server_identifier
|
const originalServerID = data?.server_identifier
|
||||||
const [url, setUrl] = React.useState(data?.server_url || '')
|
const [url, setUrl] = React.useState(data?.server_url || '')
|
||||||
@ -72,12 +99,16 @@ const MCPModal = ({
|
|||||||
const [serverIdentifier, setServerIdentifier] = React.useState(data?.server_identifier || '')
|
const [serverIdentifier, setServerIdentifier] = React.useState(data?.server_identifier || '')
|
||||||
const [timeout, setMcpTimeout] = React.useState(data?.timeout || 30)
|
const [timeout, setMcpTimeout] = React.useState(data?.timeout || 30)
|
||||||
const [sseReadTimeout, setSseReadTimeout] = React.useState(data?.sse_read_timeout || 300)
|
const [sseReadTimeout, setSseReadTimeout] = React.useState(data?.sse_read_timeout || 300)
|
||||||
const [headers, setHeaders] = React.useState<Record<string, string>>(
|
const [headers, setHeaders] = React.useState<HeaderItem[]>(
|
||||||
data?.masked_headers || {},
|
Object.entries(data?.masked_headers || {}).map(([key, value]) => ({ id: uuid(), key, value })),
|
||||||
)
|
)
|
||||||
const [isFetchingIcon, setIsFetchingIcon] = useState(false)
|
const [isFetchingIcon, setIsFetchingIcon] = useState(false)
|
||||||
const appIconRef = useRef<HTMLDivElement>(null)
|
const appIconRef = useRef<HTMLDivElement>(null)
|
||||||
const isHovering = useHover(appIconRef)
|
const isHovering = useHover(appIconRef)
|
||||||
|
const [authMethod, setAuthMethod] = useState(MCPAuthMethod.authentication)
|
||||||
|
const [isDynamicRegistration, setIsDynamicRegistration] = useState(isCreate ? true : data?.is_dynamic_registration)
|
||||||
|
const [clientID, setClientID] = useState(data?.authentication?.client_id || '')
|
||||||
|
const [credentials, setCredentials] = useState(data?.authentication?.client_secret || '')
|
||||||
|
|
||||||
// Update states when data changes (for edit mode)
|
// Update states when data changes (for edit mode)
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@ -87,8 +118,11 @@ const MCPModal = ({
|
|||||||
setServerIdentifier(data.server_identifier || '')
|
setServerIdentifier(data.server_identifier || '')
|
||||||
setMcpTimeout(data.timeout || 30)
|
setMcpTimeout(data.timeout || 30)
|
||||||
setSseReadTimeout(data.sse_read_timeout || 300)
|
setSseReadTimeout(data.sse_read_timeout || 300)
|
||||||
setHeaders(data.masked_headers || {})
|
setHeaders(Object.entries(data.masked_headers || {}).map(([key, value]) => ({ id: uuid(), key, value })))
|
||||||
setAppIcon(getIcon(data))
|
setAppIcon(getIcon(data))
|
||||||
|
setIsDynamicRegistration(data.is_dynamic_registration)
|
||||||
|
setClientID(data.authentication?.client_id || '')
|
||||||
|
setCredentials(data.authentication?.client_secret || '')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Reset for create mode
|
// Reset for create mode
|
||||||
@ -97,8 +131,11 @@ const MCPModal = ({
|
|||||||
setServerIdentifier('')
|
setServerIdentifier('')
|
||||||
setMcpTimeout(30)
|
setMcpTimeout(30)
|
||||||
setSseReadTimeout(300)
|
setSseReadTimeout(300)
|
||||||
setHeaders({})
|
setHeaders([])
|
||||||
setAppIcon(DEFAULT_ICON as AppIconSelection)
|
setAppIcon(DEFAULT_ICON as AppIconSelection)
|
||||||
|
setIsDynamicRegistration(true)
|
||||||
|
setClientID('')
|
||||||
|
setCredentials('')
|
||||||
}
|
}
|
||||||
}, [data])
|
}, [data])
|
||||||
|
|
||||||
@ -150,6 +187,11 @@ const MCPModal = ({
|
|||||||
Toast.notify({ type: 'error', message: 'invalid server identifier' })
|
Toast.notify({ type: 'error', message: 'invalid server identifier' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const formattedHeaders = headers.reduce((acc, item) => {
|
||||||
|
if (item.key.trim())
|
||||||
|
acc[item.key.trim()] = item.value
|
||||||
|
return acc
|
||||||
|
}, {} as Record<string, string>)
|
||||||
await onConfirm({
|
await onConfirm({
|
||||||
server_url: originalServerUrl === url ? '[__HIDDEN__]' : url.trim(),
|
server_url: originalServerUrl === url ? '[__HIDDEN__]' : url.trim(),
|
||||||
name,
|
name,
|
||||||
@ -157,14 +199,25 @@ const MCPModal = ({
|
|||||||
icon: appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId,
|
icon: appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId,
|
||||||
icon_background: appIcon.type === 'emoji' ? appIcon.background : undefined,
|
icon_background: appIcon.type === 'emoji' ? appIcon.background : undefined,
|
||||||
server_identifier: serverIdentifier.trim(),
|
server_identifier: serverIdentifier.trim(),
|
||||||
timeout: timeout || 30,
|
headers: Object.keys(formattedHeaders).length > 0 ? formattedHeaders : undefined,
|
||||||
sse_read_timeout: sseReadTimeout || 300,
|
is_dynamic_registration: isDynamicRegistration,
|
||||||
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
authentication: {
|
||||||
|
client_id: clientID,
|
||||||
|
client_secret: credentials,
|
||||||
|
},
|
||||||
|
configuration: {
|
||||||
|
timeout: timeout || 30,
|
||||||
|
sse_read_timeout: sseReadTimeout || 300,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
if(isCreate)
|
if(isCreate)
|
||||||
onHide()
|
onHide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleAuthMethodChange = useCallback((value: string) => {
|
||||||
|
setAuthMethod(value as MCPAuthMethod)
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal
|
<Modal
|
||||||
@ -239,42 +292,101 @@ const MCPModal = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<TabSlider
|
||||||
<div className='mb-1 flex h-6 items-center'>
|
className='w-full'
|
||||||
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.timeout')}</span>
|
itemClassName={(isActive) => {
|
||||||
</div>
|
return `flex-1 ${isActive && 'text-text-accent-light-mode-only'}`
|
||||||
<Input
|
}}
|
||||||
type='number'
|
value={authMethod}
|
||||||
value={timeout}
|
onChange={handleAuthMethodChange}
|
||||||
onChange={e => setMcpTimeout(Number(e.target.value))}
|
options={authMethods}
|
||||||
onBlur={e => handleBlur(e.target.value.trim())}
|
/>
|
||||||
placeholder={t('tools.mcp.modal.timeoutPlaceholder')}
|
{
|
||||||
/>
|
authMethod === MCPAuthMethod.authentication && (
|
||||||
</div>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<div className='mb-1 flex h-6 items-center'>
|
<div className='mb-1 flex h-6 items-center'>
|
||||||
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.sseReadTimeout')}</span>
|
<Switch
|
||||||
</div>
|
className='mr-2'
|
||||||
<Input
|
defaultValue={isDynamicRegistration}
|
||||||
type='number'
|
onChange={setIsDynamicRegistration}
|
||||||
value={sseReadTimeout}
|
/>
|
||||||
onChange={e => setSseReadTimeout(Number(e.target.value))}
|
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.useDynamicClientRegistration')}</span>
|
||||||
onBlur={e => handleBlur(e.target.value.trim())}
|
</div>
|
||||||
placeholder={t('tools.mcp.modal.timeoutPlaceholder')}
|
</div>
|
||||||
/>
|
<div>
|
||||||
</div>
|
<div className={cn('mb-1 flex h-6 items-center', isDynamicRegistration && 'opacity-50')}>
|
||||||
<div>
|
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.clientID')}</span>
|
||||||
<div className='mb-1 flex h-6 items-center'>
|
</div>
|
||||||
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.headers')}</span>
|
<Input
|
||||||
</div>
|
value={clientID}
|
||||||
<div className='body-xs-regular mb-2 text-text-tertiary'>{t('tools.mcp.modal.headersTip')}</div>
|
onChange={e => setClientID(e.target.value)}
|
||||||
<HeadersInput
|
onBlur={e => handleBlur(e.target.value.trim())}
|
||||||
headers={headers}
|
placeholder={t('tools.mcp.modal.clientID')}
|
||||||
onChange={setHeaders}
|
disabled={isDynamicRegistration}
|
||||||
readonly={false}
|
/>
|
||||||
isMasked={!isCreate && Object.keys(headers).length > 0}
|
</div>
|
||||||
/>
|
<div>
|
||||||
</div>
|
<div className={cn('mb-1 flex h-6 items-center', isDynamicRegistration && 'opacity-50')}>
|
||||||
|
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.clientSecret')}</span>
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
value={credentials}
|
||||||
|
onChange={e => setCredentials(e.target.value)}
|
||||||
|
onBlur={e => handleBlur(e.target.value.trim())}
|
||||||
|
placeholder={t('tools.mcp.modal.clientSecretPlaceholder')}
|
||||||
|
disabled={isDynamicRegistration}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
authMethod === MCPAuthMethod.headers && (
|
||||||
|
<div>
|
||||||
|
<div className='mb-1 flex h-6 items-center'>
|
||||||
|
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.headers')}</span>
|
||||||
|
</div>
|
||||||
|
<div className='body-xs-regular mb-2 text-text-tertiary'>{t('tools.mcp.modal.headersTip')}</div>
|
||||||
|
<HeadersInput
|
||||||
|
headersItems={headers}
|
||||||
|
onChange={setHeaders}
|
||||||
|
readonly={false}
|
||||||
|
isMasked={!isCreate && headers.filter(item => item.key.trim()).length > 0}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
authMethod === MCPAuthMethod.configurations && (
|
||||||
|
<>
|
||||||
|
<div>
|
||||||
|
<div className='mb-1 flex h-6 items-center'>
|
||||||
|
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.timeout')}</span>
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
type='number'
|
||||||
|
value={timeout}
|
||||||
|
onChange={e => setMcpTimeout(Number(e.target.value))}
|
||||||
|
onBlur={e => handleBlur(e.target.value.trim())}
|
||||||
|
placeholder={t('tools.mcp.modal.timeoutPlaceholder')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className='mb-1 flex h-6 items-center'>
|
||||||
|
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.sseReadTimeout')}</span>
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
type='number'
|
||||||
|
value={sseReadTimeout}
|
||||||
|
onChange={e => setSseReadTimeout(Number(e.target.value))}
|
||||||
|
onBlur={e => handleBlur(e.target.value.trim())}
|
||||||
|
placeholder={t('tools.mcp.modal.timeoutPlaceholder')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-row-reverse pt-5'>
|
<div className='flex flex-row-reverse pt-5'>
|
||||||
<Button disabled={!name || !url || !serverIdentifier || isFetchingIcon} className='ml-2' variant='primary' onClick={submit}>{data ? t('tools.mcp.modal.save') : t('tools.mcp.modal.confirm')}</Button>
|
<Button disabled={!name || !url || !serverIdentifier || isFetchingIcon} className='ml-2' variant='primary' onClick={submit}>{data ? t('tools.mcp.modal.save') : t('tools.mcp.modal.confirm')}</Button>
|
||||||
|
|||||||
@ -64,6 +64,15 @@ export type Collection = {
|
|||||||
masked_headers?: Record<string, string>
|
masked_headers?: Record<string, string>
|
||||||
is_authorized?: boolean
|
is_authorized?: boolean
|
||||||
provider?: string
|
provider?: string
|
||||||
|
is_dynamic_registration?: boolean
|
||||||
|
authentication?: {
|
||||||
|
client_id?: string
|
||||||
|
client_secret?: string
|
||||||
|
}
|
||||||
|
configuration?: {
|
||||||
|
timeout?: number
|
||||||
|
sse_read_timeout?: number
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ToolParameter = {
|
export type ToolParameter = {
|
||||||
@ -191,3 +200,9 @@ export type MCPServerDetail = {
|
|||||||
parameters?: Record<string, string>
|
parameters?: Record<string, string>
|
||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum MCPAuthMethod {
|
||||||
|
authentication = 'authentication',
|
||||||
|
headers = 'headers',
|
||||||
|
configurations = 'configurations',
|
||||||
|
}
|
||||||
|
|||||||
@ -203,6 +203,12 @@ const translation = {
|
|||||||
timeout: 'Timeout',
|
timeout: 'Timeout',
|
||||||
sseReadTimeout: 'SSE Read Timeout',
|
sseReadTimeout: 'SSE Read Timeout',
|
||||||
timeoutPlaceholder: '30',
|
timeoutPlaceholder: '30',
|
||||||
|
authentication: 'Authentication',
|
||||||
|
useDynamicClientRegistration: 'Use Dynamic Client Registration',
|
||||||
|
clientID: 'Client ID',
|
||||||
|
clientSecret: 'Client Secret',
|
||||||
|
clientSecretPlaceholder: 'Client Secret',
|
||||||
|
configurations: 'Configurations',
|
||||||
},
|
},
|
||||||
delete: 'Remove MCP Server',
|
delete: 'Remove MCP Server',
|
||||||
deleteConfirmTitle: 'Would you like to remove {{mcp}}?',
|
deleteConfirmTitle: 'Would you like to remove {{mcp}}?',
|
||||||
|
|||||||
@ -203,6 +203,12 @@ const translation = {
|
|||||||
timeout: '超时时间',
|
timeout: '超时时间',
|
||||||
sseReadTimeout: 'SSE 读取超时时间',
|
sseReadTimeout: 'SSE 读取超时时间',
|
||||||
timeoutPlaceholder: '30',
|
timeoutPlaceholder: '30',
|
||||||
|
authentication: '认证',
|
||||||
|
useDynamicClientRegistration: '使用动态客户端注册',
|
||||||
|
clientID: '客户端 ID',
|
||||||
|
clientSecret: '客户端密钥',
|
||||||
|
clientSecretPlaceholder: '客户端密钥',
|
||||||
|
configurations: '配置',
|
||||||
},
|
},
|
||||||
delete: '删除 MCP 服务',
|
delete: '删除 MCP 服务',
|
||||||
deleteConfirmTitle: '你想要删除 {{mcp}} 吗?',
|
deleteConfirmTitle: '你想要删除 {{mcp}} 吗?',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user