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

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.
@@ -50,10 +50,15 @@ class BrowserSessionManager {
50
50
  }
51
51
  async initialize(mcpEndpoint, useCDP, cdpEndpoint) {
52
52
  // Validate endpoint inputs early to avoid confusing runtime errors
53
- const trimmedMcpEndpoint = String(mcpEndpoint ?? '').trim();
53
+ let trimmedMcpEndpoint = String(mcpEndpoint ?? '').trim();
54
54
  if (!trimmedMcpEndpoint) {
55
55
  throw new Error('MCP Endpoint is required');
56
56
  }
57
+ // Be forgiving: if user passes host:port without scheme, assume http://
58
+ // Examples: localhost:3000, 127.0.0.1:3000, example.com:8080
59
+ if (!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmedMcpEndpoint)) {
60
+ trimmedMcpEndpoint = `http://${trimmedMcpEndpoint}`;
61
+ }
57
62
  if (/^wss?:\/\//i.test(trimmedMcpEndpoint)) {
58
63
  throw new Error(`Invalid MCP Endpoint: "${trimmedMcpEndpoint}". ` +
59
64
  'MCP Endpoint must be an http(s) URL (for SSE or Streamable HTTP). ' +
@@ -1,5 +1,6 @@
1
- import { type INodeType, type INodeTypeDescription, type ISupplyDataFunctions, type SupplyData } from 'n8n-workflow';
1
+ import { type IExecuteFunctions, type INodeExecutionData, type INodeType, type INodeTypeDescription, type ISupplyDataFunctions, type SupplyData } from 'n8n-workflow';
2
2
  export declare class SmartBrowserAutomationTools implements INodeType {
3
3
  description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
4
5
  supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
5
6
  }
@@ -66,8 +66,8 @@ class SmartBrowserAutomationTools {
66
66
  name: 'Browser Automation Tools',
67
67
  },
68
68
  inputs: [],
69
- outputs: [n8n_workflow_1.NodeConnectionTypes.AiTool],
70
- outputNames: ['Tools'],
69
+ outputs: [n8n_workflow_1.NodeConnectionTypes.AiTool, n8n_workflow_1.NodeConnectionTypes.Main],
70
+ outputNames: ['Tools', 'Debug'],
71
71
  icon: 'file:smartBrowserAutomation.svg',
72
72
  credentials: [
73
73
  {
@@ -86,6 +86,44 @@ class SmartBrowserAutomationTools {
86
86
  },
87
87
  ],
88
88
  };
89
+ async execute() {
90
+ const node = this.getNode();
91
+ const sessionManager = BrowserSessionManager_1.default.getInstance();
92
+ const itemIndex = 0;
93
+ try {
94
+ const credentials = await this.getCredentials('smartBrowserAutomationApi');
95
+ const cdpOverride = this.getNodeParameter('cdpOverride', itemIndex, '');
96
+ const useCDP = credentials.browserMode === 'cdp';
97
+ const cdpUrl = (cdpOverride || credentials.cdpEndpoint || '').trim();
98
+ await sessionManager.initialize(credentials.mcpEndpoint, useCDP, useCDP ? cdpUrl : undefined);
99
+ const mcpTools = await sessionManager.listTools();
100
+ const debugJson = {
101
+ mcpEndpoint: credentials.mcpEndpoint,
102
+ browserMode: credentials.browserMode,
103
+ useCDP,
104
+ cdpEndpoint: useCDP ? cdpUrl : undefined,
105
+ toolCount: mcpTools.length,
106
+ tools: mcpTools.map((t) => ({
107
+ name: t.name,
108
+ description: t.description ?? '',
109
+ inputSchema: t.inputSchema ?? undefined,
110
+ })),
111
+ };
112
+ return [[], [{ json: debugJson }]];
113
+ }
114
+ catch (error) {
115
+ const err = error;
116
+ const debugJson = {
117
+ error: true,
118
+ message: err?.message ? String(err.message) : String(err),
119
+ code: err?.code ? String(err.code) : undefined,
120
+ };
121
+ throw new n8n_workflow_1.NodeOperationError(node, debugJson.message, { itemIndex, description: JSON.stringify(debugJson) });
122
+ }
123
+ finally {
124
+ await sessionManager.close();
125
+ }
126
+ }
89
127
  async supplyData(itemIndex) {
90
128
  const node = this.getNode();
91
129
  const credentials = await this.getCredentials('smartBrowserAutomationApi');
@@ -99,6 +137,12 @@ class SmartBrowserAutomationTools {
99
137
  catch (error) {
100
138
  throw new n8n_workflow_1.NodeOperationError(node, `Failed to connect to MCP server: ${error.message}`, {
101
139
  itemIndex,
140
+ description: JSON.stringify({
141
+ mcpEndpoint: credentials.mcpEndpoint,
142
+ browserMode: credentials.browserMode,
143
+ useCDP,
144
+ cdpEndpoint: useCDP ? cdpUrl : undefined,
145
+ }),
102
146
  });
103
147
  }
104
148
  const mcpTools = await sessionManager.listTools();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-smart-browser-automation",
3
- "version": "1.6.15",
3
+ "version": "1.6.17",
4
4
  "description": "n8n node for AI-driven browser automation using MCP",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",