fix: old mcp tool compatible (#5399)
Some checks are pending
Build FastGPT images in Personal warehouse / get-vars (push) Waiting to run
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:amd64 runs-on:ubuntu-24.04]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / release-fastgpt-images (push) Blocked by required conditions

This commit is contained in:
Finley Ge 2025-08-07 11:37:26 +08:00 committed by GitHub
parent 318d21ec25
commit 17599d95bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,7 +42,7 @@ import type {
import { isProduction } from '@fastgpt/global/common/system/constants';
import { Output_Template_Error_Message } from '@fastgpt/global/core/workflow/template/output';
import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils';
import { getMCPToolRuntimeNode } from '@fastgpt/global/core/app/mcpTools/utils';
import { getMCPParentId, getMCPToolRuntimeNode } from '@fastgpt/global/core/app/mcpTools/utils';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { getMCPChildren } from '../mcp';
import { cloneDeep } from 'lodash';
@ -227,9 +227,15 @@ export async function getChildAppPreviewNode({
const version = await getAppVersionById({ appId: parentId, versionId, app: item });
const toolConfig = version.nodes[0].toolConfig?.mcpToolSet;
const tool = toolConfig?.toolList.find((item) => item.name === toolName);
if (!tool || !toolConfig) return Promise.reject(PluginErrEnum.unExist);
const tool = await (async () => {
if (toolConfig?.toolList) {
// new mcp toolset
return toolConfig.toolList.find((item) => item.name === toolName);
}
// old mcp toolset
return (await getMCPChildren(item)).find((item) => item.name === toolName);
})();
if (!tool) return Promise.reject(PluginErrEnum.unExist);
return {
avatar: item.avatar,
id: appId,