diff --git a/ui/src/workflow-canvas/nodes/ai-chat-node/component/resource-setting/McpSettingDialog.vue b/ui/src/workflow-canvas/nodes/ai-chat-node/component/resource-setting/McpSettingDialog.vue index ad14fc48334..6bde3eb995b 100644 --- a/ui/src/workflow-canvas/nodes/ai-chat-node/component/resource-setting/McpSettingDialog.vue +++ b/ui/src/workflow-canvas/nodes/ai-chat-node/component/resource-setting/McpSettingDialog.vue @@ -29,8 +29,17 @@ const formData = ref({ mcp_servers: '', mcp_source: 'referencing', m const mcpOptions = ref([]) const loading = ref(false) +// 接口可能返回对象配置;空对象表示未配置,非空对象转为 JSON 文本供输入框编辑。 +function normalizeMcpServers(value: unknown): string { + if (value == null) return '' + if (typeof value === 'string') return value + if (typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0) return '' + return JSON.stringify(value, null, 2) ?? '' +} + function open(setting: McpSetting) { formData.value = cloneDeep(setting) + formData.value.mcp_servers = normalizeMcpServers(setting.mcp_servers) if (formData.value.mcp_servers) formData.value.mcp_source = 'custom' visible.value = true @@ -107,10 +116,14 @@ defineExpose({ open }) +