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 { import {
fetchAllBuiltInTools, fetchAllBuiltInTools,
fetchAllCustomTools, fetchAllCustomTools,
fetchAllMCPTools,
fetchAllWorkflowTools, fetchAllWorkflowTools,
} from '@/service/tools' } from '@/service/tools'
import { CollectionType } from '@/app/components/tools/types' import { CollectionType } from '@/app/components/tools/types'
@ -450,6 +451,13 @@ export const useFetchToolsData = () => {
workflowTools: workflowTools || [], workflowTools: workflowTools || [],
}) })
} }
if(type === 'mcp') {
const mcpTools = await fetchAllMCPTools()
workflowStore.setState({
mcpTools: mcpTools || [],
})
}
}, [workflowStore]) }, [workflowStore])
return { return {

View File

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

View File

@ -37,6 +37,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
const buildInTools = useStore(s => s.buildInTools) const buildInTools = useStore(s => s.buildInTools)
const customTools = useStore(s => s.customTools) const customTools = useStore(s => s.customTools)
const workflowTools = useStore(s => s.workflowTools) const workflowTools = useStore(s => s.workflowTools)
const mcpTools = useStore(s => s.mcpTools)
const currentTools = (() => { const currentTools = (() => {
switch (provider_type) { switch (provider_type) {
@ -46,6 +47,8 @@ const useConfig = (id: string, payload: ToolNodeType) => {
return customTools return customTools
case CollectionType.workflow: case CollectionType.workflow:
return workflowTools return workflowTools
case CollectionType.mcp:
return mcpTools
default: default:
return [] return []
} }

View File

@ -10,6 +10,8 @@ export type ToolSliceShape = {
setCustomTools: (tools: ToolWithProvider[]) => void setCustomTools: (tools: ToolWithProvider[]) => void
workflowTools: ToolWithProvider[] workflowTools: ToolWithProvider[]
setWorkflowTools: (tools: ToolWithProvider[]) => void setWorkflowTools: (tools: ToolWithProvider[]) => void
mcpTools: ToolWithProvider[]
setMcpTools: (tools: ToolWithProvider[]) => void
toolPublished: boolean toolPublished: boolean
setToolPublished: (toolPublished: boolean) => void setToolPublished: (toolPublished: boolean) => void
} }
@ -21,6 +23,8 @@ export const createToolSlice: StateCreator<ToolSliceShape> = set => ({
setCustomTools: customTools => set(() => ({ customTools })), setCustomTools: customTools => set(() => ({ customTools })),
workflowTools: [], workflowTools: [],
setWorkflowTools: workflowTools => set(() => ({ workflowTools })), setWorkflowTools: workflowTools => set(() => ({ workflowTools })),
mcpTools: [],
setMcpTools: mcpTools => set(() => ({ mcpTools })),
toolPublished: false, toolPublished: false,
setToolPublished: toolPublished => set(() => ({ toolPublished })), setToolPublished: toolPublished => set(() => ({ toolPublished })),
}) })

View File

@ -124,6 +124,10 @@ export const fetchAllWorkflowTools = () => {
return get<ToolWithProvider[]>('/workspaces/current/tools/workflow') return get<ToolWithProvider[]>('/workspaces/current/tools/workflow')
} }
export const fetchAllMCPTools = () => {
return get<ToolWithProvider[]>('/workspaces/current/tools/mcp')
}
export const fetchLabelList = () => { export const fetchLabelList = () => {
return get<Label[]>('/workspaces/current/tool-labels') return get<Label[]>('/workspaces/current/tool-labels')
} }