fix: Do not throw on tool errors, instead return error message (#17558)

This commit is contained in:
Elias Meire
2025-07-23 12:54:31 +02:00
committed by GitHub
parent 917eabe2f7
commit f11ec538dc
3 changed files with 94 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
import { logWrapper } from '@utils/logWrapper';
import { getConnectionHintNoticeField } from '@utils/sharedFields';
import {
NodeConnectionTypes,
NodeOperationError,
@@ -7,9 +9,6 @@ import {
type SupplyData,
} from 'n8n-workflow';
import { logWrapper } from '@utils/logWrapper';
import { getConnectionHintNoticeField } from '@utils/sharedFields';
import { getTools } from './loadOptions';
import type { McpServerTransport, McpAuthenticationOption, McpToolIncludeMode } from './types';
import {
@@ -294,11 +293,10 @@ export class McpClientTool implements INodeType {
logWrapper(
mcpToolToDynamicTool(
tool,
createCallTool(tool.name, client.result, (error) => {
createCallTool(tool.name, client.result, (errorMessage) => {
const error = new NodeOperationError(node, errorMessage, { itemIndex });
void this.addOutputData(NodeConnectionTypes.AiTool, itemIndex, error);
this.logger.error(`McpClientTool: Tool "${tool.name}" failed to execute`, { error });
throw new NodeOperationError(node, `Failed to execute tool "${tool.name}"`, {
description: error,
});
}),
),
this,