UNPKG

n8n-nodes-explorium

Version:
120 lines 4.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExploriumMcp = void 0; const n8n_workflow_1 = require("n8n-workflow"); const utils_1 = require("./utils"); const SSE_ENDPOINT = 'https://mcp-auth.explorium.ai/sse'; class ExploriumMcp { constructor() { this.description = { displayName: 'Explorium MCP Client', name: 'exploriumMcp', icon: 'file:mcpClient.svg', group: ['output'], version: 1, description: 'Connect to Explorium Agent Source', defaults: { name: 'Explorium MCP', }, codex: { categories: ['AI'], subcategories: { AI: ['Model Context Protocol', 'Tools'], }, alias: ['Model Context Protocol', 'MCP Client'], resources: { primaryDocumentation: [ { url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/', }, ], }, }, inputs: [], outputs: [{ type: "ai_tool", displayName: 'Tools' }], credentials: [ { name: 'httpHeaderAuthApi', required: true, displayOptions: { show: { authentication: ['headerAuth'], }, }, }, ], properties: [ { displayName: 'Authentication', name: 'authentication', type: 'options', options: [ { name: 'Header Auth', value: 'headerAuth', }, { name: 'None', value: 'none', }, ], default: 'none', description: 'The way to authenticate with your SSE endpoint', }, { displayName: 'Credentials', name: 'credentials', type: 'credentials', default: '', displayOptions: { show: { authentication: ['headerAuth'], }, }, }, ], }; } async supplyData(itemIndex) { const credentials = await this.getCredentials('httpHeaderAuthApi'); const headers = { api_key: String(credentials.value), }; const node = this.getNode(); const setError = (message, description) => { const error = new n8n_workflow_1.NodeOperationError(node, message, { itemIndex, description }); this.addOutputData("ai_tool", itemIndex, error); throw error; }; if (!headers) { return setError('HTTP Header Authentication is required', 'Please configure the HTTP Header Authentication credentials properly.'); } console.log(headers, headers); const client = await (0, utils_1.connectMcpClient)({ sseEndpoint: SSE_ENDPOINT, headers, name: node.type, version: node.typeVersion, }); if (!client.ok) { this.logger.error('ExploriumMcp: Failed to connect to MCP Server', { error: client.error, }); return setError('Could not connect to Explorium MCP server.'); } this.logger.debug('ExploriumMcp: Successfully connected to MCP Server'); const allTools = await (0, utils_1.getAllTools)(client.result); if (!allTools.length) { return setError('Explorium MCP Server returned no tools', 'Connected successfully to the MCP server but it returned an empty list of tools.'); } const tools = allTools.map((tool) => (0, utils_1.mcpToolToDynamicTool)(tool, (0, utils_1.createCallTool)(tool.name, client.result, (error) => { this.logger.error(`ExploriumMcp: Tool "${tool.name}" failed to execute`, { error }); throw new n8n_workflow_1.NodeOperationError(node, `Failed to execute tool "${tool.name}"`, { description: error, }); })), this); return { response: tools, closeFunction: async () => await client.result.close() }; } } exports.ExploriumMcp = ExploriumMcp; //# sourceMappingURL=ExploriumMcp.node.js.map