mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix(MCP Client Tool Node): Stringify tool result (#14554)
This commit is contained in:
@@ -57,7 +57,7 @@ describe('McpClientTool', () => {
|
|||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a valid toolkit with usable tools', async () => {
|
it('should return a valid toolkit with usable tools (that returns a string)', async () => {
|
||||||
jest.spyOn(Client.prototype, 'connect').mockResolvedValue();
|
jest.spyOn(Client.prototype, 'connect').mockResolvedValue();
|
||||||
jest
|
jest
|
||||||
.spyOn(Client.prototype, 'callTool')
|
.spyOn(Client.prototype, 'callTool')
|
||||||
@@ -93,7 +93,7 @@ describe('McpClientTool', () => {
|
|||||||
expect(tools).toHaveLength(2);
|
expect(tools).toHaveLength(2);
|
||||||
|
|
||||||
const toolCallResult = await tools[0].invoke({ input: 'foo' });
|
const toolCallResult = await tools[0].invoke({ input: 'foo' });
|
||||||
expect(toolCallResult).toEqual([{ type: 'text', text: 'result from tool' }]);
|
expect(toolCallResult).toEqual(JSON.stringify([{ type: 'text', text: 'result from tool' }]));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support selecting tools to expose', async () => {
|
it('should support selecting tools to expose', async () => {
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ export class McpServer {
|
|||||||
return {
|
return {
|
||||||
name: tool.name,
|
name: tool.name,
|
||||||
description: tool.description,
|
description: tool.description,
|
||||||
inputSchema: zodToJsonSchema(tool.schema),
|
// Allow additional properties on tool call input
|
||||||
|
inputSchema: zodToJsonSchema(tool.schema, { removeAdditionalStrategy: 'strict' }),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -395,7 +395,9 @@ export function logWrapper<
|
|||||||
|
|
||||||
logAiEvent(executeFunctions, 'ai-tool-called', { ...inputData, response });
|
logAiEvent(executeFunctions, 'ai-tool-called', { ...inputData, response });
|
||||||
executeFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);
|
executeFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]);
|
||||||
return response;
|
|
||||||
|
if (typeof response === 'string') return response;
|
||||||
|
return JSON.stringify(response);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user