Skip to content

Commit 0f0b6b9

Browse files
committed
feat: add MCP server config validation and user tips
1 parent f681cb9 commit 0f0b6b9

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ export default {
226226
getToolsSuccess: 'Get Tools Successfully',
227227
getTool: 'Get Tools',
228228
tool: 'Tool',
229-
toolParam: 'Tool Params'
229+
toolParam: 'Tool Params',
230+
mcpServerTip: 'Please enter the JSON format of the MCP server config',
230231
},
231232
imageGenerateNode: {
232233
label: 'Image Generation',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ export default {
226226
getToolsSuccess: '获取工具成功',
227227
getTool: '获取工具',
228228
tool: '工具',
229-
toolParam: '工具参数'
229+
toolParam: '工具参数',
230+
mcpServerTip: '请输入 JSON 格式的 MCP 服务器配置',
230231
},
231232
imageGenerateNode: {
232233
label: '图片生成',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ export default {
226226
getToolsSuccess: '獲取工具成功',
227227
getTool: '獲取工具',
228228
tool: '工具',
229-
toolParam: '工具變數'
229+
toolParam: '工具變數',
230+
mcpServerTip: '請輸入 JSON 格式的 MCP 服務器配置',
230231
},
231232
imageGenerateNode: {
232233
label: '圖片生成',

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ import { isLastNode } from '@/workflow/common/data'
9090
import applicationApi from '@/api/application'
9191
import { t } from '@/locales'
9292
import DynamicsForm from '@/components/dynamics-form/index.vue'
93-
import { MsgSuccess } from '@/utils/message'
93+
import { MsgError, MsgSuccess } from '@/utils/message'
9494
9595
const props = defineProps<{ nodeModel: any }>()
9696
9797
const dynamicsFormRef = ref()
98-
98+
const loading = ref(false)
9999
100100
const wheel = (e: any) => {
101101
if (e.ctrlKey === true) {
@@ -122,7 +122,17 @@ function submitDialog(val: string) {
122122
}
123123
124124
function getTools() {
125-
applicationApi.getMcpTools({ mcp_servers: form_data.value.mcp_servers }).then((res: any) => {
125+
if (!form_data.value.mcp_servers) {
126+
MsgError(t('views.applicationWorkflow.nodes.mcpNode.mcpServerTip'))
127+
return
128+
}
129+
try {
130+
JSON.parse(form_data.value.mcp_servers)
131+
} catch (e) {
132+
MsgError(t('views.applicationWorkflow.nodes.mcpNode.mcpServerTip'))
133+
return
134+
}
135+
applicationApi.getMcpTools({ mcp_servers: form_data.value.mcp_servers }, loading).then((res: any) => {
126136
form_data.value.mcp_tools = res.data
127137
MsgSuccess(t('views.applicationWorkflow.nodes.mcpNode.getToolsSuccess'))
128138
})

0 commit comments

Comments
 (0)