From 74b027c41af3c26e1bbe6883f549b774b1706e05 Mon Sep 17 00:00:00 2001 From: wangxiaolei Date: Wed, 4 Feb 2026 17:33:41 +0800 Subject: [PATCH] fix: fix mcp output schema is union type frontend crash (#31779) Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> --- .../workflow/nodes/tool/use-config.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/web/app/components/workflow/nodes/tool/use-config.ts b/web/app/components/workflow/nodes/tool/use-config.ts index 7e4594f4f2..87e9186008 100644 --- a/web/app/components/workflow/nodes/tool/use-config.ts +++ b/web/app/components/workflow/nodes/tool/use-config.ts @@ -1,6 +1,7 @@ import type { ToolNodeType, ToolVarInputs } from './types' import type { InputVar } from '@/app/components/workflow/types' import { useBoolean } from 'ahooks' +import { capitalize } from 'es-toolkit/string' import { produce } from 'immer' import { useCallback, useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -25,6 +26,12 @@ import { } from '@/service/use-tools' import { canFindTool } from '@/utils' import { useWorkflowStore } from '../../store' +import { normalizeJsonSchemaType } from './output-schema-utils' + +const formatDisplayType = (output: Record): string => { + const normalizedType = normalizeJsonSchemaType(output) || 'Unknown' + return capitalize(normalizedType) +} const useConfig = (id: string, payload: ToolNodeType) => { const workflowStore = useWorkflowStore() @@ -247,20 +254,13 @@ const useConfig = (id: string, payload: ToolNodeType) => { }) } else { + const normalizedType = normalizeJsonSchemaType(output) res.push({ name: outputKey, type: - output.type === 'array' - ? `Array[${output.items?.type - ? output.items.type.slice(0, 1).toLocaleUpperCase() - + output.items.type.slice(1) - : 'Unknown' - }]` - : `${output.type - ? output.type.slice(0, 1).toLocaleUpperCase() - + output.type.slice(1) - : 'Unknown' - }`, + normalizedType === 'array' + ? `Array[${output.items ? formatDisplayType(output.items) : 'Unknown'}]` + : formatDisplayType(output), description: output.description, }) }