n8n-nodes-smart-browser-automation 1.3.0 → 1.3.2

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.
@@ -108,9 +108,25 @@ class SmartBrowserAutomation {
108
108
  };
109
109
  // Expose tools to AI Agent nodes
110
110
  async getTools() {
111
+ const sessionManager = BrowserSessionManager_1.default.getInstance();
111
112
  const credentials = await this.getCredentials('smartBrowserAutomationApi');
113
+ console.log('[getTools] Starting to fetch tools...');
114
+ // Check if session is already initialized
115
+ if (!sessionManager.isReady()) {
116
+ console.log('[getTools] Session not ready, initializing...');
117
+ try {
118
+ await sessionManager.initialize(credentials.mcpEndpoint, credentials.browserMode === 'cdp', credentials.cdpEndpoint);
119
+ console.log('[getTools] Session initialized successfully');
120
+ }
121
+ catch (error) {
122
+ console.error('[getTools] Failed to initialize session:', error.message);
123
+ // Return minimal tools if initialization fails
124
+ return [];
125
+ }
126
+ }
112
127
  // Get all individual MCP tools
113
128
  const mcpTools = await (0, DynamicBrowserTools_1.createDynamicBrowserTools)(credentials);
129
+ console.log(`[getTools] Fetched ${mcpTools.length} MCP tools`);
114
130
  // Add custom CDP connection tool
115
131
  const connectTool = {
116
132
  name: 'browser_connect_cdp',
@@ -51,6 +51,7 @@ async function createDynamicBrowserTools(credentials) {
51
51
  const sessionManager = BrowserSessionManager_1.default.getInstance();
52
52
  // Initialize and get MCP tools
53
53
  const mcpTools = await sessionManager.initialize(credentials.mcpEndpoint, credentials.browserMode === 'cdp', credentials.cdpEndpoint);
54
+ console.log(`[DynamicTools] Fetched ${mcpTools.length} tools from MCP server`);
54
55
  // Create n8n tool for each MCP tool
55
56
  const n8nTools = mcpTools.map((mcpTool) => {
56
57
  const toolName = mcpTool.name;
@@ -58,18 +59,26 @@ async function createDynamicBrowserTools(credentials) {
58
59
  .split('_')
59
60
  .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
60
61
  .join(' ');
62
+ // Use MCP's description or create a better one
63
+ let description = mcpTool.description;
64
+ if (!description || description.trim() === '') {
65
+ description = `Execute ${displayName} action in the browser.`;
66
+ }
67
+ console.log(`[DynamicTools] Tool: ${toolName}, Description: ${description.substring(0, 100)}...`);
61
68
  return {
62
69
  name: toolName,
63
70
  displayName: displayName,
64
- description: mcpTool.description || `Execute ${displayName} action in the browser. Use this tool when you need to ${displayName.toLowerCase()}.`,
71
+ description: description,
65
72
  properties: mcpSchemaToN8nProperties(mcpTool.inputSchema),
66
73
  async execute(toolInput) {
67
74
  try {
68
- console.log(`[AI Agent] Executing tool: ${toolName}`);
75
+ console.log(`[AI Agent] Executing tool: ${toolName} with input:`, JSON.stringify(toolInput));
69
76
  const result = await sessionManager.callTool(toolName, toolInput);
77
+ console.log(`[AI Agent] Tool ${toolName} result:`, JSON.stringify(result).substring(0, 200));
70
78
  return result;
71
79
  }
72
80
  catch (error) {
81
+ console.error(`[AI Agent] Tool ${toolName} error:`, error.message);
73
82
  throw new Error(error.message || 'Unknown error occurred');
74
83
  }
75
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-smart-browser-automation",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "n8n node for AI-driven browser automation using MCP",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",