Skip to content

Commit e61142a

Browse files
committed
feat: add MCP server tools integration and UI components
1 parent 954e15a commit e61142a

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

ui/src/locales/lang/en-US/views/application-workflow.ts

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ export default {
223223
mcpNode: {
224224
label: 'MCP Server',
225225
text: 'Call MCP Tools',
226+
getToolsSuccess: 'Get Tools Successfully',
226227
},
227228
imageGenerateNode: {
228229
label: 'Image Generation',

ui/src/locales/lang/zh-CN/views/application-workflow.ts

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ export default {
223223
mcpNode: {
224224
label: 'MCP 节点',
225225
text: '调用 MCP 工具',
226+
getToolsSuccess: '获取工具成功',
226227
},
227228
imageGenerateNode: {
228229
label: '图片生成',

ui/src/locales/lang/zh-Hant/views/application-workflow.ts

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ export default {
223223
mcpNode: {
224224
label: 'MCP 節點',
225225
text: '呼叫 MCP 工具',
226+
getToolsSuccess: '獲取工具成功',
226227
},
227228
imageGenerateNode: {
228229
label: '圖片生成',

ui/src/workflow/nodes/mcp-node/index.vue

+19-11
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@
5656
<h5 class="title-decoration-1 mb-8">工具参数</h5>
5757
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">
5858
<DynamicsForm
59-
v-model="tool_form_data"
60-
:model="tool_form_data"
59+
v-if="form_data.mcpTool"
60+
v-model="form_data.tool_params"
61+
:model="form_data.tool_params"
6162
label-position="top"
6263
require-asterisk-position="right"
63-
:render_data="tool_form_field"
64+
:render_data="form_data.tool_form_field"
6465
ref="dynamicsFormRef"
6566
>
6667
</DynamicsForm>
@@ -75,7 +76,7 @@ import { isLastNode } from '@/workflow/common/data'
7576
import applicationApi from '@/api/application'
7677
import { t } from '@/locales'
7778
import DynamicsForm from '@/components/dynamics-form/index.vue'
78-
import type { FormField } from '@/components/dynamics-form/type'
79+
import { MsgSuccess } from '@/utils/message'
7980
8081
const props = defineProps<{ nodeModel: any }>()
8182
@@ -92,11 +93,12 @@ const wheel = (e: any) => {
9293
}
9394
}
9495
const form = {
95-
mcpServers: ''
96+
mcpTool: '',
97+
mcpServers: '',
98+
tool_params: {},
99+
tool_form_field: []
96100
}
97101
98-
const tool_form_data = ref({})
99-
const tool_form_field = ref<FormField[]>([])
100102
101103
function submitDialog(val: string) {
102104
set(props.nodeModel.properties.node_data, 'mcpServers', val)
@@ -105,14 +107,15 @@ function submitDialog(val: string) {
105107
function getTools() {
106108
applicationApi.getMcpTools({ mcp_servers: form_data.value.mcpServers }).then((res: any) => {
107109
form_data.value.mcpTools = res.data
110+
MsgSuccess(t('views.applicationWorkflow.nodes.mcpNode.getToolsSuccess'))
108111
})
109112
}
110113
111114
function changeTool() {
112115
const params = form_data.value.mcpTools.filter((item: any) => item.name === form_data.value.mcpTool)[0].args.params
113-
tool_form_field.value = []
116+
form_data.value.tool_form_field = []
114117
for (const item in params.properties) {
115-
tool_form_field.value.push({
118+
form_data.value.tool_form_field.push({
116119
field: item,
117120
label: {
118121
input_type: 'TooltipLabel',
@@ -126,12 +129,17 @@ function changeTool() {
126129
show_default_value: false,
127130
props_info: {
128131
rules: [
129-
{ required: params.required.indexOf(item) !== -1, message: t('dynamicsForm.tip.requiredMessage'), trigger: 'blur' }
132+
{
133+
required: params.required.indexOf(item) !== -1,
134+
message: t('dynamicsForm.tip.requiredMessage'),
135+
trigger: 'blur'
136+
}
130137
]
131138
}
132139
})
133140
}
134-
dynamicsFormRef.value.render(tool_form_field.value, tool_form_data.value)
141+
//
142+
dynamicsFormRef.value?.render(form_data.value.tool_form_field, form_data.value.tool_params)
135143
}
136144
137145
const form_data = computed({

0 commit comments

Comments
 (0)