feat: in tools fetch mcp

This commit is contained in:
Joel 2025-05-27 15:09:44 +08:00
parent 4d565819f9
commit 8d2238d631
5 changed files with 20 additions and 0 deletions

View File

@ -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 {

View File

@ -205,6 +205,7 @@ export const Workflow: FC<WorkflowProps> = memo(({
handleFetchAllTools('builtin')
handleFetchAllTools('custom')
handleFetchAllTools('workflow')
handleFetchAllTools('mcp')
}, [handleFetchAllTools])
const {

View File

@ -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 []
}

View File

@ -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 })),
})

View File

@ -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')
}