n8n-nodes-smart-browser-automation 1.1.12 → 1.1.13

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.
@@ -75,8 +75,10 @@ class BrowserSessionManager {
75
75
  throw new Error('MCP client not initialized. Please configure credentials first.');
76
76
  }
77
77
  try {
78
- // Log exact payload to debug truncation issues reported by users
79
- console.log(`[MCP] Calling tool "${toolName}" with args:`, JSON.stringify(toolArgs || {}));
78
+ // Only log in development/debug mode
79
+ if (process.env.NODE_ENV !== 'production' && process.env.DEBUG) {
80
+ console.log(`[MCP] Calling tool "${toolName}" with args:`, JSON.stringify(toolArgs || {}));
81
+ }
80
82
  const result = await this.mcpClient.callTool({
81
83
  name: toolName,
82
84
  arguments: toolArgs || {}
@@ -237,7 +237,9 @@ class SmartBrowserAutomation {
237
237
  await sessionManager.initialize(credentials.mcpEndpoint, true, endpoint);
238
238
  return {
239
239
  content: [{ type: 'text', text: `Connected to browser at ${endpoint}.` }],
240
- isError: false
240
+ isError: false,
241
+ toolName: 'browser_connect_cdp',
242
+ requestedAction: input.action
241
243
  };
242
244
  }
243
245
  }
@@ -262,12 +264,19 @@ class SmartBrowserAutomation {
262
264
  console.log(`[Router] Routing '${input.action}' to '${toolName}' with args:`, toolArgs);
263
265
  try {
264
266
  const result = await sessionManager.callTool(toolName, toolArgs);
267
+ // Add tool name to result for visibility
268
+ if (result && typeof result === 'object') {
269
+ result.toolName = toolName;
270
+ result.requestedAction = input.action;
271
+ }
265
272
  return result;
266
273
  }
267
274
  catch (error) {
268
275
  return {
269
276
  content: [{ type: 'text', text: `Error executing ${toolName}: ${error.message}` }],
270
- isError: true
277
+ isError: true,
278
+ toolName: toolName,
279
+ requestedAction: input.action
271
280
  };
272
281
  }
273
282
  }
@@ -293,7 +302,8 @@ class SmartBrowserAutomation {
293
302
  await sessionManager.initialize(credentials.mcpEndpoint, true, input.endpoint);
294
303
  return {
295
304
  content: [{ type: 'text', text: `Connected to browser at ${input.endpoint}.` }],
296
- isError: false
305
+ isError: false,
306
+ toolName: 'browser_connect_cdp'
297
307
  };
298
308
  }
299
309
  };
@@ -359,45 +369,39 @@ class SmartBrowserAutomation {
359
369
  if (operation === 'initialize') {
360
370
  const cdpUrl = credentials.cdpEndpoint;
361
371
  await sessionManager.initialize(credentials.mcpEndpoint, true, cdpUrl);
362
- let connectionStatus = 'Skipped (No CDP URL provided)';
363
- let connectionResult = null;
364
372
  // New logic: Auto-call browser_connect_cdp tool if a URL is provided
365
373
  if (options.cdpUrl) {
366
374
  if (verbose) {
367
375
  console.log(`Auto-calling 'browser_connect_cdp' with endpoint: ${options.cdpUrl}`);
368
376
  }
369
377
  try {
370
- connectionResult = await sessionManager.callTool('browser_connect_cdp', { endpoint: options.cdpUrl });
371
- connectionStatus = 'Successfully connected';
378
+ const connectionResult = await sessionManager.callTool('browser_connect_cdp', { endpoint: options.cdpUrl });
379
+ // Return only the connection result, no extra messages
380
+ returnData.push({
381
+ json: connectionResult,
382
+ pairedItem: i,
383
+ });
372
384
  }
373
385
  catch (error) {
374
- connectionStatus = `Failed to connect: ${error.message}`;
375
- console.warn(`Failed to auto-connect browser via tool: ${error.message}`);
386
+ returnData.push({
387
+ json: {
388
+ success: false,
389
+ error: `Failed to connect: ${error.message}`
390
+ },
391
+ pairedItem: i,
392
+ });
376
393
  }
377
394
  }
378
- // Guide for the Router Tool
379
- const actionGuide = `
380
- Actions available via 'browser_tool':
381
- - navigate: { "url": "https://..." }
382
- - click: { "selector": "..." }
383
- - type: { "selector": "...", "text": "..." }
384
- - press_key: { "key": "Enter" }
385
- - scroll_to: { "selector": "..." }
386
- - get_text: { "selector": "..." }
387
- - take_screenshot: {}
388
- - evaluate: { "script": "return document.title;" }
389
- ...and all other MCP tools.
390
- `;
391
- returnData.push({
392
- json: {
393
- success: true,
394
- message: `MCP session initialized at ${credentials.mcpEndpoint}`,
395
- browserConnection: connectionStatus,
396
- browserResponse: connectionResult,
397
- toolGuide: actionGuide,
398
- },
399
- pairedItem: i,
400
- });
395
+ else {
396
+ // No CDP URL provided
397
+ returnData.push({
398
+ json: {
399
+ success: true,
400
+ message: 'MCP session initialized (no browser connection)'
401
+ },
402
+ pairedItem: i,
403
+ });
404
+ }
401
405
  }
402
406
  else if (operation === 'close') {
403
407
  await sessionManager.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-smart-browser-automation",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "n8n node for AI-driven browser automation using MCP",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",