n8n-nodes-smart-browser-automation 1.6.20 → 1.6.22
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.
|
@@ -96,6 +96,14 @@ class SmartBrowserAutomationTools {
|
|
|
96
96
|
},
|
|
97
97
|
],
|
|
98
98
|
properties: [
|
|
99
|
+
{
|
|
100
|
+
displayName: 'MCP Endpoint Override',
|
|
101
|
+
name: 'mcpEndpointOverride',
|
|
102
|
+
type: 'string',
|
|
103
|
+
default: '',
|
|
104
|
+
placeholder: 'http://localhost:3000',
|
|
105
|
+
description: 'Override the MCP endpoint from credentials (optional)',
|
|
106
|
+
},
|
|
99
107
|
{
|
|
100
108
|
displayName: 'CDP Endpoint Override',
|
|
101
109
|
name: 'cdpOverride',
|
|
@@ -110,28 +118,31 @@ class SmartBrowserAutomationTools {
|
|
|
110
118
|
const node = this.getNode();
|
|
111
119
|
const credentials = await this.getCredentials('smartBrowserAutomationApi');
|
|
112
120
|
const sessionManager = BrowserSessionManager_1.default.getInstance();
|
|
121
|
+
const mcpOverride = this.getNodeParameter('mcpEndpointOverride', itemIndex, '');
|
|
113
122
|
const cdpOverride = this.getNodeParameter('cdpOverride', itemIndex, '');
|
|
114
123
|
const useCDP = credentials.browserMode === 'cdp';
|
|
115
124
|
const cdpUrl = (cdpOverride || credentials.cdpEndpoint || '').trim();
|
|
116
|
-
const mcpEndpoint = (credentials.mcpEndpoint || '').trim();
|
|
125
|
+
const mcpEndpoint = (mcpOverride || credentials.mcpEndpoint || '').trim();
|
|
117
126
|
if (!mcpEndpoint) {
|
|
118
127
|
throw new n8n_workflow_1.NodeOperationError(node, 'MCP Endpoint is required in credentials', {
|
|
119
128
|
itemIndex,
|
|
120
|
-
description: '
|
|
129
|
+
description: 'Configure MCP Endpoint in Smart Browser Automation credentials (e.g. http://localhost:3000 or https://host/sse)',
|
|
121
130
|
});
|
|
122
131
|
}
|
|
132
|
+
// Basic pre-validation so users see a clear error in the UI
|
|
133
|
+
if (!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(mcpEndpoint)) {
|
|
134
|
+
throw new n8n_workflow_1.NodeOperationError(node, `MCP Endpoint looks incomplete: "${mcpEndpoint}" (add http:// or https://)`, { itemIndex });
|
|
135
|
+
}
|
|
123
136
|
try {
|
|
124
137
|
await sessionManager.initialize(mcpEndpoint, useCDP, useCDP ? cdpUrl : undefined);
|
|
125
138
|
}
|
|
126
139
|
catch (error) {
|
|
127
|
-
|
|
140
|
+
const e = error;
|
|
141
|
+
const mode = useCDP ? 'cdp' : 'launch';
|
|
142
|
+
const details = `mcp=${mcpEndpoint} | mode=${mode}${useCDP ? ` | cdp=${cdpUrl || 'unset'}` : ''}`;
|
|
143
|
+
throw new n8n_workflow_1.NodeOperationError(node, `Failed to connect to MCP: ${e.message}`, {
|
|
128
144
|
itemIndex,
|
|
129
|
-
description:
|
|
130
|
-
mcpEndpoint,
|
|
131
|
-
browserMode: credentials.browserMode,
|
|
132
|
-
useCDP,
|
|
133
|
-
cdpEndpoint: useCDP ? cdpUrl : undefined,
|
|
134
|
-
}),
|
|
145
|
+
description: details,
|
|
135
146
|
});
|
|
136
147
|
}
|
|
137
148
|
const mcpTools = await sessionManager.listTools();
|