mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 13:15:58 +08:00
feat: in tools fetch mcp
This commit is contained in:
parent
4d565819f9
commit
8d2238d631
@ -40,6 +40,7 @@ import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import {
|
||||
fetchAllBuiltInTools,
|
||||
fetchAllCustomTools,
|
||||
fetchAllMCPTools,
|
||||
fetchAllWorkflowTools,
|
||||
} from '@/service/tools'
|
||||
import { CollectionType } from '@/app/components/tools/types'
|
||||
@ -450,6 +451,13 @@ export const useFetchToolsData = () => {
|
||||
workflowTools: workflowTools || [],
|
||||
})
|
||||
}
|
||||
if(type === 'mcp') {
|
||||
const mcpTools = await fetchAllMCPTools()
|
||||
|
||||
workflowStore.setState({
|
||||
mcpTools: mcpTools || [],
|
||||
})
|
||||
}
|
||||
}, [workflowStore])
|
||||
|
||||
return {
|
||||
|
@ -205,6 +205,7 @@ export const Workflow: FC<WorkflowProps> = memo(({
|
||||
handleFetchAllTools('builtin')
|
||||
handleFetchAllTools('custom')
|
||||
handleFetchAllTools('workflow')
|
||||
handleFetchAllTools('mcp')
|
||||
}, [handleFetchAllTools])
|
||||
|
||||
const {
|
||||
|
@ -37,6 +37,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
||||
const buildInTools = useStore(s => s.buildInTools)
|
||||
const customTools = useStore(s => s.customTools)
|
||||
const workflowTools = useStore(s => s.workflowTools)
|
||||
const mcpTools = useStore(s => s.mcpTools)
|
||||
|
||||
const currentTools = (() => {
|
||||
switch (provider_type) {
|
||||
@ -46,6 +47,8 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
||||
return customTools
|
||||
case CollectionType.workflow:
|
||||
return workflowTools
|
||||
case CollectionType.mcp:
|
||||
return mcpTools
|
||||
default:
|
||||
return []
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ export type ToolSliceShape = {
|
||||
setCustomTools: (tools: ToolWithProvider[]) => void
|
||||
workflowTools: ToolWithProvider[]
|
||||
setWorkflowTools: (tools: ToolWithProvider[]) => void
|
||||
mcpTools: ToolWithProvider[]
|
||||
setMcpTools: (tools: ToolWithProvider[]) => void
|
||||
toolPublished: boolean
|
||||
setToolPublished: (toolPublished: boolean) => void
|
||||
}
|
||||
@ -21,6 +23,8 @@ export const createToolSlice: StateCreator<ToolSliceShape> = set => ({
|
||||
setCustomTools: customTools => set(() => ({ customTools })),
|
||||
workflowTools: [],
|
||||
setWorkflowTools: workflowTools => set(() => ({ workflowTools })),
|
||||
mcpTools: [],
|
||||
setMcpTools: mcpTools => set(() => ({ mcpTools })),
|
||||
toolPublished: false,
|
||||
setToolPublished: toolPublished => set(() => ({ toolPublished })),
|
||||
})
|
||||
|
@ -124,6 +124,10 @@ export const fetchAllWorkflowTools = () => {
|
||||
return get<ToolWithProvider[]>('/workspaces/current/tools/workflow')
|
||||
}
|
||||
|
||||
export const fetchAllMCPTools = () => {
|
||||
return get<ToolWithProvider[]>('/workspaces/current/tools/mcp')
|
||||
}
|
||||
|
||||
export const fetchLabelList = () => {
|
||||
return get<Label[]>('/workspaces/current/tool-labels')
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user