n8n-nodes-browser-smart-automation 0.1.2 → 0.1.5
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.
- package/dist/McpClientTool/McpClientTool.node.js +2 -13
- package/dist/McpClientTool/McpClientTool.node.js.map +1 -1
- package/dist/McpClientTool/utils.js +1 -1
- package/dist/McpClientTool/utils.js.map +1 -1
- package/dist/McpTrigger/McpTrigger.node.js +1 -1
- package/dist/McpTrigger/McpTrigger.node.js.map +1 -1
- package/dist/shared/N8nBinaryLoader.js +203 -0
- package/dist/shared/N8nBinaryLoader.js.map +1 -0
- package/dist/shared/N8nJsonLoader.js +89 -0
- package/dist/shared/N8nJsonLoader.js.map +1 -0
- package/dist/shared/N8nTool.js +106 -0
- package/dist/shared/N8nTool.js.map +1 -0
- package/dist/shared/embeddingInputValidation.js +55 -0
- package/dist/shared/embeddingInputValidation.js.map +1 -0
- package/dist/shared/helpers.js +220 -13
- package/dist/shared/helpers.js.map +1 -1
- package/dist/shared/httpProxyAgent.js +40 -2
- package/dist/shared/httpProxyAgent.js.map +1 -1
- package/dist/shared/logWrapper.js +347 -2
- package/dist/shared/logWrapper.js.map +1 -1
- package/dist/shared/schemaParsing.js +47 -4
- package/dist/shared/schemaParsing.js.map +1 -1
- package/dist/shared/sharedFields.js +142 -7
- package/dist/shared/sharedFields.js.map +1 -1
- package/dist/shared/typesN8nTool.js +17 -0
- package/dist/shared/typesN8nTool.js.map +1 -0
- package/dist/shared/utils.js +1 -1
- package/dist/shared/utils.js.map +1 -1
- package/package.json +25 -7
- package/jest.config.js +0 -24
- package/nodes/McpClient/McpClient.node.ts +0 -327
- package/nodes/McpClient/__test__/McpClient.node.test.ts +0 -221
- package/nodes/McpClient/__test__/utils.test.ts +0 -302
- package/nodes/McpClient/listSearch.ts +0 -48
- package/nodes/McpClient/resourceMapping.ts +0 -48
- package/nodes/McpClient/utils.ts +0 -281
- package/nodes/McpClientTool/McpClientTool.node.ts +0 -468
- package/nodes/McpClientTool/__test__/McpClientTool.node.test.ts +0 -730
- package/nodes/McpClientTool/loadOptions.ts +0 -45
- package/nodes/McpClientTool/types.ts +0 -1
- package/nodes/McpClientTool/utils.ts +0 -116
- package/nodes/McpTrigger/FlushingTransport.ts +0 -61
- package/nodes/McpTrigger/McpServer.ts +0 -317
- package/nodes/McpTrigger/McpTrigger.node.ts +0 -204
- package/nodes/McpTrigger/__test__/FlushingTransport.test.ts +0 -102
- package/nodes/McpTrigger/__test__/McpServer.test.ts +0 -532
- package/nodes/McpTrigger/__test__/McpTrigger.node.test.ts +0 -171
- package/nodes/shared/__test__/utils.test.ts +0 -318
- package/nodes/shared/descriptions.ts +0 -65
- package/nodes/shared/helpers.ts +0 -31
- package/nodes/shared/httpProxyAgent.ts +0 -11
- package/nodes/shared/logWrapper.ts +0 -13
- package/nodes/shared/schemaParsing.ts +0 -9
- package/nodes/shared/sharedFields.ts +0 -20
- package/nodes/shared/types.ts +0 -12
- package/nodes/shared/utils.ts +0 -296
- package/officail/package.json +0 -255
- package/tsconfig.json +0 -32
- package/tsup.config.ts +0 -16
|
@@ -23,8 +23,8 @@ __export(McpClientTool_node_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(McpClientTool_node_exports);
|
|
24
24
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
-
var import_logWrapper = require("
|
|
27
|
-
var import_sharedFields = require("
|
|
26
|
+
var import_logWrapper = require("../shared/logWrapper");
|
|
27
|
+
var import_sharedFields = require("../shared/sharedFields");
|
|
28
28
|
var import_loadOptions = require("./loadOptions");
|
|
29
29
|
var import_utils = require("./utils");
|
|
30
30
|
var import_descriptions = require("../shared/descriptions");
|
|
@@ -298,16 +298,6 @@ class McpClientTool {
|
|
|
298
298
|
type: "string",
|
|
299
299
|
default: ""
|
|
300
300
|
},
|
|
301
|
-
{
|
|
302
|
-
displayName: "Timeout",
|
|
303
|
-
name: "timeout",
|
|
304
|
-
type: "number",
|
|
305
|
-
typeOptions: {
|
|
306
|
-
minValue: 1
|
|
307
|
-
},
|
|
308
|
-
default: 6e4,
|
|
309
|
-
description: "Time in ms to wait for tool calls to finish"
|
|
310
|
-
},
|
|
311
301
|
{
|
|
312
302
|
displayName: "Timeout",
|
|
313
303
|
name: "timeout",
|
|
@@ -379,7 +369,6 @@ class McpClientTool {
|
|
|
379
369
|
if (!mcpTools?.length) {
|
|
380
370
|
throw new import_n8n_workflow.NodeOperationError(node, "MCP Server returned no tools", { itemIndex });
|
|
381
371
|
}
|
|
382
|
-
await client.callTool({ name: "browser_cdp_endpoint", arguments: { endpoint: config.cdp_endpointUrl } }, import_types.CallToolResultSchema, { timeout: config.timeout });
|
|
383
372
|
for (const tool of mcpTools) {
|
|
384
373
|
if (!item.json.tool || typeof item.json.tool !== "string") {
|
|
385
374
|
throw new import_n8n_workflow.NodeOperationError(node, "Tool name not found in item.json.tool or item.tool", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../nodes/McpClientTool/McpClientTool.node.ts"],"sourcesContent":["import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport {\n\ttype IDataObject,\n\ttype IExecuteFunctions,\n\ttype INodeExecutionData,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { getTools } from './loadOptions';\nimport type { McpToolIncludeMode } from './types';\nimport { createCallTool, getSelectedTools, McpToolkit, mcpToolToDynamicTool } from './utils';\nimport { credentials, transportSelect } from '../shared/descriptions';\nimport type { McpAuthenticationOption, McpServerTransport } from '../shared/types';\nimport {\n\tconnectMcpClient,\n\tgetAllTools,\n\tgetAuthHeaders,\n\tmapToNodeOperationError,\n\ttryRefreshOAuth2Token,\n} from '../shared/utils';\n\n/**\n * Get node parameters for MCP client configuration\n */\nfunction getNodeConfig(\n\tctx: ISupplyDataFunctions | IExecuteFunctions,\n\titemIndex: number,\n): {\n\tauthentication: McpAuthenticationOption;\n\ttimeout: number;\n\tserverTransport: McpServerTransport;\n\tendpointUrl: string;\n\tcdp_endpointUrl?: string;\n\tmode: McpToolIncludeMode;\n\tincludeTools: string[];\n\texcludeTools: string[];\n} {\n\tconst node = ctx.getNode();\n\tconst authentication = ctx.getNodeParameter(\n\t\t'authentication',\n\t\titemIndex,\n\t) as McpAuthenticationOption;\n\tconst timeout = ctx.getNodeParameter('options.timeout', itemIndex, 60000) as number;\n\n\tlet serverTransport: McpServerTransport;\n\tlet endpointUrl: string;\n\tif (node.typeVersion === 1) {\n\t\tserverTransport = 'sse';\n\t\tendpointUrl = ctx.getNodeParameter('sseEndpoint', itemIndex) as string;\n\t} else {\n\t\tserverTransport = ctx.getNodeParameter('serverTransport', itemIndex) as McpServerTransport;\n\t\tendpointUrl = ctx.getNodeParameter('endpointUrl', itemIndex) as string;\n\t}\n\n\tconst mode = ctx.getNodeParameter('include', itemIndex) as McpToolIncludeMode;\n\tconst includeTools = ctx.getNodeParameter('includeTools', itemIndex, []) as string[];\n\tconst excludeTools = ctx.getNodeParameter('excludeTools', itemIndex, []) as string[];\n\n\treturn {\n\t\tauthentication,\n\t\ttimeout,\n\t\tserverTransport,\n\t\tendpointUrl,\n\t\tmode,\n\t\tincludeTools,\n\t\texcludeTools,\n\t};\n}\n\n/**\n * Connect to MCP server and get filtered tools\n */\nasync function connectAndGetTools(\n\tctx: ISupplyDataFunctions | IExecuteFunctions,\n\tconfig: ReturnType<typeof getNodeConfig>,\n) {\n\tconst node = ctx.getNode();\n\tconst { headers } = await getAuthHeaders(ctx, config.authentication);\n\n\tconst client = await connectMcpClient({\n\t\tserverTransport: config.serverTransport,\n\t\tendpointUrl: config.endpointUrl,\n\t\theaders,\n\t\tname: node.type,\n\t\tversion: node.typeVersion,\n\t\tonUnauthorized: async (headers) =>\n\t\t\tawait tryRefreshOAuth2Token(ctx, config.authentication, headers),\n\t});\n\n\tif (!client.ok) {\n\t\treturn { client, mcpTools: null, error: client.error };\n\t}\n\n\tconst allTools = await getAllTools(client.result);\n\tconst mcpTools = getSelectedTools({\n\t\ttools: allTools,\n\t\tmode: config.mode,\n\t\tincludeTools: config.includeTools,\n\t\texcludeTools: config.excludeTools,\n\t});\n\n\treturn { client: client.result, mcpTools, error: null };\n}\n\nexport class McpClientTool implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'MCP Client Tool',\n\t\tname: 'mcpClientTool',\n\t\ticon: {\n\t\t\tlight: 'file:../mcp.svg',\n\t\t\tdark: 'file:../mcp.dark.svg',\n\t\t},\n\t\tgroup: ['output'],\n\t\tversion: [1, 1.1, 1.2],\n\t\tdescription: 'Connect tools from an MCP Server',\n\t\tdefaults: {\n\t\t\tname: 'MCP Client',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Model Context Protocol', 'Tools'],\n\t\t\t},\n\t\t\talias: ['Model Context Protocol', 'MCP Client'],\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [{ type: NodeConnectionTypes.AiTool, displayName: 'Tools' }],\n\t\tcredentials,\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'SSE Endpoint',\n\t\t\t\tname: 'sseEndpoint',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'SSE Endpoint of your MCP server',\n\t\t\t\tplaceholder: 'e.g. https://my-mcp-server.ai/sse',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Endpoint',\n\t\t\t\tname: 'endpointUrl',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Endpoint of your MCP server',\n\t\t\t\tplaceholder: 'e.g. https://my-mcp-server.ai/mcp',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\ttransportSelect({\n\t\t\t\tdefaultOption: 'sse',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t\ttransportSelect({\n\t\t\t\tdefaultOption: 'httpStreamable',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Bearer Auth',\n\t\t\t\t\t\tvalue: 'bearerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Header Auth',\n\t\t\t\t\t\tvalue: 'headerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate with your endpoint',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { lt: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Bearer Auth',\n\t\t\t\t\t\tvalue: 'bearerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Header Auth',\n\t\t\t\t\t\tvalue: 'headerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'MCP OAuth2',\n\t\t\t\t\t\tvalue: 'mcpOAuth2Api',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Multiple Headers Auth',\n\t\t\t\t\t\tvalue: 'multipleHeadersAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate with your endpoint',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Credentials',\n\t\t\t\tname: 'credentials',\n\t\t\t\ttype: 'credentials',\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['headerAuth', 'bearerAuth', 'mcpOAuth2Api', 'multipleHeadersAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Tools to Include',\n\t\t\t\tname: 'include',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription: 'How to select the tools you want to be exposed to the AI Agent',\n\t\t\t\tdefault: 'all',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'All',\n\t\t\t\t\t\tvalue: 'all',\n\t\t\t\t\t\tdescription: 'Also include all unchanged fields from the input',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Selected',\n\t\t\t\t\t\tvalue: 'selected',\n\t\t\t\t\t\tdescription: 'Also include the tools listed in the parameter \"Tools to Include\"',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'All Except',\n\t\t\t\t\t\tvalue: 'except',\n\t\t\t\t\t\tdescription: 'Exclude the tools listed in the parameter \"Tools to Exclude\"',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Tools to Include',\n\t\t\t\tname: 'includeTools',\n\t\t\t\ttype: 'multiOptions',\n\t\t\t\tdefault: [],\n\t\t\t\tdescription:\n\t\t\t\t\t'Choose from the list, or specify IDs using an <a href=\"https://docs.n8n.io/code/expressions/\">expression</a>',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsMethod: 'getTools',\n\t\t\t\t\tloadOptionsDependsOn: ['sseEndpoint'],\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tinclude: ['selected'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Tools to Exclude',\n\t\t\t\tname: 'excludeTools',\n\t\t\t\ttype: 'multiOptions',\n\t\t\t\tdefault: [],\n\t\t\t\tdescription:\n\t\t\t\t\t'Choose from the list, or specify IDs using an <a href=\"https://docs.n8n.io/code/expressions/\">expression</a>',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsMethod: 'getTools',\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tinclude: ['except'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'cdp_endpointUrl',\n\t\t\t\t\t\tname: 'cdp_endpointUrl',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tminValue: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: 60000,\n\t\t\t\t\t\tdescription: 'Time in ms to wait for tool calls to finish',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tminValue: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: 60000,\n\t\t\t\t\t\tdescription: 'Time in ms to wait for tool calls to finish',\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tmethods = {\n\t\tloadOptions: {\n\t\t\tgetTools,\n\t\t},\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst config = getNodeConfig(this, itemIndex);\n\t\tconst setError = (error: NodeOperationError): SupplyData => {\n\t\t\tthis.addOutputData(NodeConnectionTypes.AiTool, itemIndex, error);\n\t\t\tthrow error;\n\t\t};\n\n\t\tconst { client, mcpTools, error } = await connectAndGetTools(this, config);\n\n\t\tif (error) {\n\t\t\tthis.logger.error('McpClientTool: Failed to connect to MCP Server', { error });\n\t\t\treturn setError(mapToNodeOperationError(node, error));\n\t\t}\n\n\t\tthis.logger.debug('McpClientTool: Successfully connected to MCP Server');\n\n\t\tif (!mcpTools?.length) {\n\t\t\treturn setError(\n\t\t\t\tnew NodeOperationError(node, 'MCP Server returned no tools', {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Connected successfully to your MCP server but it returned an empty list of tools.',\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst tools = mcpTools.map((tool) =>\n\t\t\tlogWrapper(\n\t\t\t\tmcpToolToDynamicTool(\n\t\t\t\t\ttool,\n\t\t\t\t\tcreateCallTool(tool.name, client, config.timeout, (errorMessage) => {\n\t\t\t\t\t\tconst error = new NodeOperationError(node, errorMessage, { itemIndex });\n\t\t\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, itemIndex, error);\n\t\t\t\t\t\tthis.logger.error(`McpClientTool: Tool \"${tool.name}\" failed to execute`, { error });\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t\tthis,\n\t\t\t),\n\t\t);\n\n\t\tthis.logger.debug(`McpClientTool: Connected to MCP Server with ${tools.length} tools`);\n\n\t\tconst toolkit = new McpToolkit(tools);\n\n\t\treturn { response: toolkit, closeFunction: async () => await client.close() };\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst node = this.getNode();\n\t\tconst items = this.getInputData();\n\t\tconst returnData: INodeExecutionData[] = [];\n\n\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\tconst item = items[itemIndex];\n\t\t\tconst config = getNodeConfig(this, itemIndex);\n\n\t\t\tconst { client, mcpTools, error } = await connectAndGetTools(this, config);\n\t\t\t\n\t\t\tif (error) {\n\t\t\t\tthrow new NodeOperationError(node, error.error, { itemIndex });\n\t\t\t}\n\n\t\t\tif (!mcpTools?.length) {\n\t\t\t\tthrow new NodeOperationError(node, 'MCP Server returned no tools', { itemIndex });\n\t\t\t}\n\t\t\tawait client.callTool({name:\"browser_cdp_endpoint\",arguments:{endpoint:config.cdp_endpointUrl}},CallToolResultSchema,{timeout:config.timeout});\n\n\t\t\tfor (const tool of mcpTools) {\n\t\t\t\t// Check for tool name in item.json.tool (for toolkit execution from agent)\n\t\t\t\t// or item.tool (for direct execution)\n\t\t\t\tif (!item.json.tool || typeof item.json.tool !== 'string') {\n\t\t\t\t\tthrow new NodeOperationError(node, 'Tool name not found in item.json.tool or item.tool', {\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst toolName = item.json.tool;\n\t\t\t\tif (toolName === tool.name) {\n\t\t\t\t\t// Extract the tool name from arguments before passing to MCP\n\t\t\t\t\tconst { tool: _, ...toolArguments } = item.json;\n\t\t\t\t\tconst params: {\n\t\t\t\t\t\tname: string;\n\t\t\t\t\t\targuments: IDataObject;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\targuments: toolArguments,\n\t\t\t\t};\n\t\t\t\tconst result = await client.callTool(params, CallToolResultSchema, {\n\t\t\t\t\ttimeout: config.timeout,\n\t\t\t\t});\n\t\t\t\treturnData.push({\n\t\t\t\t\tjson: {\n\t\t\t\t\t\tresponse: (result.content || result) as IDataObject,\n\t\t\t\t\t},\n\t\t\t\t\tpairedItem: {\n\t\t\t\t\t\titem: itemIndex,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn [returnData];\n}\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AACrC,0BAUO;AAEP,wBAA2B;AAC3B,0BAA6C;AAE7C,yBAAyB;AAEzB,mBAAmF;AACnF,0BAA6C;AAE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AAK,QAAQ,OAAO,KAAK,KAAK,SAAS,UAAU;AAC1D,gBAAM,IAAI,uCAAmB,MAAM,sDAAsD;AAAA,YACxF;AAAA,UACD,CAAC;AAAA,QACF;AAEA,cAAM,WAAW,KAAK,KAAK;AAC3B,YAAI,aAAa,KAAK,MAAM;AAE3B,gBAAM,EAAE,MAAM,GAAG,GAAG,cAAc,IAAI,KAAK;AAC3C,gBAAM,SAGF;AAAA,YACH,MAAM,KAAK;AAAA,YACX,WAAW;AAAA,UACb;AACA,gBAAM,SAAS,MAAM,OAAO,SAAS,QAAQ,mCAAsB;AAAA,YAClE,SAAS,OAAO;AAAA,UACjB,CAAC;AACD,qBAAW,KAAK;AAAA,YACf,MAAM;AAAA,cACL,UAAW,OAAO,WAAW;AAAA,YAC9B;AAAA,YACA,YAAY;AAAA,cACX,MAAM;AAAA,YACP;AAAA,UACD,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAEA,WAAO,CAAC,UAAU;AAAA,EACnB;AACA;","names":["import_utils","headers","error"]}
|
|
1
|
+
{"version":3,"sources":["../../nodes/McpClientTool/McpClientTool.node.ts"],"sourcesContent":["import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport {\n\ttype IDataObject,\n\ttype IExecuteFunctions,\n\ttype INodeExecutionData,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '../shared/logWrapper';\nimport { getConnectionHintNoticeField } from '../shared/sharedFields';\n\nimport { getTools } from './loadOptions';\nimport type { McpToolIncludeMode } from './types';\nimport { createCallTool, getSelectedTools, McpToolkit, mcpToolToDynamicTool } from './utils';\nimport { credentials, transportSelect } from '../shared/descriptions';\nimport type { McpAuthenticationOption, McpServerTransport } from '../shared/types';\nimport {\n\tconnectMcpClient,\n\tgetAllTools,\n\tgetAuthHeaders,\n\tmapToNodeOperationError,\n\ttryRefreshOAuth2Token,\n} from '../shared/utils';\n\n/**\n * Get node parameters for MCP client configuration\n */\nfunction getNodeConfig(\n\tctx: ISupplyDataFunctions | IExecuteFunctions,\n\titemIndex: number,\n): {\n\tauthentication: McpAuthenticationOption;\n\ttimeout: number;\n\tserverTransport: McpServerTransport;\n\tendpointUrl: string;\n\tcdp_endpointUrl?: string;\n\tmode: McpToolIncludeMode;\n\tincludeTools: string[];\n\texcludeTools: string[];\n} {\n\tconst node = ctx.getNode();\n\tconst authentication = ctx.getNodeParameter(\n\t\t'authentication',\n\t\titemIndex,\n\t) as McpAuthenticationOption;\n\tconst timeout = ctx.getNodeParameter('options.timeout', itemIndex, 60000) as number;\n\n\tlet serverTransport: McpServerTransport;\n\tlet endpointUrl: string;\n\tif (node.typeVersion === 1) {\n\t\tserverTransport = 'sse';\n\t\tendpointUrl = ctx.getNodeParameter('sseEndpoint', itemIndex) as string;\n\t} else {\n\t\tserverTransport = ctx.getNodeParameter('serverTransport', itemIndex) as McpServerTransport;\n\t\tendpointUrl = ctx.getNodeParameter('endpointUrl', itemIndex) as string;\n\t}\n\n\tconst mode = ctx.getNodeParameter('include', itemIndex) as McpToolIncludeMode;\n\tconst includeTools = ctx.getNodeParameter('includeTools', itemIndex, []) as string[];\n\tconst excludeTools = ctx.getNodeParameter('excludeTools', itemIndex, []) as string[];\n\n\treturn {\n\t\tauthentication,\n\t\ttimeout,\n\t\tserverTransport,\n\t\tendpointUrl,\n\t\tmode,\n\t\tincludeTools,\n\t\texcludeTools,\n\t};\n}\n\n/**\n * Connect to MCP server and get filtered tools\n */\nasync function connectAndGetTools(\n\tctx: ISupplyDataFunctions | IExecuteFunctions,\n\tconfig: ReturnType<typeof getNodeConfig>,\n) {\n\tconst node = ctx.getNode();\n\tconst { headers } = await getAuthHeaders(ctx, config.authentication);\n\n\tconst client = await connectMcpClient({\n\t\tserverTransport: config.serverTransport,\n\t\tendpointUrl: config.endpointUrl,\n\t\theaders,\n\t\tname: node.type,\n\t\tversion: node.typeVersion,\n\t\tonUnauthorized: async (headers) =>\n\t\t\tawait tryRefreshOAuth2Token(ctx, config.authentication, headers),\n\t});\n\n\tif (!client.ok) {\n\t\treturn { client, mcpTools: null, error: client.error };\n\t}\n\n\tconst allTools = await getAllTools(client.result);\n\tconst mcpTools = getSelectedTools({\n\t\ttools: allTools,\n\t\tmode: config.mode,\n\t\tincludeTools: config.includeTools,\n\t\texcludeTools: config.excludeTools,\n\t});\n\n\treturn { client: client.result, mcpTools, error: null };\n}\n\nexport class McpClientTool implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'MCP Client Tool',\n\t\tname: 'mcpClientTool',\n\t\ticon: {\n\t\t\tlight: 'file:../mcp.svg',\n\t\t\tdark: 'file:../mcp.dark.svg',\n\t\t},\n\t\tgroup: ['output'],\n\t\tversion: [1, 1.1, 1.2],\n\t\tdescription: 'Connect tools from an MCP Server',\n\t\tdefaults: {\n\t\t\tname: 'MCP Client',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Model Context Protocol', 'Tools'],\n\t\t\t},\n\t\t\talias: ['Model Context Protocol', 'MCP Client'],\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [{ type: NodeConnectionTypes.AiTool, displayName: 'Tools' }],\n\t\tcredentials,\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'SSE Endpoint',\n\t\t\t\tname: 'sseEndpoint',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'SSE Endpoint of your MCP server',\n\t\t\t\tplaceholder: 'e.g. https://my-mcp-server.ai/sse',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Endpoint',\n\t\t\t\tname: 'endpointUrl',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Endpoint of your MCP server',\n\t\t\t\tplaceholder: 'e.g. https://my-mcp-server.ai/mcp',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\ttransportSelect({\n\t\t\t\tdefaultOption: 'sse',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t\ttransportSelect({\n\t\t\t\tdefaultOption: 'httpStreamable',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Bearer Auth',\n\t\t\t\t\t\tvalue: 'bearerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Header Auth',\n\t\t\t\t\t\tvalue: 'headerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate with your endpoint',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { lt: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Bearer Auth',\n\t\t\t\t\t\tvalue: 'bearerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Header Auth',\n\t\t\t\t\t\tvalue: 'headerAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'MCP OAuth2',\n\t\t\t\t\t\tvalue: 'mcpOAuth2Api',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Multiple Headers Auth',\n\t\t\t\t\t\tvalue: 'multipleHeadersAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate with your endpoint',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Credentials',\n\t\t\t\tname: 'credentials',\n\t\t\t\ttype: 'credentials',\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['headerAuth', 'bearerAuth', 'mcpOAuth2Api', 'multipleHeadersAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Tools to Include',\n\t\t\t\tname: 'include',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription: 'How to select the tools you want to be exposed to the AI Agent',\n\t\t\t\tdefault: 'all',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'All',\n\t\t\t\t\t\tvalue: 'all',\n\t\t\t\t\t\tdescription: 'Also include all unchanged fields from the input',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Selected',\n\t\t\t\t\t\tvalue: 'selected',\n\t\t\t\t\t\tdescription: 'Also include the tools listed in the parameter \"Tools to Include\"',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'All Except',\n\t\t\t\t\t\tvalue: 'except',\n\t\t\t\t\t\tdescription: 'Exclude the tools listed in the parameter \"Tools to Exclude\"',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Tools to Include',\n\t\t\t\tname: 'includeTools',\n\t\t\t\ttype: 'multiOptions',\n\t\t\t\tdefault: [],\n\t\t\t\tdescription:\n\t\t\t\t\t'Choose from the list, or specify IDs using an <a href=\"https://docs.n8n.io/code/expressions/\">expression</a>',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsMethod: 'getTools',\n\t\t\t\t\tloadOptionsDependsOn: ['sseEndpoint'],\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tinclude: ['selected'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Tools to Exclude',\n\t\t\t\tname: 'excludeTools',\n\t\t\t\ttype: 'multiOptions',\n\t\t\t\tdefault: [],\n\t\t\t\tdescription:\n\t\t\t\t\t'Choose from the list, or specify IDs using an <a href=\"https://docs.n8n.io/code/expressions/\">expression</a>',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsMethod: 'getTools',\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tinclude: ['except'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'cdp_endpointUrl',\n\t\t\t\t\t\tname: 'cdp_endpointUrl',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tminValue: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: 60000,\n\t\t\t\t\t\tdescription: 'Time in ms to wait for tool calls to finish',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tmethods = {\n\t\tloadOptions: {\n\t\t\tgetTools,\n\t\t},\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst config = getNodeConfig(this, itemIndex);\n\t\tconst setError = (error: NodeOperationError): SupplyData => {\n\t\t\tthis.addOutputData(NodeConnectionTypes.AiTool, itemIndex, error);\n\t\t\tthrow error;\n\t\t};\n\n\t\tconst { client, mcpTools, error } = await connectAndGetTools(this, config);\n\n\t\tif (error) {\n\t\t\tthis.logger.error('McpClientTool: Failed to connect to MCP Server', { error });\n\t\t\treturn setError(mapToNodeOperationError(node, error));\n\t\t}\n\n\t\tthis.logger.debug('McpClientTool: Successfully connected to MCP Server');\n\n\t\tif (!mcpTools?.length) {\n\t\t\treturn setError(\n\t\t\t\tnew NodeOperationError(node, 'MCP Server returned no tools', {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Connected successfully to your MCP server but it returned an empty list of tools.',\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst tools = mcpTools.map((tool) =>\n\t\t\tlogWrapper(\n\t\t\t\tmcpToolToDynamicTool(\n\t\t\t\t\ttool,\n\t\t\t\t\tcreateCallTool(tool.name, client, config.timeout, (errorMessage) => {\n\t\t\t\t\t\tconst error = new NodeOperationError(node, errorMessage, { itemIndex });\n\t\t\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, itemIndex, error);\n\t\t\t\t\t\tthis.logger.error(`McpClientTool: Tool \"${tool.name}\" failed to execute`, { error });\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t\tthis,\n\t\t\t),\n\t\t);\n\n\t\tthis.logger.debug(`McpClientTool: Connected to MCP Server with ${tools.length} tools`);\n\n\t\tconst toolkit = new McpToolkit(tools);\n\n\t\treturn { response: toolkit, closeFunction: async () => await client.close() };\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst node = this.getNode();\n\t\tconst items = this.getInputData();\n\t\tconst returnData: INodeExecutionData[] = [];\n\n\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\tconst item = items[itemIndex];\n\t\t\tconst config = getNodeConfig(this, itemIndex);\n\n\t\t\tconst { client, mcpTools, error } = await connectAndGetTools(this, config);\n\t\t\t\n\t\t\tif (error) {\n\t\t\t\tthrow new NodeOperationError(node, error.error, { itemIndex });\n\t\t\t}\n\n\t\t\tif (!mcpTools?.length) {\n\t\t\t\tthrow new NodeOperationError(node, 'MCP Server returned no tools', { itemIndex });\n\t\t\t}\n\n\t\t\tfor (const tool of mcpTools) {\n\t\t\t\t// Check for tool name in item.json.tool (for toolkit execution from agent)\n\t\t\t\t// or item.tool (for direct execution)\n\t\t\t\tif (!item.json.tool || typeof item.json.tool !== 'string') {\n\t\t\t\t\tthrow new NodeOperationError(node, 'Tool name not found in item.json.tool or item.tool', {\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst toolName = item.json.tool;\n\t\t\t\tif (toolName === tool.name) {\n\t\t\t\t\t// Extract the tool name from arguments before passing to MCP\n\t\t\t\t\tconst { tool: _, ...toolArguments } = item.json;\n\t\t\t\t\tconst params: {\n\t\t\t\t\t\tname: string;\n\t\t\t\t\t\targuments: IDataObject;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\targuments: toolArguments,\n\t\t\t\t};\n\t\t\t\tconst result = await client.callTool(params, CallToolResultSchema, {\n\t\t\t\t\ttimeout: config.timeout,\n\t\t\t\t});\n\t\t\t\treturnData.push({\n\t\t\t\t\tjson: {\n\t\t\t\t\t\tresponse: (result.content || result) as IDataObject,\n\t\t\t\t\t},\n\t\t\t\t\tpairedItem: {\n\t\t\t\t\t\titem: itemIndex,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn [returnData];\n}\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AACrC,0BAUO;AAEP,wBAA2B;AAC3B,0BAA6C;AAE7C,yBAAyB;AAEzB,mBAAmF;AACnF,0BAA6C;AAE7C,IAAAA,gBAMO;AAKP,SAAS,cACR,KACA,WAUC;AACD,QAAM,OAAO,IAAI,QAAQ;AACzB,QAAM,iBAAiB,IAAI;AAAA,IAC1B;AAAA,IACA;AAAA,EACD;AACA,QAAM,UAAU,IAAI,iBAAiB,mBAAmB,WAAW,GAAK;AAExE,MAAI;AACJ,MAAI;AACJ,MAAI,KAAK,gBAAgB,GAAG;AAC3B,sBAAkB;AAClB,kBAAc,IAAI,iBAAiB,eAAe,SAAS;AAAA,EAC5D,OAAO;AACN,sBAAk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ACnB;AACA;","names":["import_utils","headers","error"]}
|
|
@@ -29,7 +29,7 @@ var import_tools = require("@langchain/core/tools");
|
|
|
29
29
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
30
30
|
var import_agents = require("@langchain/classic/agents");
|
|
31
31
|
var import_zod = require("zod");
|
|
32
|
-
var import_schemaParsing = require("
|
|
32
|
+
var import_schemaParsing = require("../shared/schemaParsing");
|
|
33
33
|
function getSelectedTools({
|
|
34
34
|
mode,
|
|
35
35
|
includeTools,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../nodes/McpClientTool/utils.ts"],"sourcesContent":["import { DynamicStructuredTool, type DynamicStructuredToolInput } from '@langchain/core/tools';\nimport type { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { CompatibilityCallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { Toolkit } from '@langchain/classic/agents';\nimport { type IDataObject } from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport { convertJsonSchemaToZod } from '
|
|
1
|
+
{"version":3,"sources":["../../nodes/McpClientTool/utils.ts"],"sourcesContent":["import { DynamicStructuredTool, type DynamicStructuredToolInput } from '@langchain/core/tools';\nimport type { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { CompatibilityCallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { Toolkit } from '@langchain/classic/agents';\nimport { type IDataObject } from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport { convertJsonSchemaToZod } from '../shared/schemaParsing';\n\nimport type { McpToolIncludeMode } from './types';\nimport type { McpTool } from '../shared/types';\n\nexport function getSelectedTools({\n\tmode,\n\tincludeTools,\n\texcludeTools,\n\ttools,\n}: {\n\tmode: McpToolIncludeMode;\n\tincludeTools?: string[];\n\texcludeTools?: string[];\n\ttools: McpTool[];\n}) {\n\tswitch (mode) {\n\t\tcase 'selected': {\n\t\t\tif (!includeTools?.length) return tools;\n\t\t\tconst include = new Set(includeTools);\n\t\t\treturn tools.filter((tool) => include.has(tool.name));\n\t\t}\n\t\tcase 'except': {\n\t\t\tconst except = new Set(excludeTools ?? []);\n\t\t\treturn tools.filter((tool) => !except.has(tool.name));\n\t\t}\n\t\tcase 'all':\n\t\tdefault:\n\t\t\treturn tools;\n\t}\n}\n\nexport const getErrorDescriptionFromToolCall = (result: unknown): string | undefined => {\n\tif (result && typeof result === 'object') {\n\t\tif ('content' in result && Array.isArray(result.content)) {\n\t\t\tconst errorMessage = (result.content as Array<{ type: 'text'; text: string }>).find(\n\t\t\t\t(content) => content && typeof content === 'object' && typeof content.text === 'string',\n\t\t\t)?.text;\n\t\t\treturn errorMessage;\n\t\t} else if ('toolResult' in result && typeof result.toolResult === 'string') {\n\t\t\treturn result.toolResult;\n\t\t}\n\t\tif ('message' in result && typeof result.message === 'string') {\n\t\t\treturn result.message;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nexport const createCallTool =\n\t(name: string, client: Client, timeout: number, onError: (error: string) => void) =>\n\tasync (args: IDataObject) => {\n\t\tlet result: Awaited<ReturnType<Client['callTool']>>;\n\n\t\tfunction handleError(error: unknown) {\n\t\t\tconst errorDescription =\n\t\t\t\tgetErrorDescriptionFromToolCall(error) ?? `Failed to execute tool \"${name}\"`;\n\t\t\tonError(errorDescription);\n\t\t\treturn errorDescription;\n\t\t}\n\n\t\ttry {\n\t\t\tresult = await client.callTool({ name, arguments: args }, CompatibilityCallToolResultSchema, {\n\t\t\t\ttimeout,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\treturn handleError(error);\n\t\t}\n\n\t\tif (result.isError) {\n\t\t\treturn handleError(result);\n\t\t}\n\n\t\tif (result.toolResult !== undefined) {\n\t\t\treturn result.toolResult;\n\t\t}\n\n\t\tif (result.content !== undefined) {\n\t\t\treturn result.content;\n\t\t}\n\n\t\treturn result;\n\t};\n\nexport function mcpToolToDynamicTool(\n\ttool: McpTool,\n\tonCallTool: DynamicStructuredToolInput['func'],\n): DynamicStructuredTool {\n\tconst rawSchema = convertJsonSchemaToZod(tool.inputSchema);\n\n\t// Ensure we always have an object schema for structured tools\n\tconst objectSchema =\n\t\trawSchema instanceof z.ZodObject ? rawSchema : z.object({ value: rawSchema });\n\n\treturn new DynamicStructuredTool({\n\t\tname: tool.name,\n\t\tdescription: tool.description ?? '',\n\t\tschema: objectSchema,\n\t\tfunc: onCallTool,\n\t\tmetadata: { isFromToolkit: true },\n\t});\n}\n\nexport class McpToolkit extends Toolkit {\n\tconstructor(public tools: DynamicStructuredTool[]) {\n\t\tsuper();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuE;AAEvE,mBAAkD;AAClD,oBAAwB;AAExB,iBAAkB;AAElB,2BAAuC;AAKhC,SAAS,iBAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAKG;AACF,UAAQ,MAAM;AAAA,IACb,KAAK,YAAY;AAChB,UAAI,CAAC,cAAc,OAAQ,QAAO;AAClC,YAAM,UAAU,IAAI,IAAI,YAAY;AACpC,aAAO,MAAM,OAAO,CAAC,SAAS,QAAQ,IAAI,KAAK,IAAI,CAAC;AAAA,IACrD;AAAA,IACA,KAAK,UAAU;AACd,YAAM,SAAS,IAAI,IAAI,gBAAgB,CAAC,CAAC;AACzC,aAAO,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,IAAI,KAAK,IAAI,CAAC;AAAA,IACrD;AAAA,IACA,KAAK;AAAA,IACL;AACC,aAAO;AAAA,EACT;AACD;AAEO,MAAM,kCAAkC,CAAC,WAAwC;AACvF,MAAI,UAAU,OAAO,WAAW,UAAU;AACzC,QAAI,aAAa,UAAU,MAAM,QAAQ,OAAO,OAAO,GAAG;AACzD,YAAM,eAAgB,OAAO,QAAkD;AAAA,QAC9E,CAAC,YAAY,WAAW,OAAO,YAAY,YAAY,OAAO,QAAQ,SAAS;AAAA,MAChF,GAAG;AACH,aAAO;AA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|
|
|
24
24
|
var import_error = require("n8n-nodes-base/dist/nodes/Webhook/error");
|
|
25
25
|
var import_utils = require("n8n-nodes-base/dist/nodes/Webhook/utils");
|
|
26
26
|
var import_n8n_workflow = require("n8n-workflow");
|
|
27
|
-
var import_helpers = require("
|
|
27
|
+
var import_helpers = require("../shared/helpers");
|
|
28
28
|
var import_McpServer = require("./McpServer");
|
|
29
29
|
const MCP_SSE_SETUP_PATH = "sse";
|
|
30
30
|
const MCP_SSE_MESSAGES_PATH = "messages";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../nodes/McpTrigger/McpTrigger.node.ts"],"sourcesContent":["import { WebhookAuthorizationError } from 'n8n-nodes-base/dist/nodes/Webhook/error';\nimport { validateWebhookAuthentication } from 'n8n-nodes-base/dist/nodes/Webhook/utils';\nimport type { INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';\nimport { NodeConnectionTypes, Node, nodeNameToToolName } from 'n8n-workflow';\n\nimport { getConnectedTools } from '@utils/helpers';\n\nimport type { CompressionResponse } from './FlushingTransport';\nimport { McpServerManager } from './McpServer';\n\nconst MCP_SSE_SETUP_PATH = 'sse';\nconst MCP_SSE_MESSAGES_PATH = 'messages';\n\nexport class McpTrigger extends Node {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'MCP Server Trigger',\n\t\tname: 'mcpTrigger',\n\t\ticon: {\n\t\t\tlight: 'file:../mcp.svg',\n\t\t\tdark: 'file:../mcp.dark.svg',\n\t\t},\n\t\tgroup: ['trigger'],\n\t\tversion: [1, 1.1, 2],\n\t\tdescription: 'Expose n8n tools as an MCP Server endpoint',\n\t\tactivationMessage:\n\t\t\t'You can now connect your MCP Clients to the URL, using SSE or Streamable HTTP transports.',\n\t\tdefaults: {\n\t\t\tname: 'MCP Server Trigger',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI', 'Core Nodes'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Root Nodes', 'Model Context Protocol'],\n\t\t\t\t'Core Nodes': ['Other Trigger Nodes'],\n\t\t\t},\n\t\t\talias: ['Model Context Protocol', 'MCP Server'],\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\ttriggerPanel: {\n\t\t\theader: 'Listen for MCP events',\n\t\t\texecutionsHelp: {\n\t\t\t\tinactive:\n\t\t\t\t\t\"This trigger has two modes: test and production.<br /><br /><b>Use test mode while you build your workflow</b>. Click the 'execute step' button, then make an MCP request to the test URL. The executions will show up in the editor.<br /><br /><b>Use production mode to run your workflow automatically</b>. Publish the workflow, then make requests to the production URL. These executions will show up in the <a data-key='executions'>executions list</a>, but not the editor.\",\n\t\t\t\tactive:\n\t\t\t\t\t\"This trigger has two modes: test and production.<br /><br /><b>Use test mode while you build your workflow</b>. Click the 'execute step' button, then make an MCP request to the test URL. The executions will show up in the editor.<br /><br /><b>Use production mode to run your workflow automatically</b>. Since your workflow is activated, you can make requests to the production URL. These executions will show up in the <a data-key='executions'>executions list</a>, but not the editor.\",\n\t\t\t},\n\t\t\tactivationHint:\n\t\t\t\t'Once you’ve finished building your workflow, run it without having to click this button by using the production URL.',\n\t\t},\n\t\tinputs: [\n\t\t\t{\n\t\t\t\ttype: NodeConnectionTypes.AiTool,\n\t\t\t\tdisplayName: 'Tools',\n\t\t\t},\n\t\t],\n\t\toutputs: [],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed\n\t\t\t\tname: 'httpBearerAuth',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['bearerAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'httpHeaderAuth',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['headerAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: 'None', value: 'none' },\n\t\t\t\t\t{ name: 'Bearer Auth', value: 'bearerAuth' },\n\t\t\t\t\t{ name: 'Header Auth', value: 'headerAuth' },\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Path',\n\t\t\t\tname: 'path',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'webhook',\n\t\t\t\trequired: true,\n\t\t\t\tdescription: 'The base path for this MCP server',\n\t\t\t},\n\t\t],\n\t\twebhooks: [\n\t\t\t{\n\t\t\t\tname: 'setup',\n\t\t\t\thttpMethod: 'GET',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tisFullPath: true,\n\t\t\t\tpath: `={{$parameter[\"path\"]}}{{parseFloat($nodeVersion)<2 ? '/${MCP_SSE_SETUP_PATH}' : ''}}`,\n\t\t\t\tnodeType: 'mcp',\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'POST',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tisFullPath: true,\n\t\t\t\tpath: `={{$parameter[\"path\"]}}{{parseFloat($nodeVersion)<2 ? '/${MCP_SSE_MESSAGES_PATH}' : ''}}`,\n\t\t\t\tnodeType: 'mcp',\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'DELETE',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tisFullPath: true,\n\t\t\t\tpath: '={{$parameter[\"path\"]}}',\n\t\t\t\tnodeType: 'mcp',\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: true,\n\t\t\t},\n\t\t],\n\t};\n\n\tasync webhook(context: IWebhookFunctions): Promise<IWebhookResponseData> {\n\t\tconst webhookName = context.getWebhookName();\n\t\tconst req = context.getRequestObject();\n\t\tconst resp = context.getResponseObject() as unknown as CompressionResponse;\n\n\t\ttry {\n\t\t\tawait validateWebhookAuthentication(context, 'authentication');\n\t\t} catch (error) {\n\t\t\tif (error instanceof WebhookAuthorizationError) {\n\t\t\t\tresp.writeHead(error.responseCode);\n\t\t\t\tresp.end(error.message);\n\t\t\t\treturn { noWebhookResponse: true };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tconst node = context.getNode();\n\t\t// Get a url/tool friendly name for the server, based on the node name\n\t\tconst serverName = node.typeVersion > 1 ? nodeNameToToolName(node) : 'n8n-mcp-server';\n\n\t\tconst mcpServerManager: McpServerManager = McpServerManager.instance(context.logger);\n\n\t\tif (webhookName === 'setup') {\n\t\t\t// Sets up the transport and opens the long-lived connection. This resp\n\t\t\t// will stay streaming, and is the channel that sends the events\n\n\t\t\t// Prior to version 2.0, we use different paths for the setup and messages.\n\t\t\tconst postUrl =\n\t\t\t\tnode.typeVersion < 2\n\t\t\t\t\t? req.path.replace(new RegExp(`/${MCP_SSE_SETUP_PATH}$`), `/${MCP_SSE_MESSAGES_PATH}`)\n\t\t\t\t\t: req.path;\n\t\t\tawait mcpServerManager.createServerWithSSETransport(serverName, postUrl, resp);\n\n\t\t\treturn { noWebhookResponse: true };\n\t\t} else if (webhookName === 'default') {\n\t\t\t// Here we handle POST and DELETE requests.\n\t\t\t// POST can be either:\n\t\t\t// 1) Client calls in an established session using the SSE transport, or\n\t\t\t// 2) Client calls in an established session using the StreamableHTTPServerTransport\n\t\t\t// 3) Session setup requests using the StreamableHTTPServerTransport\n\t\t\t// DELETE is used to terminate the session using the StreamableHTTPServerTransport\n\n\t\t\tif (req.method === 'DELETE') {\n\t\t\t\tawait mcpServerManager.handleDeleteRequest(req, resp);\n\t\t\t} else {\n\t\t\t\t// Check if there is a session and a transport is already established\n\t\t\t\tconst sessionId = mcpServerManager.getSessionId(req);\n\n\t\t\t\tif (sessionId && mcpServerManager.getTransport(sessionId)) {\n\t\t\t\t\tconst connectedTools = await getConnectedTools(context, true);\n\t\t\t\t\tconst wasToolCall = await mcpServerManager.handlePostMessage(req, resp, connectedTools);\n\t\t\t\t\tif (wasToolCall) return { noWebhookResponse: true, workflowData: [[{ json: {} }]] };\n\t\t\t\t} else {\n\t\t\t\t\t// If no session is established, this is a setup request\n\t\t\t\t\t// for the StreamableHTTPServerTransport, so we create a new transport\n\t\t\t\t\tawait mcpServerManager.createServerWithStreamableHTTPTransport(serverName, resp, req);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { noWebhookResponse: true };\n\t\t}\n\n\t\treturn { workflowData: [[{ json: {} }]] };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAC1C,mBAA8C;AAE9C,0BAA8D;AAE9D,qBAAkC;AAGlC,uBAAiC;AAEjC,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAEvB,MAAM,mBAAmB,yBAAK;AAAA,EACpC,cAAoC;AAAA,IACnC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,MACL,OAAO;AAAA,MACP,MAAM;AAAA,IACP;AAAA,IACA,OAAO,CAAC,SAAS;AAAA,IACjB,SAAS,CAAC,GAAG,KAAK,CAAC;AAAA,IACnB,aAAa;AAAA,IACb,mBACC;AAAA,IACD,UAAU;AAAA,MACT,MAAM;AAAA,IACP;AAAA,I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AAG,IAAI,qBAAqB,EAAE,IACnF,IAAI;AACR,YAAM,iBAAiB,6BAA6B,YAAY,SAAS,IAAI;AAE7E,aAAO,EAAE,mBAAmB,KAAK;AAAA,IAClC,WAAW,gBAAgB,WAAW;AAQrC,UAAI,IAAI,WAAW,UAAU;AAC5B,cAAM,iBAAiB,oBAAoB,KAAK,IAAI;AAAA,MACrD,OAAO;AAEN,cAAM,YAAY,iBAAiB,aAAa,GAAG;AAEnD,YAAI,aAAa,iBAAiB,aAAa,SAAS,GAAG;AAC1D,gBAAM,iBAAiB,UAAM,kCAAkB,SAAS,IAAI;AAC5D,gBAAM,cAAc,MAAM,iBAAiB,kBAAkB,KAAK,MAAM,cAAc;AACtF,cAAI,YAAa,QAAO,EAAE,mBAAmB,MAAM,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE;AAAA,QACnF,OAAO;AAGN,gBAAM,iBAAiB,wCAAwC,YAAY,MAAM,GAAG;AAAA,QACrF;AAAA,MACD;AAEA,aAAO,EAAE,mBAAmB,KAAK;AAAA,IAClC;AAEA,WAAO,EAAE,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE;AAAA,EACzC;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../nodes/McpTrigger/McpTrigger.node.ts"],"sourcesContent":["import { WebhookAuthorizationError } from 'n8n-nodes-base/dist/nodes/Webhook/error';\nimport { validateWebhookAuthentication } from 'n8n-nodes-base/dist/nodes/Webhook/utils';\nimport type { INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';\nimport { NodeConnectionTypes, Node, nodeNameToToolName } from 'n8n-workflow';\n\nimport { getConnectedTools } from '../shared/helpers';\n\nimport type { CompressionResponse } from './FlushingTransport';\nimport { McpServerManager } from './McpServer';\n\nconst MCP_SSE_SETUP_PATH = 'sse';\nconst MCP_SSE_MESSAGES_PATH = 'messages';\n\nexport class McpTrigger extends Node {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'MCP Server Trigger',\n\t\tname: 'mcpTrigger',\n\t\ticon: {\n\t\t\tlight: 'file:../mcp.svg',\n\t\t\tdark: 'file:../mcp.dark.svg',\n\t\t},\n\t\tgroup: ['trigger'],\n\t\tversion: [1, 1.1, 2],\n\t\tdescription: 'Expose n8n tools as an MCP Server endpoint',\n\t\tactivationMessage:\n\t\t\t'You can now connect your MCP Clients to the URL, using SSE or Streamable HTTP transports.',\n\t\tdefaults: {\n\t\t\tname: 'MCP Server Trigger',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI', 'Core Nodes'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Root Nodes', 'Model Context Protocol'],\n\t\t\t\t'Core Nodes': ['Other Trigger Nodes'],\n\t\t\t},\n\t\t\talias: ['Model Context Protocol', 'MCP Server'],\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\ttriggerPanel: {\n\t\t\theader: 'Listen for MCP events',\n\t\t\texecutionsHelp: {\n\t\t\t\tinactive:\n\t\t\t\t\t\"This trigger has two modes: test and production.<br /><br /><b>Use test mode while you build your workflow</b>. Click the 'execute step' button, then make an MCP request to the test URL. The executions will show up in the editor.<br /><br /><b>Use production mode to run your workflow automatically</b>. Publish the workflow, then make requests to the production URL. These executions will show up in the <a data-key='executions'>executions list</a>, but not the editor.\",\n\t\t\t\tactive:\n\t\t\t\t\t\"This trigger has two modes: test and production.<br /><br /><b>Use test mode while you build your workflow</b>. Click the 'execute step' button, then make an MCP request to the test URL. The executions will show up in the editor.<br /><br /><b>Use production mode to run your workflow automatically</b>. Since your workflow is activated, you can make requests to the production URL. These executions will show up in the <a data-key='executions'>executions list</a>, but not the editor.\",\n\t\t\t},\n\t\t\tactivationHint:\n\t\t\t\t'Once you’ve finished building your workflow, run it without having to click this button by using the production URL.',\n\t\t},\n\t\tinputs: [\n\t\t\t{\n\t\t\t\ttype: NodeConnectionTypes.AiTool,\n\t\t\t\tdisplayName: 'Tools',\n\t\t\t},\n\t\t],\n\t\toutputs: [],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed\n\t\t\t\tname: 'httpBearerAuth',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['bearerAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'httpHeaderAuth',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['headerAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: 'None', value: 'none' },\n\t\t\t\t\t{ name: 'Bearer Auth', value: 'bearerAuth' },\n\t\t\t\t\t{ name: 'Header Auth', value: 'headerAuth' },\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Path',\n\t\t\t\tname: 'path',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'webhook',\n\t\t\t\trequired: true,\n\t\t\t\tdescription: 'The base path for this MCP server',\n\t\t\t},\n\t\t],\n\t\twebhooks: [\n\t\t\t{\n\t\t\t\tname: 'setup',\n\t\t\t\thttpMethod: 'GET',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tisFullPath: true,\n\t\t\t\tpath: `={{$parameter[\"path\"]}}{{parseFloat($nodeVersion)<2 ? '/${MCP_SSE_SETUP_PATH}' : ''}}`,\n\t\t\t\tnodeType: 'mcp',\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'POST',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tisFullPath: true,\n\t\t\t\tpath: `={{$parameter[\"path\"]}}{{parseFloat($nodeVersion)<2 ? '/${MCP_SSE_MESSAGES_PATH}' : ''}}`,\n\t\t\t\tnodeType: 'mcp',\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'DELETE',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tisFullPath: true,\n\t\t\t\tpath: '={{$parameter[\"path\"]}}',\n\t\t\t\tnodeType: 'mcp',\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: true,\n\t\t\t},\n\t\t],\n\t};\n\n\tasync webhook(context: IWebhookFunctions): Promise<IWebhookResponseData> {\n\t\tconst webhookName = context.getWebhookName();\n\t\tconst req = context.getRequestObject();\n\t\tconst resp = context.getResponseObject() as unknown as CompressionResponse;\n\n\t\ttry {\n\t\t\tawait validateWebhookAuthentication(context, 'authentication');\n\t\t} catch (error) {\n\t\t\tif (error instanceof WebhookAuthorizationError) {\n\t\t\t\tresp.writeHead(error.responseCode);\n\t\t\t\tresp.end(error.message);\n\t\t\t\treturn { noWebhookResponse: true };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tconst node = context.getNode();\n\t\t// Get a url/tool friendly name for the server, based on the node name\n\t\tconst serverName = node.typeVersion > 1 ? nodeNameToToolName(node) : 'n8n-mcp-server';\n\n\t\tconst mcpServerManager: McpServerManager = McpServerManager.instance(context.logger);\n\n\t\tif (webhookName === 'setup') {\n\t\t\t// Sets up the transport and opens the long-lived connection. This resp\n\t\t\t// will stay streaming, and is the channel that sends the events\n\n\t\t\t// Prior to version 2.0, we use different paths for the setup and messages.\n\t\t\tconst postUrl =\n\t\t\t\tnode.typeVersion < 2\n\t\t\t\t\t? req.path.replace(new RegExp(`/${MCP_SSE_SETUP_PATH}$`), `/${MCP_SSE_MESSAGES_PATH}`)\n\t\t\t\t\t: req.path;\n\t\t\tawait mcpServerManager.createServerWithSSETransport(serverName, postUrl, resp);\n\n\t\t\treturn { noWebhookResponse: true };\n\t\t} else if (webhookName === 'default') {\n\t\t\t// Here we handle POST and DELETE requests.\n\t\t\t// POST can be either:\n\t\t\t// 1) Client calls in an established session using the SSE transport, or\n\t\t\t// 2) Client calls in an established session using the StreamableHTTPServerTransport\n\t\t\t// 3) Session setup requests using the StreamableHTTPServerTransport\n\t\t\t// DELETE is used to terminate the session using the StreamableHTTPServerTransport\n\n\t\t\tif (req.method === 'DELETE') {\n\t\t\t\tawait mcpServerManager.handleDeleteRequest(req, resp);\n\t\t\t} else {\n\t\t\t\t// Check if there is a session and a transport is already established\n\t\t\t\tconst sessionId = mcpServerManager.getSessionId(req);\n\n\t\t\t\tif (sessionId && mcpServerManager.getTransport(sessionId)) {\n\t\t\t\t\tconst connectedTools = await getConnectedTools(context, true);\n\t\t\t\t\tconst wasToolCall = await mcpServerManager.handlePostMessage(req, resp, connectedTools);\n\t\t\t\t\tif (wasToolCall) return { noWebhookResponse: true, workflowData: [[{ json: {} }]] };\n\t\t\t\t} else {\n\t\t\t\t\t// If no session is established, this is a setup request\n\t\t\t\t\t// for the StreamableHTTPServerTransport, so we create a new transport\n\t\t\t\t\tawait mcpServerManager.createServerWithStreamableHTTPTransport(serverName, resp, req);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { noWebhookResponse: true };\n\t\t}\n\n\t\treturn { workflowData: [[{ json: {} }]] };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;A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1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var N8nBinaryLoader_exports = {};
|
|
20
|
+
__export(N8nBinaryLoader_exports, {
|
|
21
|
+
N8nBinaryLoader: () => N8nBinaryLoader
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(N8nBinaryLoader_exports);
|
|
24
|
+
var import_csv = require("@langchain/community/document_loaders/fs/csv");
|
|
25
|
+
var import_docx = require("@langchain/community/document_loaders/fs/docx");
|
|
26
|
+
var import_epub = require("@langchain/community/document_loaders/fs/epub");
|
|
27
|
+
var import_pdf = require("@langchain/community/document_loaders/fs/pdf");
|
|
28
|
+
var import_fs = require("fs");
|
|
29
|
+
var import_json = require("@langchain/classic/document_loaders/fs/json");
|
|
30
|
+
var import_text = require("@langchain/classic/document_loaders/fs/text");
|
|
31
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
32
|
+
var import_promises = require("stream/promises");
|
|
33
|
+
var import_tmp_promise = require("tmp-promise");
|
|
34
|
+
var import_helpers = require("./helpers");
|
|
35
|
+
const SUPPORTED_MIME_TYPES = {
|
|
36
|
+
auto: ["*/*"],
|
|
37
|
+
pdfLoader: ["application/pdf"],
|
|
38
|
+
csvLoader: ["text/csv"],
|
|
39
|
+
epubLoader: ["application/epub+zip"],
|
|
40
|
+
docxLoader: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
41
|
+
textLoader: ["text/plain", "text/mdx", "text/md", "text/markdown"],
|
|
42
|
+
jsonLoader: ["application/json"]
|
|
43
|
+
};
|
|
44
|
+
class N8nBinaryLoader {
|
|
45
|
+
constructor(context, optionsPrefix = "", binaryDataKey = "", textSplitter) {
|
|
46
|
+
this.context = context;
|
|
47
|
+
this.optionsPrefix = optionsPrefix;
|
|
48
|
+
this.binaryDataKey = binaryDataKey;
|
|
49
|
+
this.textSplitter = textSplitter;
|
|
50
|
+
}
|
|
51
|
+
async processAll(items) {
|
|
52
|
+
const docs = [];
|
|
53
|
+
if (!items) return [];
|
|
54
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
55
|
+
const processedDocuments = await this.processItem(items[itemIndex], itemIndex);
|
|
56
|
+
docs.push(...processedDocuments);
|
|
57
|
+
}
|
|
58
|
+
return docs;
|
|
59
|
+
}
|
|
60
|
+
async validateMimeType(mimeType, selectedLoader) {
|
|
61
|
+
if (selectedLoader !== "auto" && !SUPPORTED_MIME_TYPES[selectedLoader].includes(mimeType)) {
|
|
62
|
+
const neededLoader = Object.keys(SUPPORTED_MIME_TYPES).find(
|
|
63
|
+
(loader) => SUPPORTED_MIME_TYPES[loader].includes(mimeType)
|
|
64
|
+
);
|
|
65
|
+
throw new import_n8n_workflow.NodeOperationError(
|
|
66
|
+
this.context.getNode(),
|
|
67
|
+
`Mime type doesn't match selected loader. Please select under "Loader Type": ${neededLoader}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (!Object.values(SUPPORTED_MIME_TYPES).flat().includes(mimeType)) {
|
|
71
|
+
throw new import_n8n_workflow.NodeOperationError(this.context.getNode(), `Unsupported mime type: ${mimeType}`);
|
|
72
|
+
}
|
|
73
|
+
if (!SUPPORTED_MIME_TYPES[selectedLoader].includes(mimeType) && selectedLoader !== "textLoader" && selectedLoader !== "auto") {
|
|
74
|
+
throw new import_n8n_workflow.NodeOperationError(
|
|
75
|
+
this.context.getNode(),
|
|
76
|
+
`Unsupported mime type: ${mimeType} for selected loader: ${selectedLoader}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async getFilePathOrBlob(binaryData, mimeType) {
|
|
81
|
+
if (binaryData.id) {
|
|
82
|
+
const binaryBuffer = await this.context.helpers.binaryToBuffer(
|
|
83
|
+
await this.context.helpers.getBinaryStream(binaryData.id)
|
|
84
|
+
);
|
|
85
|
+
return new Blob([binaryBuffer], {
|
|
86
|
+
type: mimeType
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
return new Blob([Buffer.from(binaryData.data, import_n8n_workflow.BINARY_ENCODING)], {
|
|
90
|
+
type: mimeType
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async getLoader(mimeType, filePathOrBlob, itemIndex) {
|
|
95
|
+
switch (mimeType) {
|
|
96
|
+
case "application/pdf":
|
|
97
|
+
const splitPages = this.context.getNodeParameter(
|
|
98
|
+
`${this.optionsPrefix}splitPages`,
|
|
99
|
+
itemIndex,
|
|
100
|
+
false
|
|
101
|
+
);
|
|
102
|
+
return new import_pdf.PDFLoader(filePathOrBlob, { splitPages });
|
|
103
|
+
case "text/csv":
|
|
104
|
+
const column = this.context.getNodeParameter(
|
|
105
|
+
`${this.optionsPrefix}column`,
|
|
106
|
+
itemIndex,
|
|
107
|
+
null
|
|
108
|
+
);
|
|
109
|
+
const separator = this.context.getNodeParameter(
|
|
110
|
+
`${this.optionsPrefix}separator`,
|
|
111
|
+
itemIndex,
|
|
112
|
+
","
|
|
113
|
+
);
|
|
114
|
+
return new import_csv.CSVLoader(filePathOrBlob, { column: column ?? void 0, separator });
|
|
115
|
+
case "application/epub+zip":
|
|
116
|
+
let filePath;
|
|
117
|
+
if (filePathOrBlob instanceof Blob) {
|
|
118
|
+
const tmpFileData = await (0, import_tmp_promise.file)({ prefix: "epub-loader-" });
|
|
119
|
+
const bufferData = await filePathOrBlob.arrayBuffer();
|
|
120
|
+
await (0, import_promises.pipeline)([new Uint8Array(bufferData)], (0, import_fs.createWriteStream)(tmpFileData.path));
|
|
121
|
+
return new import_epub.EPubLoader(tmpFileData.path);
|
|
122
|
+
} else {
|
|
123
|
+
filePath = filePathOrBlob;
|
|
124
|
+
}
|
|
125
|
+
return new import_epub.EPubLoader(filePath);
|
|
126
|
+
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
127
|
+
return new import_docx.DocxLoader(filePathOrBlob);
|
|
128
|
+
case "text/plain":
|
|
129
|
+
return new import_text.TextLoader(filePathOrBlob);
|
|
130
|
+
case "application/json":
|
|
131
|
+
const pointers = this.context.getNodeParameter(
|
|
132
|
+
`${this.optionsPrefix}pointers`,
|
|
133
|
+
itemIndex,
|
|
134
|
+
""
|
|
135
|
+
);
|
|
136
|
+
const pointersArray = pointers.split(",").map((pointer) => pointer.trim());
|
|
137
|
+
return new import_json.JSONLoader(filePathOrBlob, pointersArray);
|
|
138
|
+
default:
|
|
139
|
+
return new import_text.TextLoader(filePathOrBlob);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async loadDocuments(loader) {
|
|
143
|
+
return this.textSplitter ? await this.textSplitter.splitDocuments(await loader.load()) : await loader.load();
|
|
144
|
+
}
|
|
145
|
+
async cleanupTmpFileIfNeeded(cleanupTmpFile) {
|
|
146
|
+
if (cleanupTmpFile) {
|
|
147
|
+
await cleanupTmpFile();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async processItem(item, itemIndex) {
|
|
151
|
+
const docs = [];
|
|
152
|
+
const binaryMode = this.context.getNodeParameter("binaryMode", itemIndex, "allInputData");
|
|
153
|
+
if (binaryMode === "allInputData") {
|
|
154
|
+
const binaryData = this.context.getInputData();
|
|
155
|
+
for (const data of binaryData) {
|
|
156
|
+
if (data.binary) {
|
|
157
|
+
const binaryDataKeys = Object.keys(data.binary);
|
|
158
|
+
for (const fileKey of binaryDataKeys) {
|
|
159
|
+
const processedDocuments = await this.processItemByKey(item, itemIndex, fileKey);
|
|
160
|
+
docs.push(...processedDocuments);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
const processedDocuments = await this.processItemByKey(item, itemIndex, this.binaryDataKey);
|
|
166
|
+
docs.push(...processedDocuments);
|
|
167
|
+
}
|
|
168
|
+
return docs;
|
|
169
|
+
}
|
|
170
|
+
async processItemByKey(item, itemIndex, binaryKey) {
|
|
171
|
+
const selectedLoader = this.context.getNodeParameter(
|
|
172
|
+
"loader",
|
|
173
|
+
itemIndex,
|
|
174
|
+
"auto"
|
|
175
|
+
);
|
|
176
|
+
const docs = [];
|
|
177
|
+
const metadata = (0, import_helpers.getMetadataFiltersValues)(this.context, itemIndex);
|
|
178
|
+
if (!item) return [];
|
|
179
|
+
const binaryData = this.context.helpers.assertBinaryData(itemIndex, binaryKey);
|
|
180
|
+
const { mimeType } = binaryData;
|
|
181
|
+
await this.validateMimeType(mimeType, selectedLoader);
|
|
182
|
+
const filePathOrBlob = await this.getFilePathOrBlob(binaryData, mimeType);
|
|
183
|
+
const cleanupTmpFile = void 0;
|
|
184
|
+
const loader = await this.getLoader(mimeType, filePathOrBlob, itemIndex);
|
|
185
|
+
const loadedDoc = await this.loadDocuments(loader);
|
|
186
|
+
docs.push(...loadedDoc);
|
|
187
|
+
if (metadata) {
|
|
188
|
+
docs.forEach((document) => {
|
|
189
|
+
document.metadata = {
|
|
190
|
+
...document.metadata,
|
|
191
|
+
...metadata
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
await this.cleanupTmpFileIfNeeded(cleanupTmpFile);
|
|
196
|
+
return docs;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
200
|
+
0 && (module.exports = {
|
|
201
|
+
N8nBinaryLoader
|
|
202
|
+
});
|
|
203
|
+
//# sourceMappingURL=N8nBinaryLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../nodes/shared/N8nBinaryLoader.ts"],"sourcesContent":["import { CSVLoader } from '@langchain/community/document_loaders/fs/csv';\nimport { DocxLoader } from '@langchain/community/document_loaders/fs/docx';\nimport { EPubLoader } from '@langchain/community/document_loaders/fs/epub';\nimport { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';\nimport type { Document } from '@langchain/core/documents';\nimport type { TextSplitter } from '@langchain/textsplitters';\nimport { createWriteStream } from 'fs';\nimport { JSONLoader } from '@langchain/classic/document_loaders/fs/json';\nimport { TextLoader } from '@langchain/classic/document_loaders/fs/text';\nimport type {\n\tIBinaryData,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tISupplyDataFunctions,\n} from 'n8n-workflow';\nimport { NodeOperationError, BINARY_ENCODING } from 'n8n-workflow';\nimport { pipeline } from 'stream/promises';\nimport { file as tmpFile, type DirectoryResult } from 'tmp-promise';\n\nimport { getMetadataFiltersValues } from './helpers';\n\nconst SUPPORTED_MIME_TYPES = {\n\tauto: ['*/*'],\n\tpdfLoader: ['application/pdf'],\n\tcsvLoader: ['text/csv'],\n\tepubLoader: ['application/epub+zip'],\n\tdocxLoader: ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],\n\ttextLoader: ['text/plain', 'text/mdx', 'text/md', 'text/markdown'],\n\tjsonLoader: ['application/json'],\n};\n\nexport class N8nBinaryLoader {\n\tconstructor(\n\t\tprivate context: IExecuteFunctions | ISupplyDataFunctions,\n\t\tprivate optionsPrefix = '',\n\t\tprivate binaryDataKey = '',\n\t\tprivate textSplitter?: TextSplitter,\n\t) {}\n\n\tasync processAll(items?: INodeExecutionData[]): Promise<Document[]> {\n\t\tconst docs: Document[] = [];\n\n\t\tif (!items) return [];\n\n\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\tconst processedDocuments = await this.processItem(items[itemIndex], itemIndex);\n\n\t\t\tdocs.push(...processedDocuments);\n\t\t}\n\n\t\treturn docs;\n\t}\n\n\tprivate async validateMimeType(\n\t\tmimeType: string,\n\t\tselectedLoader: keyof typeof SUPPORTED_MIME_TYPES,\n\t): Promise<void> {\n\t\t// Check if loader matches the mime-type of the data\n\t\tif (selectedLoader !== 'auto' && !SUPPORTED_MIME_TYPES[selectedLoader].includes(mimeType)) {\n\t\t\tconst neededLoader = Object.keys(SUPPORTED_MIME_TYPES).find((loader) =>\n\t\t\t\tSUPPORTED_MIME_TYPES[loader as keyof typeof SUPPORTED_MIME_TYPES].includes(mimeType),\n\t\t\t);\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.context.getNode(),\n\t\t\t\t`Mime type doesn't match selected loader. Please select under \"Loader Type\": ${neededLoader}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!Object.values(SUPPORTED_MIME_TYPES).flat().includes(mimeType)) {\n\t\t\tthrow new NodeOperationError(this.context.getNode(), `Unsupported mime type: ${mimeType}`);\n\t\t}\n\n\t\tif (\n\t\t\t!SUPPORTED_MIME_TYPES[selectedLoader].includes(mimeType) &&\n\t\t\tselectedLoader !== 'textLoader' &&\n\t\t\tselectedLoader !== 'auto'\n\t\t) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.context.getNode(),\n\t\t\t\t`Unsupported mime type: ${mimeType} for selected loader: ${selectedLoader}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async getFilePathOrBlob(\n\t\tbinaryData: IBinaryData,\n\t\tmimeType: string,\n\t): Promise<string | Blob> {\n\t\tif (binaryData.id) {\n\t\t\tconst binaryBuffer = await this.context.helpers.binaryToBuffer(\n\t\t\t\tawait this.context.helpers.getBinaryStream(binaryData.id),\n\t\t\t);\n\t\t\treturn new Blob([binaryBuffer as BlobPart], {\n\t\t\t\ttype: mimeType,\n\t\t\t});\n\t\t} else {\n\t\t\treturn new Blob([Buffer.from(binaryData.data, BINARY_ENCODING)], {\n\t\t\t\ttype: mimeType,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async getLoader(\n\t\tmimeType: string,\n\t\tfilePathOrBlob: string | Blob,\n\t\titemIndex: number,\n\t): Promise<PDFLoader | CSVLoader | EPubLoader | DocxLoader | TextLoader | JSONLoader> {\n\t\tswitch (mimeType) {\n\t\t\tcase 'application/pdf':\n\t\t\t\tconst splitPages = this.context.getNodeParameter(\n\t\t\t\t\t`${this.optionsPrefix}splitPages`,\n\t\t\t\t\titemIndex,\n\t\t\t\t\tfalse,\n\t\t\t\t) as boolean;\n\t\t\t\treturn new PDFLoader(filePathOrBlob, { splitPages });\n\t\t\tcase 'text/csv':\n\t\t\t\tconst column = this.context.getNodeParameter(\n\t\t\t\t\t`${this.optionsPrefix}column`,\n\t\t\t\t\titemIndex,\n\t\t\t\t\tnull,\n\t\t\t\t) as string;\n\t\t\t\tconst separator = this.context.getNodeParameter(\n\t\t\t\t\t`${this.optionsPrefix}separator`,\n\t\t\t\t\titemIndex,\n\t\t\t\t\t',',\n\t\t\t\t) as string;\n\t\t\t\treturn new CSVLoader(filePathOrBlob, { column: column ?? undefined, separator });\n\t\t\tcase 'application/epub+zip':\n\t\t\t\t// EPubLoader currently does not accept Blobs https://github.com/langchain-ai/langchainjs/issues/1623\n\t\t\t\tlet filePath: string;\n\t\t\t\tif (filePathOrBlob instanceof Blob) {\n\t\t\t\t\tconst tmpFileData = await tmpFile({ prefix: 'epub-loader-' });\n\t\t\t\t\tconst bufferData = await filePathOrBlob.arrayBuffer();\n\t\t\t\t\tawait pipeline([new Uint8Array(bufferData)], createWriteStream(tmpFileData.path));\n\t\t\t\t\treturn new EPubLoader(tmpFileData.path);\n\t\t\t\t} else {\n\t\t\t\t\tfilePath = filePathOrBlob;\n\t\t\t\t}\n\t\t\t\treturn new EPubLoader(filePath);\n\t\t\tcase 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':\n\t\t\t\treturn new DocxLoader(filePathOrBlob);\n\t\t\tcase 'text/plain':\n\t\t\t\treturn new TextLoader(filePathOrBlob);\n\t\t\tcase 'application/json':\n\t\t\t\tconst pointers = this.context.getNodeParameter(\n\t\t\t\t\t`${this.optionsPrefix}pointers`,\n\t\t\t\t\titemIndex,\n\t\t\t\t\t'',\n\t\t\t\t) as string;\n\t\t\t\tconst pointersArray = pointers.split(',').map((pointer) => pointer.trim());\n\t\t\t\treturn new JSONLoader(filePathOrBlob, pointersArray);\n\t\t\tdefault:\n\t\t\t\treturn new TextLoader(filePathOrBlob);\n\t\t}\n\t}\n\n\tprivate async loadDocuments(\n\t\tloader: PDFLoader | CSVLoader | EPubLoader | DocxLoader | TextLoader | JSONLoader,\n\t): Promise<Document[]> {\n\t\treturn this.textSplitter\n\t\t\t? await this.textSplitter.splitDocuments(await loader.load())\n\t\t\t: await loader.load();\n\t}\n\n\tprivate async cleanupTmpFileIfNeeded(\n\t\tcleanupTmpFile: DirectoryResult['cleanup'] | undefined,\n\t): Promise<void> {\n\t\tif (cleanupTmpFile) {\n\t\t\tawait cleanupTmpFile();\n\t\t}\n\t}\n\n\tasync processItem(item: INodeExecutionData, itemIndex: number): Promise<Document[]> {\n\t\tconst docs: Document[] = [];\n\t\tconst binaryMode = this.context.getNodeParameter('binaryMode', itemIndex, 'allInputData');\n\t\tif (binaryMode === 'allInputData') {\n\t\t\tconst binaryData = this.context.getInputData();\n\n\t\t\tfor (const data of binaryData) {\n\t\t\t\tif (data.binary) {\n\t\t\t\t\tconst binaryDataKeys = Object.keys(data.binary);\n\n\t\t\t\t\tfor (const fileKey of binaryDataKeys) {\n\t\t\t\t\t\tconst processedDocuments = await this.processItemByKey(item, itemIndex, fileKey);\n\t\t\t\t\t\tdocs.push(...processedDocuments);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst processedDocuments = await this.processItemByKey(item, itemIndex, this.binaryDataKey);\n\t\t\tdocs.push(...processedDocuments);\n\t\t}\n\n\t\treturn docs;\n\t}\n\n\tasync processItemByKey(\n\t\titem: INodeExecutionData,\n\t\titemIndex: number,\n\t\tbinaryKey: string,\n\t): Promise<Document[]> {\n\t\tconst selectedLoader: keyof typeof SUPPORTED_MIME_TYPES = this.context.getNodeParameter(\n\t\t\t'loader',\n\t\t\titemIndex,\n\t\t\t'auto',\n\t\t) as keyof typeof SUPPORTED_MIME_TYPES;\n\n\t\tconst docs: Document[] = [];\n\t\tconst metadata = getMetadataFiltersValues(this.context, itemIndex);\n\n\t\tif (!item) return [];\n\n\t\tconst binaryData = this.context.helpers.assertBinaryData(itemIndex, binaryKey);\n\t\tconst { mimeType } = binaryData;\n\n\t\tawait this.validateMimeType(mimeType, selectedLoader);\n\n\t\tconst filePathOrBlob = await this.getFilePathOrBlob(binaryData, mimeType);\n\t\tconst cleanupTmpFile: DirectoryResult['cleanup'] | undefined = undefined;\n\t\tconst loader = await this.getLoader(mimeType, filePathOrBlob, itemIndex);\n\t\tconst loadedDoc = await this.loadDocuments(loader);\n\n\t\tdocs.push(...loadedDoc);\n\n\t\tif (metadata) {\n\t\t\tdocs.forEach((document) => {\n\t\t\t\tdocument.metadata = {\n\t\t\t\t\t...document.metadata,\n\t\t\t\t\t...metadata,\n\t\t\t\t};\n\t\t\t});\n\t\t}\n\n\t\tawait this.cleanupTmpFileIfNeeded(cleanupTmpFile);\n\n\t\treturn docs;\n\t}\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0B;AAC1B,kBAA2B;AAC3B,kBAA2B;AAC3B,iBAA0B;AAG1B,gBAAkC;AAClC,kBAA2B;AAC3B,kBAA2B;AAO3B,0BAAoD;AACpD,sBAAyB;AACzB,yBAAsD;AAEtD,qBAAyC;AAEzC,MAAM,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,YAAM,qBAAqB,MAAM,KAAK,iBAAiB,MAAM,WAAW,KAAK,aAAa;AAC1F,WAAK,KAAK,GAAG,kBAAkB;AAAA,IAChC;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,iBACL,MACA,WACA,WACsB;AACtB,UAAM,iBAAoD,KAAK,QAAQ;AAAA,MACtE;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAEA,UAAM,OAAmB,CAAC;AAC1B,UAAM,eAAW,yCAAyB,KAAK,SAAS,SAAS;AAEjE,QAAI,CAAC,KAAM,QAAO,CAAC;AAEnB,UAAM,aAAa,KAAK,QAAQ,QAAQ,iBAAiB,WAAW,SAAS;AAC7E,UAAM,EAAE,SAAS,IAAI;AAErB,UAAM,KAAK,iBAAiB,UAAU,cAAc;AAEpD,UAAM,iBAAiB,MAAM,KAAK,kBAAkB,YAAY,QAAQ;AACxE,UAAM,iBAAyD;AAC/D,UAAM,SAAS,MAAM,KAAK,UAAU,UAAU,gBAAgB,SAAS;AACvE,UAAM,YAAY,MAAM,KAAK,cAAc,MAAM;AAEjD,SAAK,KAAK,GAAG,SAAS;AAEtB,QAAI,UAAU;AACb,WAAK,QAAQ,CAAC,aAAa;AAC1B,iBAAS,WAAW;AAAA,UACnB,GAAG,SAAS;AAAA,UACZ,GAAG;AAAA,QACJ;AAAA,MACD,CAAC;AAAA,IACF;AAEA,UAAM,KAAK,uBAAuB,cAAc;AAEhD,WAAO;AAAA,EACR;AACD;","names":["tmpFile"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var N8nJsonLoader_exports = {};
|
|
20
|
+
__export(N8nJsonLoader_exports, {
|
|
21
|
+
N8nJsonLoader: () => N8nJsonLoader
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(N8nJsonLoader_exports);
|
|
24
|
+
var import_json = require("@langchain/classic/document_loaders/fs/json");
|
|
25
|
+
var import_text = require("@langchain/classic/document_loaders/fs/text");
|
|
26
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
27
|
+
var import_helpers = require("./helpers");
|
|
28
|
+
class N8nJsonLoader {
|
|
29
|
+
constructor(context, optionsPrefix = "", textSplitter) {
|
|
30
|
+
this.context = context;
|
|
31
|
+
this.optionsPrefix = optionsPrefix;
|
|
32
|
+
this.textSplitter = textSplitter;
|
|
33
|
+
}
|
|
34
|
+
async processAll(items) {
|
|
35
|
+
const docs = [];
|
|
36
|
+
if (!items) return [];
|
|
37
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
38
|
+
const processedDocuments = await this.processItem(items[itemIndex], itemIndex);
|
|
39
|
+
docs.push(...processedDocuments);
|
|
40
|
+
}
|
|
41
|
+
return docs;
|
|
42
|
+
}
|
|
43
|
+
async processItem(item, itemIndex) {
|
|
44
|
+
const mode = this.context.getNodeParameter("jsonMode", itemIndex, "allInputData");
|
|
45
|
+
const pointers = this.context.getNodeParameter(
|
|
46
|
+
`${this.optionsPrefix}pointers`,
|
|
47
|
+
itemIndex,
|
|
48
|
+
""
|
|
49
|
+
);
|
|
50
|
+
const pointersArray = pointers.split(",").map((pointer) => pointer.trim());
|
|
51
|
+
const metadata = (0, import_helpers.getMetadataFiltersValues)(this.context, itemIndex) ?? [];
|
|
52
|
+
if (!item) return [];
|
|
53
|
+
let documentLoader = null;
|
|
54
|
+
if (mode === "allInputData") {
|
|
55
|
+
const itemString = JSON.stringify(item.json);
|
|
56
|
+
const itemBlob = new Blob([itemString], { type: "application/json" });
|
|
57
|
+
documentLoader = new import_json.JSONLoader(itemBlob, pointersArray);
|
|
58
|
+
}
|
|
59
|
+
if (mode === "expressionData") {
|
|
60
|
+
const dataString = this.context.getNodeParameter("jsonData", itemIndex);
|
|
61
|
+
if (typeof dataString === "object") {
|
|
62
|
+
const itemBlob = new Blob([JSON.stringify(dataString)], { type: "application/json" });
|
|
63
|
+
documentLoader = new import_json.JSONLoader(itemBlob, pointersArray);
|
|
64
|
+
}
|
|
65
|
+
if (typeof dataString === "string") {
|
|
66
|
+
const itemBlob = new Blob([dataString], { type: "text/plain" });
|
|
67
|
+
documentLoader = new import_text.TextLoader(itemBlob);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (documentLoader === null) {
|
|
71
|
+
throw new import_n8n_workflow.NodeOperationError(this.context.getNode(), "Document loader is not initialized");
|
|
72
|
+
}
|
|
73
|
+
const docs = this.textSplitter ? await this.textSplitter.splitDocuments(await documentLoader.load()) : await documentLoader.load();
|
|
74
|
+
if (metadata) {
|
|
75
|
+
docs.forEach((doc) => {
|
|
76
|
+
doc.metadata = {
|
|
77
|
+
...doc.metadata,
|
|
78
|
+
...metadata
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return docs;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
N8nJsonLoader
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=N8nJsonLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../nodes/shared/N8nJsonLoader.ts"],"sourcesContent":["import type { Document } from '@langchain/core/documents';\nimport type { TextSplitter } from '@langchain/textsplitters';\nimport { JSONLoader } from '@langchain/classic/document_loaders/fs/json';\nimport { TextLoader } from '@langchain/classic/document_loaders/fs/text';\nimport {\n\ttype IExecuteFunctions,\n\ttype INodeExecutionData,\n\ttype ISupplyDataFunctions,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport { getMetadataFiltersValues } from './helpers';\n\nexport class N8nJsonLoader {\n\tconstructor(\n\t\tprivate context: IExecuteFunctions | ISupplyDataFunctions,\n\t\tprivate optionsPrefix = '',\n\t\tprivate textSplitter?: TextSplitter,\n\t) {}\n\n\tasync processAll(items?: INodeExecutionData[]): Promise<Document[]> {\n\t\tconst docs: Document[] = [];\n\n\t\tif (!items) return [];\n\n\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\tconst processedDocuments = await this.processItem(items[itemIndex], itemIndex);\n\n\t\t\tdocs.push(...processedDocuments);\n\t\t}\n\n\t\treturn docs;\n\t}\n\n\tasync processItem(item: INodeExecutionData, itemIndex: number): Promise<Document[]> {\n\t\tconst mode = this.context.getNodeParameter('jsonMode', itemIndex, 'allInputData') as\n\t\t\t| 'allInputData'\n\t\t\t| 'expressionData';\n\n\t\tconst pointers = this.context.getNodeParameter(\n\t\t\t`${this.optionsPrefix}pointers`,\n\t\t\titemIndex,\n\t\t\t'',\n\t\t) as string;\n\t\tconst pointersArray = pointers.split(',').map((pointer) => pointer.trim());\n\t\tconst metadata = getMetadataFiltersValues(this.context, itemIndex) ?? [];\n\n\t\tif (!item) return [];\n\n\t\tlet documentLoader: JSONLoader | TextLoader | null = null;\n\n\t\tif (mode === 'allInputData') {\n\t\t\tconst itemString = JSON.stringify(item.json);\n\t\t\tconst itemBlob = new Blob([itemString], { type: 'application/json' });\n\t\t\tdocumentLoader = new JSONLoader(itemBlob, pointersArray);\n\t\t}\n\n\t\tif (mode === 'expressionData') {\n\t\t\tconst dataString = this.context.getNodeParameter('jsonData', itemIndex) as string | object;\n\t\t\tif (typeof dataString === 'object') {\n\t\t\t\tconst itemBlob = new Blob([JSON.stringify(dataString)], { type: 'application/json' });\n\t\t\t\tdocumentLoader = new JSONLoader(itemBlob, pointersArray);\n\t\t\t}\n\n\t\t\tif (typeof dataString === 'string') {\n\t\t\t\tconst itemBlob = new Blob([dataString], { type: 'text/plain' });\n\t\t\t\tdocumentLoader = new TextLoader(itemBlob);\n\t\t\t}\n\t\t}\n\n\t\tif (documentLoader === null) {\n\t\t\t// This should never happen\n\t\t\tthrow new NodeOperationError(this.context.getNode(), 'Document loader is not initialized');\n\t\t}\n\n\t\tconst docs = this.textSplitter\n\t\t\t? await this.textSplitter.splitDocuments(await documentLoader.load())\n\t\t\t: await documentLoader.load();\n\n\t\tif (metadata) {\n\t\t\tdocs.forEach((doc) => {\n\t\t\t\tdoc.metadata = {\n\t\t\t\t\t...doc.metadata,\n\t\t\t\t\t...metadata,\n\t\t\t\t};\n\t\t\t});\n\t\t}\n\t\treturn docs;\n\t}\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA2B;AAC3B,kBAA2B;AAC3B,0BAKO;AAEP,qBAAyC;AAElC,MAAM,cAAc;AAAA,EAC1B,YACS,SACA,gBAAgB,IAChB,cACP;AAHO;AACA;AACA;AAAA,EACN;AAAA,EAEH,MAAM,WAAW,OAAmD;AACnE,UAAM,OAAmB,CAAC;AAE1B,QAAI,CAAC,MAAO,QAAO,CAAC;AAEpB,aAAS,YAAY,GAAG,YAAY,MAAM,QAAQ,aAAa;AAC9D,YAAM,qBAAqB,MAAM,KAAK,YAAY,MAAM,SAAS,GAAG,SAAS;AAE7E,WAAK,KAAK,GAAG,kBAAkB;AAAA,IAChC;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,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