n8n-nodes-smart-browser-automation 1.6.17 → 1.6.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,6 +55,26 @@ async function importToolkitBase() {
55
55
  // n8n uses Toolkit from @langchain/classic/agents internally.
56
56
  return await Promise.resolve().then(() => __importStar(require('@langchain/classic/agents')));
57
57
  }
58
+ function formatMcpToolResult(result) {
59
+ if (result === null || result === undefined)
60
+ return '';
61
+ if (typeof result === 'string')
62
+ return result;
63
+ const content = result?.content;
64
+ if (Array.isArray(content)) {
65
+ const texts = content
66
+ .map((c) => (c?.type === 'text' ? String(c?.text ?? '') : ''))
67
+ .filter((t) => t.length > 0);
68
+ if (texts.length)
69
+ return texts.join('\n');
70
+ }
71
+ try {
72
+ return JSON.stringify(result);
73
+ }
74
+ catch {
75
+ return String(result);
76
+ }
77
+ }
58
78
  class SmartBrowserAutomationTools {
59
79
  description = {
60
80
  displayName: 'Smart Browser Automation Tools',
@@ -151,14 +171,37 @@ class SmartBrowserAutomationTools {
151
171
  }
152
172
  const { DynamicStructuredTool } = await importDynamicStructuredTool();
153
173
  const { Toolkit } = await importToolkitBase();
174
+ const ctx = this;
154
175
  const tools = await Promise.all(mcpTools.map(async (tool) => {
155
176
  const schema = await (0, jsonSchemaToZod_1.jsonSchemaToZod)(tool.inputSchema);
177
+ const toolName = tool.name;
178
+ const toolDescription = (tool.description ?? '');
156
179
  return new DynamicStructuredTool({
157
- name: tool.name,
158
- description: tool.description ?? '',
180
+ name: toolName,
181
+ description: toolDescription,
159
182
  schema,
160
183
  func: async (args) => {
161
- return await sessionManager.callTool(tool.name, args);
184
+ // Make tool calls visible in n8n execution UI
185
+ const input = {
186
+ tool: toolName,
187
+ arguments: args,
188
+ };
189
+ let runIndex = 0;
190
+ try {
191
+ runIndex = ctx.getNextRunIndex?.() ?? 0;
192
+ }
193
+ catch { }
194
+ const { index } = ctx.addInputData(n8n_workflow_1.NodeConnectionTypes.AiTool, [[{ json: input }]], runIndex);
195
+ try {
196
+ const result = await sessionManager.callTool(toolName, args);
197
+ const output = { tool: toolName, result };
198
+ ctx.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiTool, index, [[{ json: output }]]);
199
+ return formatMcpToolResult(result);
200
+ }
201
+ catch (e) {
202
+ ctx.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiTool, index, e);
203
+ throw e;
204
+ }
162
205
  },
163
206
  metadata: { isFromToolkit: true },
164
207
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-smart-browser-automation",
3
- "version": "1.6.17",
3
+ "version": "1.6.18",
4
4
  "description": "n8n node for AI-driven browser automation using MCP",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",