n8n-nodes-smart-browser-automation 1.5.0 → 1.5.1
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.
|
@@ -67,7 +67,7 @@ class BrowserSessionManager {
|
|
|
67
67
|
this.config = { mcpEndpoint, cdpEndpoint };
|
|
68
68
|
// Fetch available tools from MCP server
|
|
69
69
|
const toolsResponse = await this.mcpClient.listTools();
|
|
70
|
-
await this.mcpClient.callTool({ name: 'browser_connect_cdp', arguments: {
|
|
70
|
+
await this.mcpClient.callTool({ name: 'browser_connect_cdp', arguments: { endpoint: cdpEndpoint || '' } });
|
|
71
71
|
this.tools = toolsResponse.tools;
|
|
72
72
|
return this.tools;
|
|
73
73
|
}
|
|
@@ -36,66 +36,18 @@ class SmartBrowserAutomation {
|
|
|
36
36
|
description: 'Override CDP endpoint from credentials. Use this to connect to a specific browser instance.',
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
displayName: '
|
|
40
|
-
name: '
|
|
41
|
-
type: '
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
name: 'All Tools',
|
|
46
|
-
value: 'listTools',
|
|
47
|
-
description: 'Get all available browser tools from MCP server',
|
|
48
|
-
action: 'List all browser tools',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'Click',
|
|
52
|
-
value: 'browser_click',
|
|
53
|
-
description: 'Click an element',
|
|
54
|
-
action: 'Click element',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'Connect to Browser',
|
|
58
|
-
value: 'browser_connect_cdp',
|
|
59
|
-
description: 'Connect to browser via CDP',
|
|
60
|
-
action: 'Connect to browser via CDP',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'Navigate',
|
|
64
|
-
value: 'browser_navigate',
|
|
65
|
-
description: 'Navigate to a URL',
|
|
66
|
-
action: 'Navigate to URL',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'Take Snapshot',
|
|
70
|
-
value: 'browser_snapshot',
|
|
71
|
-
description: 'Capture page accessibility snapshot',
|
|
72
|
-
action: 'Take snapshot',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'Type',
|
|
76
|
-
value: 'browser_type',
|
|
77
|
-
description: 'Type text into an element',
|
|
78
|
-
action: 'Type text',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
default: 'browser_connect_cdp',
|
|
39
|
+
displayName: 'Tool Name',
|
|
40
|
+
name: 'toolName',
|
|
41
|
+
type: 'string',
|
|
42
|
+
required: true,
|
|
43
|
+
default: 'browser_navigate',
|
|
44
|
+
description: 'Name of the browser tool to execute (e.g., browser_navigate, browser_click, browser_type, browser_snapshot)',
|
|
82
45
|
},
|
|
83
46
|
{
|
|
84
47
|
displayName: 'Tool Parameters',
|
|
85
48
|
name: 'toolParameters',
|
|
86
49
|
type: 'json',
|
|
87
50
|
required: true,
|
|
88
|
-
displayOptions: {
|
|
89
|
-
show: {
|
|
90
|
-
operation: [
|
|
91
|
-
'browser_connect_cdp',
|
|
92
|
-
'browser_navigate',
|
|
93
|
-
'browser_click',
|
|
94
|
-
'browser_type',
|
|
95
|
-
'browser_snapshot',
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
51
|
default: '{}',
|
|
100
52
|
description: 'Parameters to pass to the browser tool in JSON format',
|
|
101
53
|
},
|
|
@@ -129,21 +81,13 @@ class SmartBrowserAutomation {
|
|
|
129
81
|
const sessionManager = BrowserSessionManager_1.default.getInstance();
|
|
130
82
|
// Get CDP override or use from credentials
|
|
131
83
|
const cdpOverride = this.getNodeParameter('cdpOverride', 0, '');
|
|
132
|
-
const
|
|
84
|
+
const toolName = this.getNodeParameter('toolName', 0);
|
|
133
85
|
try {
|
|
134
86
|
// Initialize session if not ready
|
|
135
87
|
if (!sessionManager.isReady()) {
|
|
136
88
|
const cdpUrl = cdpOverride || credentials.cdpEndpoint || '';
|
|
137
89
|
await sessionManager.initialize(credentials.mcpEndpoint, !!cdpUrl, cdpUrl);
|
|
138
90
|
}
|
|
139
|
-
// Handle listTools operation
|
|
140
|
-
if (operation === 'listTools') {
|
|
141
|
-
const tools = await sessionManager.listTools();
|
|
142
|
-
returnData.push({
|
|
143
|
-
json: { tools },
|
|
144
|
-
});
|
|
145
|
-
return [returnData];
|
|
146
|
-
}
|
|
147
91
|
// Handle tool execution
|
|
148
92
|
let toolParams;
|
|
149
93
|
try {
|
|
@@ -182,7 +126,7 @@ class SmartBrowserAutomation {
|
|
|
182
126
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to parse tool parameters: ${error.message}. Make sure the parameters are valid JSON.`);
|
|
183
127
|
}
|
|
184
128
|
// Special handling for browser_connect_cdp
|
|
185
|
-
if (
|
|
129
|
+
if (toolName === 'browser_connect_cdp') {
|
|
186
130
|
const endpoint = toolParams.endpoint || cdpOverride || credentials.cdpEndpoint;
|
|
187
131
|
if (!endpoint) {
|
|
188
132
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'CDP endpoint is required. Provide it in tool parameters or CDP Endpoint Override field.');
|
|
@@ -201,7 +145,7 @@ class SmartBrowserAutomation {
|
|
|
201
145
|
return [returnData];
|
|
202
146
|
}
|
|
203
147
|
// Execute the tool via MCP
|
|
204
|
-
const result = await sessionManager.callTool(
|
|
148
|
+
const result = await sessionManager.callTool(toolName, toolParams);
|
|
205
149
|
returnData.push({
|
|
206
150
|
json: { result },
|
|
207
151
|
});
|