@n8n/n8n-nodes-langchain 1.106.2 → 1.107.0
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/credentials/ZepApi.credentials.js +6 -0
- package/dist/credentials/ZepApi.credentials.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +1 -1
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js +1 -1
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js +1 -1
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js.map +1 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +1 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
- package/dist/nodes/llms/LmChatVercelAiGateway/LmChatVercelAiGateway.node.js +1 -1
- package/dist/nodes/llms/LmChatVercelAiGateway/LmChatVercelAiGateway.node.js.map +1 -1
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js +1 -1
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js +22 -1
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/utils.js +4 -2
- package/dist/nodes/mcp/McpClientTool/utils.js.map +1 -1
- package/dist/nodes/memory/MemoryZep/MemoryZep.node.js +7 -0
- package/dist/nodes/memory/MemoryZep/MemoryZep.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js +93 -83
- package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js +7 -0
- package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreZepInsert/VectorStoreZepInsert.node.js +6 -0
- package/dist/nodes/vector_store/VectorStoreZepInsert/VectorStoreZepInsert.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreZepLoad/VectorStoreZepLoad.node.js +6 -0
- package/dist/nodes/vector_store/VectorStoreZepLoad/VectorStoreZepLoad.node.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js.map +1 -1
- package/dist/nodes/vendors/GoogleGemini/transport/index.js +2 -2
- package/dist/nodes/vendors/GoogleGemini/transport/index.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.js +1 -1
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.js.map +1 -1
- package/dist/types/credentials.json +1 -1
- package/dist/types/nodes.json +5 -5
- package/package.json +11 -11
|
@@ -216,6 +216,26 @@ class McpClientTool {
|
|
|
216
216
|
include: ["except"]
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
displayName: "Options",
|
|
222
|
+
name: "options",
|
|
223
|
+
placeholder: "Add Option",
|
|
224
|
+
description: "Additional options to add",
|
|
225
|
+
type: "collection",
|
|
226
|
+
default: {},
|
|
227
|
+
options: [
|
|
228
|
+
{
|
|
229
|
+
displayName: "Timeout",
|
|
230
|
+
name: "timeout",
|
|
231
|
+
type: "number",
|
|
232
|
+
typeOptions: {
|
|
233
|
+
minValue: 1
|
|
234
|
+
},
|
|
235
|
+
default: 6e4,
|
|
236
|
+
description: "Time in ms to wait for tool calls to finish"
|
|
237
|
+
}
|
|
238
|
+
]
|
|
219
239
|
}
|
|
220
240
|
]
|
|
221
241
|
};
|
|
@@ -231,6 +251,7 @@ class McpClientTool {
|
|
|
231
251
|
itemIndex
|
|
232
252
|
);
|
|
233
253
|
const node = this.getNode();
|
|
254
|
+
const timeout = this.getNodeParameter("options.timeout", itemIndex, 6e4);
|
|
234
255
|
let serverTransport;
|
|
235
256
|
let endpointUrl;
|
|
236
257
|
if (node.typeVersion === 1) {
|
|
@@ -286,7 +307,7 @@ class McpClientTool {
|
|
|
286
307
|
(tool) => (0, import_logWrapper.logWrapper)(
|
|
287
308
|
(0, import_utils.mcpToolToDynamicTool)(
|
|
288
309
|
tool,
|
|
289
|
-
(0, import_utils.createCallTool)(tool.name, client.result, (errorMessage) => {
|
|
310
|
+
(0, import_utils.createCallTool)(tool.name, client.result, timeout, (errorMessage) => {
|
|
290
311
|
const error = new import_n8n_workflow.NodeOperationError(node, errorMessage, { itemIndex });
|
|
291
312
|
void this.addOutputData(import_n8n_workflow.NodeConnectionTypes.AiTool, itemIndex, error);
|
|
292
313
|
this.logger.error(`McpClientTool: Tool "${tool.name}" failed to execute`, { error });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/mcp/McpClientTool/McpClientTool.node.ts"],"sourcesContent":["import { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\nimport {\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getTools } from './loadOptions';\nimport type { McpServerTransport, McpAuthenticationOption, McpToolIncludeMode } from './types';\nimport {\n\tconnectMcpClient,\n\tcreateCallTool,\n\tgetAllTools,\n\tgetAuthHeaders,\n\tgetSelectedTools,\n\tMcpToolkit,\n\tmcpToolToDynamicTool,\n} from './utils';\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],\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\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\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\t{\n\t\t\t\tdisplayName: 'Server Transport',\n\t\t\t\tname: 'serverTransport',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Server Sent Events (Deprecated)',\n\t\t\t\t\t\tvalue: 'sse',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'HTTP Streamable',\n\t\t\t\t\t\tvalue: 'httpStreamable',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'sse',\n\t\t\t\tdescription: 'The transport used by your endpoint',\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\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},\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'],\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],\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 authentication = this.getNodeParameter(\n\t\t\t'authentication',\n\t\t\titemIndex,\n\t\t) as McpAuthenticationOption;\n\t\tconst node = this.getNode();\n\n\t\tlet serverTransport: McpServerTransport;\n\t\tlet endpointUrl: string;\n\t\tif (node.typeVersion === 1) {\n\t\t\tserverTransport = 'sse';\n\t\t\tendpointUrl = this.getNodeParameter('sseEndpoint', itemIndex) as string;\n\t\t} else {\n\t\t\tserverTransport = this.getNodeParameter('serverTransport', itemIndex) as McpServerTransport;\n\t\t\tendpointUrl = this.getNodeParameter('endpointUrl', itemIndex) as string;\n\t\t}\n\n\t\tconst { headers } = await getAuthHeaders(this, authentication);\n\t\tconst client = await connectMcpClient({\n\t\t\tserverTransport,\n\t\t\tendpointUrl,\n\t\t\theaders,\n\t\t\tname: node.type,\n\t\t\tversion: node.typeVersion,\n\t\t});\n\n\t\tconst setError = (message: string, description?: string): SupplyData => {\n\t\t\tconst error = new NodeOperationError(node, message, { itemIndex, description });\n\t\t\tthis.addOutputData(NodeConnectionTypes.AiTool, itemIndex, error);\n\t\t\tthrow error;\n\t\t};\n\n\t\tif (!client.ok) {\n\t\t\tthis.logger.error('McpClientTool: Failed to connect to MCP Server', {\n\t\t\t\terror: client.error,\n\t\t\t});\n\n\t\t\tswitch (client.error.type) {\n\t\t\t\tcase 'invalid_url':\n\t\t\t\t\treturn setError('Could not connect to your MCP server. The provided URL is invalid.');\n\t\t\t\tcase 'connection':\n\t\t\t\tdefault:\n\t\t\t\t\treturn setError('Could not connect to your MCP server');\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.debug('McpClientTool: Successfully connected to MCP Server');\n\n\t\tconst mode = this.getNodeParameter('include', itemIndex) as McpToolIncludeMode;\n\t\tconst includeTools = this.getNodeParameter('includeTools', itemIndex, []) as string[];\n\t\tconst excludeTools = this.getNodeParameter('excludeTools', itemIndex, []) as string[];\n\n\t\tconst allTools = await getAllTools(client.result);\n\t\tconst mcpTools = getSelectedTools({\n\t\t\ttools: allTools,\n\t\t\tmode,\n\t\t\tincludeTools,\n\t\t\texcludeTools,\n\t\t});\n\n\t\tif (!mcpTools.length) {\n\t\t\treturn setError(\n\t\t\t\t'MCP Server returned no tools',\n\t\t\t\t'Connected successfully to your MCP server but it returned an empty list of tools.',\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.result, (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.result.close() };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA2B;AAC3B,0BAA6C;AAC7C,0BAOO;AAEP,yBAAyB;AAEzB,mBAQO;AAEA,MAAM,cAAmC;AAAA,EAAzC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,MACP;AAAA,MACA,OAAO,CAAC,QAAQ;AAAA,MAChB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,0BAA0B,OAAO;AAAA,QACvC;AAAA,QACA,OAAO,CAAC,0BAA0B,YAAY;AAAA,QAC9C,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,SAAS,CAAC,EAAE,MAAM,wCAAoB,QAAQ,aAAa,QAAQ,CAAC;AAAA,MACpE,aAAa;AAAA,QACZ;AAAA;AAAA,UAEC,MAAM;AAAA,UACN,UAAU;AAAA,UACV,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,gBAAgB,CAAC,YAAY;AAAA,YAC9B;AAAA,UACD;AAAA,QACD;AAAA,QACA;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,UACV,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,gBAAgB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;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAED,QAAI,CAAC,SAAS,QAAQ;AACrB,aAAO;AAAA,QACN;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,UAAM,QAAQ,SAAS;AAAA,MAAI,CAAC,aAC3B;AAAA,YACC;AAAA,UACC;AAAA,cACA,6BAAe,KAAK,MAAM,OAAO,QAAQ,CAAC,iBAAiB;AAC1D,kBAAM,QAAQ,IAAI,uCAAmB,MAAM,cAAc,EAAE,UAAU,CAAC;AACtE,iBAAK,KAAK,cAAc,wCAAoB,QAAQ,WAAW,KAAK;AACpE,iBAAK,OAAO,MAAM,wBAAwB,KAAK,IAAI,uBAAuB,EAAE,MAAM,CAAC;AAAA,UACpF,CAAC;AAAA,QACF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,SAAK,OAAO,MAAM,+CAA+C,MAAM,MAAM,QAAQ;AAErF,UAAM,UAAU,IAAI,wBAAW,KAAK;AAEpC,WAAO,EAAE,UAAU,SAAS,eAAe,YAAY,MAAM,OAAO,OAAO,MAAM,EAAE;AAAA,EACpF;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/mcp/McpClientTool/McpClientTool.node.ts"],"sourcesContent":["import { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\nimport {\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getTools } from './loadOptions';\nimport type { McpServerTransport, McpAuthenticationOption, McpToolIncludeMode } from './types';\nimport {\n\tconnectMcpClient,\n\tcreateCallTool,\n\tgetAllTools,\n\tgetAuthHeaders,\n\tgetSelectedTools,\n\tMcpToolkit,\n\tmcpToolToDynamicTool,\n} from './utils';\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],\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\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\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\t{\n\t\t\t\tdisplayName: 'Server Transport',\n\t\t\t\tname: 'serverTransport',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Server Sent Events (Deprecated)',\n\t\t\t\t\t\tvalue: 'sse',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'HTTP Streamable',\n\t\t\t\t\t\tvalue: 'httpStreamable',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'sse',\n\t\t\t\tdescription: 'The transport used by your endpoint',\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\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},\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'],\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: '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 authentication = this.getNodeParameter(\n\t\t\t'authentication',\n\t\t\titemIndex,\n\t\t) as McpAuthenticationOption;\n\t\tconst node = this.getNode();\n\t\tconst timeout = this.getNodeParameter('options.timeout', itemIndex, 60000) as number;\n\n\t\tlet serverTransport: McpServerTransport;\n\t\tlet endpointUrl: string;\n\t\tif (node.typeVersion === 1) {\n\t\t\tserverTransport = 'sse';\n\t\t\tendpointUrl = this.getNodeParameter('sseEndpoint', itemIndex) as string;\n\t\t} else {\n\t\t\tserverTransport = this.getNodeParameter('serverTransport', itemIndex) as McpServerTransport;\n\t\t\tendpointUrl = this.getNodeParameter('endpointUrl', itemIndex) as string;\n\t\t}\n\n\t\tconst { headers } = await getAuthHeaders(this, authentication);\n\t\tconst client = await connectMcpClient({\n\t\t\tserverTransport,\n\t\t\tendpointUrl,\n\t\t\theaders,\n\t\t\tname: node.type,\n\t\t\tversion: node.typeVersion,\n\t\t});\n\n\t\tconst setError = (message: string, description?: string): SupplyData => {\n\t\t\tconst error = new NodeOperationError(node, message, { itemIndex, description });\n\t\t\tthis.addOutputData(NodeConnectionTypes.AiTool, itemIndex, error);\n\t\t\tthrow error;\n\t\t};\n\n\t\tif (!client.ok) {\n\t\t\tthis.logger.error('McpClientTool: Failed to connect to MCP Server', {\n\t\t\t\terror: client.error,\n\t\t\t});\n\n\t\t\tswitch (client.error.type) {\n\t\t\t\tcase 'invalid_url':\n\t\t\t\t\treturn setError('Could not connect to your MCP server. The provided URL is invalid.');\n\t\t\t\tcase 'connection':\n\t\t\t\tdefault:\n\t\t\t\t\treturn setError('Could not connect to your MCP server');\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.debug('McpClientTool: Successfully connected to MCP Server');\n\n\t\tconst mode = this.getNodeParameter('include', itemIndex) as McpToolIncludeMode;\n\t\tconst includeTools = this.getNodeParameter('includeTools', itemIndex, []) as string[];\n\t\tconst excludeTools = this.getNodeParameter('excludeTools', itemIndex, []) as string[];\n\n\t\tconst allTools = await getAllTools(client.result);\n\t\tconst mcpTools = getSelectedTools({\n\t\t\ttools: allTools,\n\t\t\tmode,\n\t\t\tincludeTools,\n\t\t\texcludeTools,\n\t\t});\n\n\t\tif (!mcpTools.length) {\n\t\t\treturn setError(\n\t\t\t\t'MCP Server returned no tools',\n\t\t\t\t'Connected successfully to your MCP server but it returned an empty list of tools.',\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.result, 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.result.close() };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA2B;AAC3B,0BAA6C;AAC7C,0BAOO;AAEP,yBAAyB;AAEzB,mBAQO;AAEA,MAAM,cAAmC;AAAA,EAAzC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,MACP;AAAA,MACA,OAAO,CAAC,QAAQ;AAAA,MAChB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,0BAA0B,OAAO;AAAA,QACvC;AAAA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c,wCAAoB,QAAQ,WAAW,KAAK;AACpE,iBAAK,OAAO,MAAM,wBAAwB,KAAK,IAAI,uBAAuB,EAAE,MAAM,CAAC;AAAA,UACpF,CAAC;AAAA,QACF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,SAAK,OAAO,MAAM,+CAA+C,MAAM,MAAM,QAAQ;AAErF,UAAM,UAAU,IAAI,wBAAW,KAAK;AAEpC,WAAO,EAAE,UAAU,SAAS,eAAe,YAAY,MAAM,OAAO,OAAO,MAAM,EAAE;AAAA,EACpF;AACD;","names":[]}
|
|
@@ -81,7 +81,7 @@ const getErrorDescriptionFromToolCall = (result) => {
|
|
|
81
81
|
}
|
|
82
82
|
return void 0;
|
|
83
83
|
};
|
|
84
|
-
const createCallTool = (name, client, onError) => async (args) => {
|
|
84
|
+
const createCallTool = (name, client, timeout, onError) => async (args) => {
|
|
85
85
|
let result;
|
|
86
86
|
function handleError(error) {
|
|
87
87
|
const errorDescription = getErrorDescriptionFromToolCall(error) ?? `Failed to execute tool "${name}"`;
|
|
@@ -89,7 +89,9 @@ const createCallTool = (name, client, onError) => async (args) => {
|
|
|
89
89
|
return errorDescription;
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
|
-
result = await client.callTool({ name, arguments: args }, import_types.CompatibilityCallToolResultSchema
|
|
92
|
+
result = await client.callTool({ name, arguments: args }, import_types.CompatibilityCallToolResultSchema, {
|
|
93
|
+
timeout
|
|
94
|
+
});
|
|
93
95
|
} catch (error) {
|
|
94
96
|
return handleError(error);
|
|
95
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/mcp/McpClientTool/utils.ts"],"sourcesContent":["import { DynamicStructuredTool, type DynamicStructuredToolInput } from '@langchain/core/tools';\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';\nimport { CompatibilityCallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { convertJsonSchemaToZod } from '@utils/schemaParsing';\nimport { Toolkit } from 'langchain/agents';\nimport {\n\tcreateResultError,\n\tcreateResultOk,\n\ttype IDataObject,\n\ttype IExecuteFunctions,\n\ttype Result,\n} from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport type {\n\tMcpAuthenticationOption,\n\tMcpServerTransport,\n\tMcpTool,\n\tMcpToolIncludeMode,\n} from './types';\n\nexport async function getAllTools(client: Client, cursor?: string): Promise<McpTool[]> {\n\tconst { tools, nextCursor } = await client.listTools({ cursor });\n\n\tif (nextCursor) {\n\t\treturn (tools as McpTool[]).concat(await getAllTools(client, nextCursor));\n\t}\n\n\treturn tools as McpTool[];\n}\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, onError: (error: string) => void) => async (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} 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\nfunction safeCreateUrl(url: string, baseUrl?: string | URL): Result<URL, Error> {\n\ttry {\n\t\treturn createResultOk(new URL(url, baseUrl));\n\t} catch (error) {\n\t\treturn createResultError(error);\n\t}\n}\n\nfunction normalizeAndValidateUrl(input: string): Result<URL, Error> {\n\tconst withProtocol = !/^https?:\\/\\//i.test(input) ? `https://${input}` : input;\n\tconst parsedUrl = safeCreateUrl(withProtocol);\n\n\tif (!parsedUrl.ok) {\n\t\treturn createResultError(parsedUrl.error);\n\t}\n\n\treturn parsedUrl;\n}\n\ntype ConnectMcpClientError =\n\t| { type: 'invalid_url'; error: Error }\n\t| { type: 'connection'; error: Error };\nexport async function connectMcpClient({\n\theaders,\n\tserverTransport,\n\tendpointUrl,\n\tname,\n\tversion,\n}: {\n\tserverTransport: McpServerTransport;\n\tendpointUrl: string;\n\theaders?: Record<string, string>;\n\tname: string;\n\tversion: number;\n}): Promise<Result<Client, ConnectMcpClientError>> {\n\tconst endpoint = normalizeAndValidateUrl(endpointUrl);\n\n\tif (!endpoint.ok) {\n\t\treturn createResultError({ type: 'invalid_url', error: endpoint.error });\n\t}\n\n\tconst client = new Client({ name, version: version.toString() }, { capabilities: { tools: {} } });\n\n\tif (serverTransport === 'httpStreamable') {\n\t\ttry {\n\t\t\tconst transport = new StreamableHTTPClientTransport(endpoint.result, {\n\t\t\t\trequestInit: { headers },\n\t\t\t});\n\t\t\tawait client.connect(transport);\n\t\t\treturn createResultOk(client);\n\t\t} catch (error) {\n\t\t\treturn createResultError({ type: 'connection', error });\n\t\t}\n\t}\n\n\ttry {\n\t\tconst sseTransport = new SSEClientTransport(endpoint.result, {\n\t\t\teventSourceInit: {\n\t\t\t\tfetch: async (url, init) =>\n\t\t\t\t\tawait fetch(url, {\n\t\t\t\t\t\t...init,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t...headers,\n\t\t\t\t\t\t\tAccept: 'text/event-stream',\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t},\n\t\t\trequestInit: { headers },\n\t\t});\n\t\tawait client.connect(sseTransport);\n\t\treturn createResultOk(client);\n\t} catch (error) {\n\t\treturn createResultError({ type: 'connection', error });\n\t}\n}\n\nexport async function getAuthHeaders(\n\tctx: Pick<IExecuteFunctions, 'getCredentials'>,\n\tauthentication: McpAuthenticationOption,\n): Promise<{ headers?: Record<string, string> }> {\n\tswitch (authentication) {\n\t\tcase 'headerAuth': {\n\t\t\tconst header = await ctx\n\t\t\t\t.getCredentials<{ name: string; value: string }>('httpHeaderAuth')\n\t\t\t\t.catch(() => null);\n\n\t\t\tif (!header) return {};\n\n\t\t\treturn { headers: { [header.name]: header.value } };\n\t\t}\n\t\tcase 'bearerAuth': {\n\t\t\tconst result = await ctx\n\t\t\t\t.getCredentials<{ token: string }>('httpBearerAuth')\n\t\t\t\t.catch(() => null);\n\n\t\t\tif (!result) return {};\n\n\t\t\treturn { headers: { Authorization: `Bearer ${result.token}` } };\n\t\t}\n\t\tcase 'none':\n\t\tdefault: {\n\t\t\treturn {};\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuE;AACvE,oBAAuB;AACvB,iBAAmC;AACnC,4BAA8C;AAC9C,mBAAkD;AAClD,2BAAuC;AACvC,oBAAwB;AACxB,0BAMO;AACP,iBAAkB;AASlB,eAAsB,YAAY,QAAgB,QAAqC;AACtF,QAAM,EAAE,OAAO,WAAW,IAAI,MAAM,OAAO,UAAU,EAAE,OAAO,CAAC;AAE/D,MAAI,YAAY;AACf,WAAQ,MAAoB,OAAO,MAAM,YAAY,QAAQ,UAAU,CAAC;AAAA,EACzE;AAEA,SAAO;AACR;AAEO,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,MAA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ACf,iBAAO,uCAAkB,EAAE,MAAM,cAAc,MAAM,CAAC;AAAA,IACvD;AAAA,EACD;AAEA,MAAI;AACH,UAAM,eAAe,IAAI,8BAAmB,SAAS,QAAQ;AAAA,MAC5D,iBAAiB;AAAA,QAChB,OAAO,OAAO,KAAK,SAClB,MAAM,MAAM,KAAK;AAAA,UAChB,GAAG;AAAA,UACH,SAAS;AAAA,YACR,GAAG;AAAA,YACH,QAAQ;AAAA,UACT;AAAA,QACD,CAAC;AAAA,MACH;AAAA,MACA,aAAa,EAAE,QAAQ;AAAA,IACxB,CAAC;AACD,UAAM,OAAO,QAAQ,YAAY;AACjC,eAAO,oCAAe,MAAM;AAAA,EAC7B,SAAS,OAAO;AACf,eAAO,uCAAkB,EAAE,MAAM,cAAc,MAAM,CAAC;AAAA,EACvD;AACD;AAEA,eAAsB,eACrB,KACA,gBACgD;AAChD,UAAQ,gBAAgB;AAAA,IACvB,KAAK,cAAc;AAClB,YAAM,SAAS,MAAM,IACnB,eAAgD,gBAAgB,EAChE,MAAM,MAAM,IAAI;AAElB,UAAI,CAAC,OAAQ,QAAO,CAAC;AAErB,aAAO,EAAE,SAAS,EAAE,CAAC,OAAO,IAAI,GAAG,OAAO,MAAM,EAAE;AAAA,IACnD;AAAA,IACA,KAAK,cAAc;AAClB,YAAM,SAAS,MAAM,IACnB,eAAkC,gBAAgB,EAClD,MAAM,MAAM,IAAI;AAElB,UAAI,CAAC,OAAQ,QAAO,CAAC;AAErB,aAAO,EAAE,SAAS,EAAE,eAAe,UAAU,OAAO,KAAK,GAAG,EAAE;AAAA,IAC/D;AAAA,IACA,KAAK;AAAA,IACL,SAAS;AACR,aAAO,CAAC;AAAA,IACT;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/mcp/McpClientTool/utils.ts"],"sourcesContent":["import { DynamicStructuredTool, type DynamicStructuredToolInput } from '@langchain/core/tools';\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';\nimport { CompatibilityCallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { convertJsonSchemaToZod } from '@utils/schemaParsing';\nimport { Toolkit } from 'langchain/agents';\nimport {\n\tcreateResultError,\n\tcreateResultOk,\n\ttype IDataObject,\n\ttype IExecuteFunctions,\n\ttype Result,\n} from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport type {\n\tMcpAuthenticationOption,\n\tMcpServerTransport,\n\tMcpTool,\n\tMcpToolIncludeMode,\n} from './types';\n\nexport async function getAllTools(client: Client, cursor?: string): Promise<McpTool[]> {\n\tconst { tools, nextCursor } = await client.listTools({ cursor });\n\n\tif (nextCursor) {\n\t\treturn (tools as McpTool[]).concat(await getAllTools(client, nextCursor));\n\t}\n\n\treturn tools as McpTool[];\n}\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\nfunction safeCreateUrl(url: string, baseUrl?: string | URL): Result<URL, Error> {\n\ttry {\n\t\treturn createResultOk(new URL(url, baseUrl));\n\t} catch (error) {\n\t\treturn createResultError(error);\n\t}\n}\n\nfunction normalizeAndValidateUrl(input: string): Result<URL, Error> {\n\tconst withProtocol = !/^https?:\\/\\//i.test(input) ? `https://${input}` : input;\n\tconst parsedUrl = safeCreateUrl(withProtocol);\n\n\tif (!parsedUrl.ok) {\n\t\treturn createResultError(parsedUrl.error);\n\t}\n\n\treturn parsedUrl;\n}\n\ntype ConnectMcpClientError =\n\t| { type: 'invalid_url'; error: Error }\n\t| { type: 'connection'; error: Error };\nexport async function connectMcpClient({\n\theaders,\n\tserverTransport,\n\tendpointUrl,\n\tname,\n\tversion,\n}: {\n\tserverTransport: McpServerTransport;\n\tendpointUrl: string;\n\theaders?: Record<string, string>;\n\tname: string;\n\tversion: number;\n}): Promise<Result<Client, ConnectMcpClientError>> {\n\tconst endpoint = normalizeAndValidateUrl(endpointUrl);\n\n\tif (!endpoint.ok) {\n\t\treturn createResultError({ type: 'invalid_url', error: endpoint.error });\n\t}\n\n\tconst client = new Client({ name, version: version.toString() }, { capabilities: { tools: {} } });\n\n\tif (serverTransport === 'httpStreamable') {\n\t\ttry {\n\t\t\tconst transport = new StreamableHTTPClientTransport(endpoint.result, {\n\t\t\t\trequestInit: { headers },\n\t\t\t});\n\t\t\tawait client.connect(transport);\n\t\t\treturn createResultOk(client);\n\t\t} catch (error) {\n\t\t\treturn createResultError({ type: 'connection', error });\n\t\t}\n\t}\n\n\ttry {\n\t\tconst sseTransport = new SSEClientTransport(endpoint.result, {\n\t\t\teventSourceInit: {\n\t\t\t\tfetch: async (url, init) =>\n\t\t\t\t\tawait fetch(url, {\n\t\t\t\t\t\t...init,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t...headers,\n\t\t\t\t\t\t\tAccept: 'text/event-stream',\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t},\n\t\t\trequestInit: { headers },\n\t\t});\n\t\tawait client.connect(sseTransport);\n\t\treturn createResultOk(client);\n\t} catch (error) {\n\t\treturn createResultError({ type: 'connection', error });\n\t}\n}\n\nexport async function getAuthHeaders(\n\tctx: Pick<IExecuteFunctions, 'getCredentials'>,\n\tauthentication: McpAuthenticationOption,\n): Promise<{ headers?: Record<string, string> }> {\n\tswitch (authentication) {\n\t\tcase 'headerAuth': {\n\t\t\tconst header = await ctx\n\t\t\t\t.getCredentials<{ name: string; value: string }>('httpHeaderAuth')\n\t\t\t\t.catch(() => null);\n\n\t\t\tif (!header) return {};\n\n\t\t\treturn { headers: { [header.name]: header.value } };\n\t\t}\n\t\tcase 'bearerAuth': {\n\t\t\tconst result = await ctx\n\t\t\t\t.getCredentials<{ token: string }>('httpBearerAuth')\n\t\t\t\t.catch(() => null);\n\n\t\t\tif (!result) return {};\n\n\t\t\treturn { headers: { Authorization: `Bearer ${result.token}` } };\n\t\t}\n\t\tcase 'none':\n\t\tdefault: {\n\t\t\treturn {};\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuE;AACvE,oBAAuB;AACvB,iBAAmC;AACnC,4BAA8C;AAC9C,mBAAkD;AAClD,2BAAuC;AACvC,oBAAwB;AACxB,0BAMO;AACP,iBAAkB;AASlB,eAAsB,YAAY,QAAgB,QAAqC;AACtF,QAAM,EAAE,OAAO,WAAW,IAAI,MAAM,OAAO,UAAU,EAAE,OAAO,CAAC;AAE/D,MAAI,YAAY;AACf,WAAQ,MAAoB,OAAO,MAAM,YAAY,QAAQ,UAAU,CAAC;AAAA,EACzE;AAEA,SAAO;AACR;AAEO,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,SA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","names":[]}
|
|
@@ -42,6 +42,7 @@ class MemoryZep {
|
|
|
42
42
|
this.description = {
|
|
43
43
|
displayName: "Zep",
|
|
44
44
|
name: "memoryZep",
|
|
45
|
+
hidden: true,
|
|
45
46
|
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
|
|
46
47
|
icon: "file:zep.png",
|
|
47
48
|
group: ["transform"],
|
|
@@ -74,6 +75,12 @@ class MemoryZep {
|
|
|
74
75
|
}
|
|
75
76
|
],
|
|
76
77
|
properties: [
|
|
78
|
+
{
|
|
79
|
+
displayName: "This Zep integration is deprecated and will be removed in a future version.",
|
|
80
|
+
name: "deprecationNotice",
|
|
81
|
+
type: "notice",
|
|
82
|
+
default: ""
|
|
83
|
+
},
|
|
77
84
|
(0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiAgent]),
|
|
78
85
|
{
|
|
79
86
|
displayName: "Only works with Zep Cloud and Community edition <= v0.27.2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/memory/MemoryZep/MemoryZep.node.ts"],"sourcesContent":["import type { BaseChatMemory } from '@langchain/community/dist/memory/chat_memory';\nimport { ZepMemory } from '@langchain/community/memory/zep';\nimport { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';\nimport type { InputValues, MemoryVariables } from '@langchain/core/memory';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport {\n\tNodeConnectionTypes,\n\ttype ISupplyDataFunctions,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';\n\n// Extend ZepCloudMemory to trim white space in messages.\nclass WhiteSpaceTrimmedZepCloudMemory extends ZepCloudMemory {\n\toverride async loadMemoryVariables(values: InputValues): Promise<MemoryVariables> {\n\t\tconst memoryVariables = await super.loadMemoryVariables(values);\n\t\tmemoryVariables.chat_history = memoryVariables.chat_history.filter((m: BaseMessage) =>\n\t\t\tm.content.toString().trim(),\n\t\t);\n\t\treturn memoryVariables;\n\t}\n}\n\nexport class MemoryZep implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Zep',\n\t\tname: 'memoryZep',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg\n\t\ticon: 'file:zep.png',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdescription: 'Use Zep Memory',\n\t\tdefaults: {\n\t\t\tname: 'Zep',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t\tMemory: ['Other memories'],\n\t\t\t},\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.memoryzep/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'zepApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Only works with Zep Cloud and Community edition <= v0.27.2',\n\t\t\t\tname: 'supportedVersions',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\trequired: true,\n\t\t\t\tdefault: '',\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: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\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\t{\n\t\t\t\t...sessionIdOption,\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\texpressionSessionKeyProperty(1.3),\n\t\t\tsessionKeyProperty,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials<{\n\t\t\tapiKey?: string;\n\t\t\tapiUrl?: string;\n\t\t\tcloud?: boolean;\n\t\t}>('zepApi');\n\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionId', itemIndex) as string;\n\t\t}\n\n\t\tlet memory: BaseChatMemory;\n\n\t\tif (credentials.cloud) {\n\t\t\tif (!credentials.apiKey) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API key is required to use Zep Cloud');\n\t\t\t}\n\t\t\tmemory = new WhiteSpaceTrimmedZepCloudMemory({\n\t\t\t\tsessionId,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryType: 'perpetual',\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t\tseparateMessages: false,\n\t\t\t});\n\t\t} else {\n\t\t\tif (!credentials.apiUrl) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API url is required to use Zep Open Source');\n\t\t\t}\n\t\t\tmemory = new ZepMemory({\n\t\t\t\tsessionId,\n\t\t\t\tbaseURL: credentials.apiUrl,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAA0B;AAC1B,uBAA+B;AAG/B,0BAOO;AAEP,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAAkF;AAGlF,MAAM,wCAAwC,gCAAe;AAAA,EAC5D,MAAe,oBAAoB,QAA+C;AACjF,UAAM,kBAAkB,MAAM,MAAM,oBAAoB,MAAM;AAC9D,oBAAgB,eAAe,gBAAgB,aAAa;AAAA,MAAO,CAAC,MACnE,EAAE,QAAQ,SAAS,EAAE,KAAK;AAAA,IAC3B;AACA,WAAO;AAAA,EACR;AACD;AAEO,MAAM,UAA+B;AAAA,EAArC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/memory/MemoryZep/MemoryZep.node.ts"],"sourcesContent":["import type { BaseChatMemory } from '@langchain/community/dist/memory/chat_memory';\nimport { ZepMemory } from '@langchain/community/memory/zep';\nimport { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';\nimport type { InputValues, MemoryVariables } from '@langchain/core/memory';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport {\n\tNodeConnectionTypes,\n\ttype ISupplyDataFunctions,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';\n\n// Extend ZepCloudMemory to trim white space in messages.\nclass WhiteSpaceTrimmedZepCloudMemory extends ZepCloudMemory {\n\toverride async loadMemoryVariables(values: InputValues): Promise<MemoryVariables> {\n\t\tconst memoryVariables = await super.loadMemoryVariables(values);\n\t\tmemoryVariables.chat_history = memoryVariables.chat_history.filter((m: BaseMessage) =>\n\t\t\tm.content.toString().trim(),\n\t\t);\n\t\treturn memoryVariables;\n\t}\n}\n\nexport class MemoryZep implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Zep',\n\t\tname: 'memoryZep',\n\t\thidden: true,\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg\n\t\ticon: 'file:zep.png',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdescription: 'Use Zep Memory',\n\t\tdefaults: {\n\t\t\tname: 'Zep',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t\tMemory: ['Other memories'],\n\t\t\t},\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.memoryzep/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'zepApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'This Zep integration is deprecated and will be removed in a future version.',\n\t\t\t\tname: 'deprecationNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Only works with Zep Cloud and Community edition <= v0.27.2',\n\t\t\t\tname: 'supportedVersions',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\trequired: true,\n\t\t\t\tdefault: '',\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: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\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\t{\n\t\t\t\t...sessionIdOption,\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\texpressionSessionKeyProperty(1.3),\n\t\t\tsessionKeyProperty,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials<{\n\t\t\tapiKey?: string;\n\t\t\tapiUrl?: string;\n\t\t\tcloud?: boolean;\n\t\t}>('zepApi');\n\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionId', itemIndex) as string;\n\t\t}\n\n\t\tlet memory: BaseChatMemory;\n\n\t\tif (credentials.cloud) {\n\t\t\tif (!credentials.apiKey) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API key is required to use Zep Cloud');\n\t\t\t}\n\t\t\tmemory = new WhiteSpaceTrimmedZepCloudMemory({\n\t\t\t\tsessionId,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryType: 'perpetual',\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t\tseparateMessages: false,\n\t\t\t});\n\t\t} else {\n\t\t\tif (!credentials.apiUrl) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API url is required to use Zep Open Source');\n\t\t\t}\n\t\t\tmemory = new ZepMemory({\n\t\t\t\tsessionId,\n\t\t\t\tbaseURL: credentials.apiUrl,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAA0B;AAC1B,uBAA+B;AAG/B,0BAOO;AAEP,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAAkF;AAGlF,MAAM,wCAAwC,gCAAe;AAAA,EAC5D,MAAe,oBAAoB,QAA+C;AACjF,UAAM,kBAAkB,MAA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QAAQ,YAAY;AAAA,QACpB,WAAW;AAAA,QACX,gBAAgB;AAAA,QAChB,UAAU;AAAA,QACV,WAAW;AAAA,MACZ,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,MACN,cAAU,8BAAW,QAAQ,IAAI;AAAA,IAClC;AAAA,EACD;AACD;","names":[]}
|
|
@@ -18,8 +18,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var VectorStoreMongoDBAtlas_node_exports = {};
|
|
20
20
|
__export(VectorStoreMongoDBAtlas_node_exports, {
|
|
21
|
+
EMBEDDING_NAME: () => EMBEDDING_NAME,
|
|
22
|
+
METADATA_FIELD_NAME: () => METADATA_FIELD_NAME,
|
|
23
|
+
MONGODB_COLLECTION_NAME: () => MONGODB_COLLECTION_NAME,
|
|
24
|
+
MONGODB_CREDENTIALS: () => MONGODB_CREDENTIALS,
|
|
25
|
+
VECTOR_INDEX_NAME: () => VECTOR_INDEX_NAME,
|
|
21
26
|
VectorStoreMongoDBAtlas: () => VectorStoreMongoDBAtlas,
|
|
27
|
+
getCollectionName: () => getCollectionName,
|
|
28
|
+
getCollections: () => getCollections,
|
|
29
|
+
getDatabase: () => getDatabase,
|
|
30
|
+
getEmbeddingFieldName: () => getEmbeddingFieldName,
|
|
31
|
+
getMetadataFieldName: () => getMetadataFieldName,
|
|
22
32
|
getMongoClient: () => getMongoClient,
|
|
33
|
+
getParameter: () => getParameter,
|
|
34
|
+
getVectorIndexName: () => getVectorIndexName,
|
|
23
35
|
mongoConfig: () => mongoConfig
|
|
24
36
|
});
|
|
25
37
|
module.exports = __toCommonJS(VectorStoreMongoDBAtlas_node_exports);
|
|
@@ -122,8 +134,13 @@ const mongoConfig = {
|
|
|
122
134
|
client: null,
|
|
123
135
|
connectionString: ""
|
|
124
136
|
};
|
|
137
|
+
const MONGODB_CREDENTIALS = "mongoDb";
|
|
138
|
+
const MONGODB_COLLECTION_NAME = "mongoCollection";
|
|
139
|
+
const VECTOR_INDEX_NAME = "vectorIndexName";
|
|
140
|
+
const EMBEDDING_NAME = "embedding";
|
|
141
|
+
const METADATA_FIELD_NAME = "metadata_field";
|
|
125
142
|
async function getMongoClient(context) {
|
|
126
|
-
const credentials = await context.getCredentials(
|
|
143
|
+
const credentials = await context.getCredentials(MONGODB_CREDENTIALS);
|
|
127
144
|
const connectionString = credentials.connectionString;
|
|
128
145
|
if (!mongoConfig.client || mongoConfig.connectionString !== connectionString) {
|
|
129
146
|
if (mongoConfig.client) {
|
|
@@ -137,15 +154,14 @@ async function getMongoClient(context) {
|
|
|
137
154
|
}
|
|
138
155
|
return mongoConfig.client;
|
|
139
156
|
}
|
|
140
|
-
async function
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
const db = client.db(credentials.database);
|
|
144
|
-
return { client, db };
|
|
157
|
+
async function getDatabase(context, client) {
|
|
158
|
+
const credentials = await context.getCredentials(MONGODB_CREDENTIALS);
|
|
159
|
+
return client.db(credentials.database);
|
|
145
160
|
}
|
|
146
|
-
async function
|
|
147
|
-
const { db } = await mongoClientAndDatabase(this);
|
|
161
|
+
async function getCollections() {
|
|
148
162
|
try {
|
|
163
|
+
const client = await getMongoClient(this);
|
|
164
|
+
const db = await getDatabase(this, client);
|
|
149
165
|
const collections = await db.listCollections().toArray();
|
|
150
166
|
const results = collections.map((collection) => ({
|
|
151
167
|
name: collection.name,
|
|
@@ -156,6 +172,19 @@ async function mongoCollectionSearch() {
|
|
|
156
172
|
throw new import_n8n_workflow.NodeOperationError(this.getNode(), `Error: ${error.message}`);
|
|
157
173
|
}
|
|
158
174
|
}
|
|
175
|
+
function getParameter(key, context, itemIndex) {
|
|
176
|
+
const value = context.getNodeParameter(key, itemIndex, "", {
|
|
177
|
+
extractValue: true
|
|
178
|
+
});
|
|
179
|
+
if (typeof value !== "string") {
|
|
180
|
+
throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Parameter ${key} must be a string`);
|
|
181
|
+
}
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
const getCollectionName = getParameter.bind(null, MONGODB_COLLECTION_NAME);
|
|
185
|
+
const getVectorIndexName = getParameter.bind(null, VECTOR_INDEX_NAME);
|
|
186
|
+
const getEmbeddingFieldName = getParameter.bind(null, EMBEDDING_NAME);
|
|
187
|
+
const getMetadataFieldName = getParameter.bind(null, METADATA_FIELD_NAME);
|
|
159
188
|
class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVectorStoreNode)({
|
|
160
189
|
meta: {
|
|
161
190
|
displayName: "MongoDB Atlas Vector Store",
|
|
@@ -171,57 +200,41 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
|
|
|
171
200
|
],
|
|
172
201
|
operationModes: ["load", "insert", "retrieve", "update", "retrieve-as-tool"]
|
|
173
202
|
},
|
|
174
|
-
methods: { listSearch: { mongoCollectionSearch } },
|
|
203
|
+
methods: { listSearch: { mongoCollectionSearch: getCollections } },
|
|
175
204
|
retrieveFields,
|
|
176
205
|
loadFields: retrieveFields,
|
|
177
206
|
insertFields,
|
|
178
207
|
sharedFields,
|
|
179
208
|
async getVectorStoreClient(context, _filter, embeddings, itemIndex) {
|
|
180
209
|
try {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
const metadataFieldName = context.getNodeParameter("metadata_field", itemIndex, "", {
|
|
193
|
-
extractValue: true
|
|
194
|
-
});
|
|
195
|
-
const collection = db.collection(collectionName);
|
|
196
|
-
const indexes = await collection.listSearchIndexes().toArray();
|
|
197
|
-
const indexExists = indexes.some((index) => index.name === mongoVectorIndexName);
|
|
198
|
-
if (!indexExists) {
|
|
199
|
-
throw new import_n8n_workflow.NodeOperationError(
|
|
200
|
-
context.getNode(),
|
|
201
|
-
`Index ${mongoVectorIndexName} not found`,
|
|
202
|
-
{
|
|
203
|
-
itemIndex,
|
|
204
|
-
description: "Please check that the index exists in your collection"
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
return new import_mongodb.MongoDBAtlasVectorSearch(embeddings, {
|
|
209
|
-
collection,
|
|
210
|
-
indexName: mongoVectorIndexName,
|
|
211
|
-
// Default index name
|
|
212
|
-
textKey: metadataFieldName,
|
|
213
|
-
// Field containing raw text
|
|
214
|
-
embeddingKey: embeddingFieldName
|
|
215
|
-
// Field containing embeddings
|
|
216
|
-
});
|
|
217
|
-
} catch (error) {
|
|
218
|
-
throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Error: ${error.message}`, {
|
|
210
|
+
const client = await getMongoClient(context);
|
|
211
|
+
const db = await getDatabase(context, client);
|
|
212
|
+
const collectionName = getCollectionName(context, itemIndex);
|
|
213
|
+
const mongoVectorIndexName = getVectorIndexName(context, itemIndex);
|
|
214
|
+
const embeddingFieldName = getEmbeddingFieldName(context, itemIndex);
|
|
215
|
+
const metadataFieldName = getMetadataFieldName(context, itemIndex);
|
|
216
|
+
const collection = db.collection(collectionName);
|
|
217
|
+
const indexes = await collection.listSearchIndexes().toArray();
|
|
218
|
+
const indexExists = indexes.some((index) => index.name === mongoVectorIndexName);
|
|
219
|
+
if (!indexExists) {
|
|
220
|
+
throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Index ${mongoVectorIndexName} not found`, {
|
|
219
221
|
itemIndex,
|
|
220
|
-
description: "Please check
|
|
222
|
+
description: "Please check that the index exists in your collection"
|
|
221
223
|
});
|
|
222
|
-
} finally {
|
|
223
224
|
}
|
|
225
|
+
return new import_mongodb.MongoDBAtlasVectorSearch(embeddings, {
|
|
226
|
+
collection,
|
|
227
|
+
indexName: mongoVectorIndexName,
|
|
228
|
+
// Default index name
|
|
229
|
+
textKey: metadataFieldName,
|
|
230
|
+
// Field containing raw text
|
|
231
|
+
embeddingKey: embeddingFieldName
|
|
232
|
+
// Field containing embeddings
|
|
233
|
+
});
|
|
224
234
|
} catch (error) {
|
|
235
|
+
if (error instanceof import_n8n_workflow.NodeOperationError) {
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
225
238
|
throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Error: ${error.message}`, {
|
|
226
239
|
itemIndex,
|
|
227
240
|
description: "Please check your MongoDB Atlas connection details"
|
|
@@ -230,41 +243,26 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
|
|
|
230
243
|
},
|
|
231
244
|
async populateVectorStore(context, embeddings, documents, itemIndex) {
|
|
232
245
|
try {
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
extractValue: true
|
|
243
|
-
});
|
|
244
|
-
const mongoDBAtlasVectorIndex = context.getNodeParameter("vectorIndexName", itemIndex, "", {
|
|
245
|
-
extractValue: true
|
|
246
|
-
});
|
|
247
|
-
const collections = await db.listCollections({ name: mongoCollectionName }).toArray();
|
|
248
|
-
if (collections.length === 0) {
|
|
249
|
-
await db.createCollection(mongoCollectionName);
|
|
250
|
-
}
|
|
251
|
-
const collection = db.collection(mongoCollectionName);
|
|
252
|
-
await import_mongodb.MongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {
|
|
253
|
-
collection,
|
|
254
|
-
indexName: mongoDBAtlasVectorIndex,
|
|
255
|
-
// Default index name
|
|
256
|
-
textKey: metadataFieldName,
|
|
257
|
-
// Field containing raw text
|
|
258
|
-
embeddingKey: embeddingFieldName
|
|
259
|
-
// Field containing embeddings
|
|
260
|
-
});
|
|
261
|
-
} catch (error) {
|
|
262
|
-
throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Error: ${error.message}`, {
|
|
263
|
-
itemIndex,
|
|
264
|
-
description: "Please check your MongoDB Atlas connection details"
|
|
265
|
-
});
|
|
266
|
-
} finally {
|
|
246
|
+
const client = await getMongoClient(context);
|
|
247
|
+
const db = await getDatabase(context, client);
|
|
248
|
+
const collectionName = getCollectionName(context, itemIndex);
|
|
249
|
+
const mongoVectorIndexName = getVectorIndexName(context, itemIndex);
|
|
250
|
+
const embeddingFieldName = getEmbeddingFieldName(context, itemIndex);
|
|
251
|
+
const metadataFieldName = getMetadataFieldName(context, itemIndex);
|
|
252
|
+
const collections = await db.listCollections({ name: collectionName }).toArray();
|
|
253
|
+
if (collections.length === 0) {
|
|
254
|
+
await db.createCollection(collectionName);
|
|
267
255
|
}
|
|
256
|
+
const collection = db.collection(collectionName);
|
|
257
|
+
await import_mongodb.MongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {
|
|
258
|
+
collection,
|
|
259
|
+
indexName: mongoVectorIndexName,
|
|
260
|
+
// Default index name
|
|
261
|
+
textKey: metadataFieldName,
|
|
262
|
+
// Field containing raw text
|
|
263
|
+
embeddingKey: embeddingFieldName
|
|
264
|
+
// Field containing embeddings
|
|
265
|
+
});
|
|
268
266
|
} catch (error) {
|
|
269
267
|
throw new import_n8n_workflow.NodeOperationError(context.getNode(), `Error: ${error.message}`, {
|
|
270
268
|
itemIndex,
|
|
@@ -276,8 +274,20 @@ class VectorStoreMongoDBAtlas extends (0, import_createVectorStoreNode.createVec
|
|
|
276
274
|
}
|
|
277
275
|
// Annotate the CommonJS export names for ESM import in node:
|
|
278
276
|
0 && (module.exports = {
|
|
277
|
+
EMBEDDING_NAME,
|
|
278
|
+
METADATA_FIELD_NAME,
|
|
279
|
+
MONGODB_COLLECTION_NAME,
|
|
280
|
+
MONGODB_CREDENTIALS,
|
|
281
|
+
VECTOR_INDEX_NAME,
|
|
279
282
|
VectorStoreMongoDBAtlas,
|
|
283
|
+
getCollectionName,
|
|
284
|
+
getCollections,
|
|
285
|
+
getDatabase,
|
|
286
|
+
getEmbeddingFieldName,
|
|
287
|
+
getMetadataFieldName,
|
|
280
288
|
getMongoClient,
|
|
289
|
+
getParameter,
|
|
290
|
+
getVectorIndexName,
|
|
281
291
|
mongoConfig
|
|
282
292
|
});
|
|
283
293
|
//# sourceMappingURL=VectorStoreMongoDBAtlas.node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts"],"sourcesContent":["import { MongoDBAtlasVectorSearch } from '@langchain/mongodb';\nimport { MongoClient } from 'mongodb';\nimport { type ILoadOptionsFunctions, NodeOperationError, type INodeProperties } from 'n8n-workflow';\n\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\n\nconst mongoCollectionRLC: INodeProperties = {\n\tdisplayName: 'MongoDB Collection',\n\tname: 'mongoCollection',\n\ttype: 'resourceLocator',\n\tdefault: { mode: 'list', value: '' },\n\trequired: true,\n\tmodes: [\n\t\t{\n\t\t\tdisplayName: 'From List',\n\t\t\tname: 'list',\n\t\t\ttype: 'list',\n\t\t\ttypeOptions: {\n\t\t\t\tsearchListMethod: 'mongoCollectionSearch', // Method to fetch collections\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Name',\n\t\t\tname: 'name',\n\t\t\ttype: 'string',\n\t\t\tplaceholder: 'e.g. my_collection',\n\t\t},\n\t],\n};\n\nconst vectorIndexName: INodeProperties = {\n\tdisplayName: 'Vector Index Name',\n\tname: 'vectorIndexName',\n\ttype: 'string',\n\tdefault: '',\n\tdescription: 'The name of the vector index',\n\trequired: true,\n};\n\nconst embeddingField: INodeProperties = {\n\tdisplayName: 'Embedding',\n\tname: 'embedding',\n\ttype: 'string',\n\tdefault: 'embedding',\n\tdescription: 'The field with the embedding array',\n\trequired: true,\n};\n\nconst metadataField: INodeProperties = {\n\tdisplayName: 'Metadata Field',\n\tname: 'metadata_field',\n\ttype: 'string',\n\tdefault: 'text',\n\tdescription: 'The text field of the raw data',\n\trequired: true,\n};\n\nconst sharedFields: INodeProperties[] = [\n\tmongoCollectionRLC,\n\tembeddingField,\n\tmetadataField,\n\tvectorIndexName,\n];\n\nconst mongoNamespaceField: INodeProperties = {\n\tdisplayName: 'Namespace',\n\tname: 'namespace',\n\ttype: 'string',\n\tdescription: 'Logical partition for documents. Uses metadata.namespace field for filtering.',\n\tdefault: '',\n};\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [mongoNamespaceField, metadataFilterField],\n\t},\n];\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Clear Namespace',\n\t\t\t\tname: 'clearNamespace',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to clear documents in the namespace before inserting new data',\n\t\t\t},\n\t\t\tmongoNamespaceField,\n\t\t],\n\t},\n];\n\nexport const mongoConfig = {\n\tclient: null as MongoClient | null,\n\tconnectionString: '',\n};\n\nexport async function getMongoClient(context: any) {\n\tconst credentials = await context.getCredentials('mongoDb');\n\tconst connectionString = credentials.connectionString as string;\n\tif (!mongoConfig.client || mongoConfig.connectionString !== connectionString) {\n\t\tif (mongoConfig.client) {\n\t\t\tawait mongoConfig.client.close();\n\t\t}\n\n\t\tmongoConfig.connectionString = connectionString;\n\t\tmongoConfig.client = new MongoClient(connectionString, {\n\t\t\tappName: 'devrel.integration.n8n_vector_integ',\n\t\t});\n\t\tawait mongoConfig.client.connect();\n\t}\n\treturn mongoConfig.client;\n}\n\nasync function mongoClientAndDatabase(context: any) {\n\tconst client = await getMongoClient(context);\n\tconst credentials = await context.getCredentials('mongoDb');\n\tconst db = client.db(credentials.database as string);\n\treturn { client, db };\n}\n\nasync function mongoCollectionSearch(this: ILoadOptionsFunctions) {\n\tconst { db } = await mongoClientAndDatabase(this);\n\ttry {\n\t\tconst collections = await db.listCollections().toArray();\n\t\tconst results = collections.map((collection) => ({\n\t\t\tname: collection.name,\n\t\t\tvalue: collection.name,\n\t\t}));\n\n\t\treturn { results };\n\t} catch (error) {\n\t\tthrow new NodeOperationError(this.getNode(), `Error: ${error.message}`);\n\t}\n}\nexport class VectorStoreMongoDBAtlas extends createVectorStoreNode({\n\tmeta: {\n\t\tdisplayName: 'MongoDB Atlas Vector Store',\n\t\tname: 'vectorStoreMongoDBAtlas',\n\t\tdescription: 'Work with your data in MongoDB Atlas Vector Store',\n\t\ticon: { light: 'file:mongodb.svg', dark: 'file:mongodb.dark.svg' },\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoremongodbatlas/',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'mongoDb',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toperationModes: ['load', 'insert', 'retrieve', 'update', 'retrieve-as-tool'],\n\t},\n\tmethods: { listSearch: { mongoCollectionSearch } },\n\tretrieveFields,\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\ttry {\n\t\t\tconst { db } = await mongoClientAndDatabase(context);\n\t\t\ttry {\n\t\t\t\tconst collectionName = context.getNodeParameter('mongoCollection', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\n\t\t\t\tconst mongoVectorIndexName = context.getNodeParameter('vectorIndexName', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\n\t\t\t\tconst embeddingFieldName = context.getNodeParameter('embedding', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\n\t\t\t\tconst metadataFieldName = context.getNodeParameter('metadata_field', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\n\t\t\t\tconst collection = db.collection(collectionName);\n\n\t\t\t\t// test index exists\n\t\t\t\tconst indexes = await collection.listSearchIndexes().toArray();\n\n\t\t\t\tconst indexExists = indexes.some((index) => index.name === mongoVectorIndexName);\n\n\t\t\t\tif (!indexExists) {\n\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t\t`Index ${mongoVectorIndexName} not found`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t\tdescription: 'Please check that the index exists in your collection',\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn new MongoDBAtlasVectorSearch(embeddings, {\n\t\t\t\t\tcollection,\n\t\t\t\t\tindexName: mongoVectorIndexName, // Default index name\n\t\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\t// Don't close the client here to maintain connection pooling\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t\t}\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\ttry {\n\t\t\tconst { db } = await mongoClientAndDatabase(context);\n\t\t\ttry {\n\t\t\t\tconst mongoCollectionName = context.getNodeParameter('mongoCollection', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\t\t\t\tconst embeddingFieldName = context.getNodeParameter('embedding', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\n\t\t\t\tconst metadataFieldName = context.getNodeParameter('metadata_field', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\n\t\t\t\tconst mongoDBAtlasVectorIndex = context.getNodeParameter('vectorIndexName', itemIndex, '', {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\n\t\t\t\t// Check if collection exists\n\t\t\t\tconst collections = await db.listCollections({ name: mongoCollectionName }).toArray();\n\t\t\t\tif (collections.length === 0) {\n\t\t\t\t\tawait db.createCollection(mongoCollectionName);\n\t\t\t\t}\n\t\t\t\tconst collection = db.collection(mongoCollectionName);\n\t\t\t\tawait MongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {\n\t\t\t\t\tcollection,\n\t\t\t\t\tindexName: mongoDBAtlasVectorIndex, // Default index name\n\t\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\t// Don't close the client here to maintain connection pooling\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t\t}\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyC;AACzC,IAAAA,kBAA4B;AAC5B,0BAAqF;AAErF,0BAAoC;AAEpC,mCAAsC;AAEtC,MAAM,qBAAsC;AAAA,EAC3C,aAAa;AAAA,EACb,MAAM;AAAA,EACN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AG,UAAU,MAAM,OAAO,IAAI;AAAA,UAC1E;AAAA,UACA,aAAa;AAAA,QACd,CAAC;AAAA,MACF,UAAE;AAAA,MAEF;AAAA,IACD,SAAS,OAAO;AACf,YAAM,IAAI,uCAAmB,QAAQ,QAAQ,GAAG,UAAU,MAAM,OAAO,IAAI;AAAA,QAC1E;AAAA,QACA,aAAa;AAAA,MACd,CAAC;AAAA,IACF;AAAA,EACD;AACD,CAAC,EAAE;AAAC;","names":["import_mongodb"]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts"],"sourcesContent":["import { MongoDBAtlasVectorSearch } from '@langchain/mongodb';\nimport { MongoClient } from 'mongodb';\nimport {\n\ttype ILoadOptionsFunctions,\n\tNodeOperationError,\n\ttype INodeProperties,\n\ttype IExecuteFunctions,\n\ttype ISupplyDataFunctions,\n} from 'n8n-workflow';\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\n\nconst mongoCollectionRLC: INodeProperties = {\n\tdisplayName: 'MongoDB Collection',\n\tname: 'mongoCollection',\n\ttype: 'resourceLocator',\n\tdefault: { mode: 'list', value: '' },\n\trequired: true,\n\tmodes: [\n\t\t{\n\t\t\tdisplayName: 'From List',\n\t\t\tname: 'list',\n\t\t\ttype: 'list',\n\t\t\ttypeOptions: {\n\t\t\t\tsearchListMethod: 'mongoCollectionSearch', // Method to fetch collections\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Name',\n\t\t\tname: 'name',\n\t\t\ttype: 'string',\n\t\t\tplaceholder: 'e.g. my_collection',\n\t\t},\n\t],\n};\n\nconst vectorIndexName: INodeProperties = {\n\tdisplayName: 'Vector Index Name',\n\tname: 'vectorIndexName',\n\ttype: 'string',\n\tdefault: '',\n\tdescription: 'The name of the vector index',\n\trequired: true,\n};\n\nconst embeddingField: INodeProperties = {\n\tdisplayName: 'Embedding',\n\tname: 'embedding',\n\ttype: 'string',\n\tdefault: 'embedding',\n\tdescription: 'The field with the embedding array',\n\trequired: true,\n};\n\nconst metadataField: INodeProperties = {\n\tdisplayName: 'Metadata Field',\n\tname: 'metadata_field',\n\ttype: 'string',\n\tdefault: 'text',\n\tdescription: 'The text field of the raw data',\n\trequired: true,\n};\n\nconst sharedFields: INodeProperties[] = [\n\tmongoCollectionRLC,\n\tembeddingField,\n\tmetadataField,\n\tvectorIndexName,\n];\n\nconst mongoNamespaceField: INodeProperties = {\n\tdisplayName: 'Namespace',\n\tname: 'namespace',\n\ttype: 'string',\n\tdescription: 'Logical partition for documents. Uses metadata.namespace field for filtering.',\n\tdefault: '',\n};\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [mongoNamespaceField, metadataFilterField],\n\t},\n];\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Clear Namespace',\n\t\t\t\tname: 'clearNamespace',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to clear documents in the namespace before inserting new data',\n\t\t\t},\n\t\t\tmongoNamespaceField,\n\t\t],\n\t},\n];\n\nexport const mongoConfig = {\n\tclient: null as MongoClient | null,\n\tconnectionString: '',\n};\n\n/**\n * Constants for the name of the credentials and Node parameters.\n */\nexport const MONGODB_CREDENTIALS = 'mongoDb';\nexport const MONGODB_COLLECTION_NAME = 'mongoCollection';\nexport const VECTOR_INDEX_NAME = 'vectorIndexName';\nexport const EMBEDDING_NAME = 'embedding';\nexport const METADATA_FIELD_NAME = 'metadata_field';\n\n/**\n * Type used for cleaner, more intentional typing.\n */\ntype IFunctionsContext = IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions;\n\n/**\n * Get the mongo client.\n * @param context - The context.\n * @returns the MongoClient for the node.\n */\nexport async function getMongoClient(context: any) {\n\tconst credentials = await context.getCredentials(MONGODB_CREDENTIALS);\n\tconst connectionString = credentials.connectionString as string;\n\tif (!mongoConfig.client || mongoConfig.connectionString !== connectionString) {\n\t\tif (mongoConfig.client) {\n\t\t\tawait mongoConfig.client.close();\n\t\t}\n\n\t\tmongoConfig.connectionString = connectionString;\n\t\tmongoConfig.client = new MongoClient(connectionString, {\n\t\t\tappName: 'devrel.integration.n8n_vector_integ',\n\t\t});\n\t\tawait mongoConfig.client.connect();\n\t}\n\treturn mongoConfig.client;\n}\n\n/**\n * Get the database object from the MongoClient by the configured name.\n * @param context - The context.\n * @returns the Db object.\n */\nexport async function getDatabase(context: IFunctionsContext, client: MongoClient) {\n\tconst credentials = await context.getCredentials(MONGODB_CREDENTIALS);\n\treturn client.db(credentials.database as string);\n}\n\n/**\n * Get all the collection in the database.\n * @param this The load options context.\n * @returns The list of collections.\n */\nexport async function getCollections(this: ILoadOptionsFunctions) {\n\ttry {\n\t\tconst client = await getMongoClient(this);\n\t\tconst db = await getDatabase(this, client);\n\t\tconst collections = await db.listCollections().toArray();\n\t\tconst results = collections.map((collection) => ({\n\t\t\tname: collection.name,\n\t\t\tvalue: collection.name,\n\t\t}));\n\n\t\treturn { results };\n\t} catch (error) {\n\t\tthrow new NodeOperationError(this.getNode(), `Error: ${error.message}`);\n\t}\n}\n\n/**\n * Get a parameter from the context.\n * @param key - The key of the parameter.\n * @param context - The context.\n * @param itemIndex - The index.\n * @returns The value.\n */\nexport function getParameter(key: string, context: IFunctionsContext, itemIndex: number): string {\n\tconst value = context.getNodeParameter(key, itemIndex, '', {\n\t\textractValue: true,\n\t}) as string;\n\tif (typeof value !== 'string') {\n\t\tthrow new NodeOperationError(context.getNode(), `Parameter ${key} must be a string`);\n\t}\n\treturn value;\n}\n\nexport const getCollectionName = getParameter.bind(null, MONGODB_COLLECTION_NAME);\nexport const getVectorIndexName = getParameter.bind(null, VECTOR_INDEX_NAME);\nexport const getEmbeddingFieldName = getParameter.bind(null, EMBEDDING_NAME);\nexport const getMetadataFieldName = getParameter.bind(null, METADATA_FIELD_NAME);\n\nexport class VectorStoreMongoDBAtlas extends createVectorStoreNode({\n\tmeta: {\n\t\tdisplayName: 'MongoDB Atlas Vector Store',\n\t\tname: 'vectorStoreMongoDBAtlas',\n\t\tdescription: 'Work with your data in MongoDB Atlas Vector Store',\n\t\ticon: { light: 'file:mongodb.svg', dark: 'file:mongodb.dark.svg' },\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoremongodbatlas/',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'mongoDb',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toperationModes: ['load', 'insert', 'retrieve', 'update', 'retrieve-as-tool'],\n\t},\n\tmethods: { listSearch: { mongoCollectionSearch: getCollections } },\n\tretrieveFields,\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\ttry {\n\t\t\tconst client = await getMongoClient(context);\n\t\t\tconst db = await getDatabase(context, client);\n\t\t\tconst collectionName = getCollectionName(context, itemIndex);\n\t\t\tconst mongoVectorIndexName = getVectorIndexName(context, itemIndex);\n\t\t\tconst embeddingFieldName = getEmbeddingFieldName(context, itemIndex);\n\t\t\tconst metadataFieldName = getMetadataFieldName(context, itemIndex);\n\n\t\t\tconst collection = db.collection(collectionName);\n\n\t\t\t// test index exists\n\t\t\tconst indexes = await collection.listSearchIndexes().toArray();\n\n\t\t\tconst indexExists = indexes.some((index) => index.name === mongoVectorIndexName);\n\n\t\t\tif (!indexExists) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), `Index ${mongoVectorIndexName} not found`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: 'Please check that the index exists in your collection',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn new MongoDBAtlasVectorSearch(embeddings, {\n\t\t\t\tcollection,\n\t\t\t\tindexName: mongoVectorIndexName, // Default index name\n\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof NodeOperationError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t\t}\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\ttry {\n\t\t\tconst client = await getMongoClient(context);\n\t\t\tconst db = await getDatabase(context, client);\n\t\t\tconst collectionName = getCollectionName(context, itemIndex);\n\t\t\tconst mongoVectorIndexName = getVectorIndexName(context, itemIndex);\n\t\t\tconst embeddingFieldName = getEmbeddingFieldName(context, itemIndex);\n\t\t\tconst metadataFieldName = getMetadataFieldName(context, itemIndex);\n\n\t\t\t// Check if collection exists\n\t\t\tconst collections = await db.listCollections({ name: collectionName }).toArray();\n\t\t\tif (collections.length === 0) {\n\t\t\t\tawait db.createCollection(collectionName);\n\t\t\t}\n\t\t\tconst collection = db.collection(collectionName);\n\t\t\tawait MongoDBAtlasVectorSearch.fromDocuments(documents, embeddings, {\n\t\t\t\tcollection,\n\t\t\t\tindexName: mongoVectorIndexName, // Default index name\n\t\t\t\ttextKey: metadataFieldName, // Field containing raw text\n\t\t\t\tembeddingKey: embeddingFieldName, // Field containing embeddings\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your MongoDB Atlas connection details',\n\t\t\t});\n\t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,EAAE,QAAQ;AAC/E,UAAI,YAAY,WAAW,GAAG;AAC7B,cAAM,GAAG,iBAAiB,cAAc;AAAA,MACzC;AACA,YAAM,aAAa,GAAG,WAAW,cAAc;AAC/C,YAAM,wCAAyB,cAAc,WAAW,YAAY;AAAA,QACnE;AAAA,QACA,WAAW;AAAA;AAAA,QACX,SAAS;AAAA;AAAA,QACT,cAAc;AAAA;AAAA,MACf,CAAC;AAAA,IACF,SAAS,OAAO;AACf,YAAM,IAAI,uCAAmB,QAAQ,QAAQ,GAAG,UAAU,MAAM,OAAO,IAAI;AAAA,QAC1E;AAAA,QACA,aAAa;AAAA,MACd,CAAC;AAAA,IACF;AAAA,EACD;AACD,CAAC,EAAE;AAAC;","names":["import_mongodb"]}
|
|
@@ -66,6 +66,7 @@ class VectorStoreZep extends (0, import_createVectorStoreNode.createVectorStoreN
|
|
|
66
66
|
meta: {
|
|
67
67
|
displayName: "Zep Vector Store",
|
|
68
68
|
name: "vectorStoreZep",
|
|
69
|
+
hidden: true,
|
|
69
70
|
description: "Work with your data in Zep Vector Store",
|
|
70
71
|
credentials: [
|
|
71
72
|
{
|
|
@@ -77,6 +78,12 @@ class VectorStoreZep extends (0, import_createVectorStoreNode.createVectorStoreN
|
|
|
77
78
|
docsUrl: "https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstorezep/"
|
|
78
79
|
},
|
|
79
80
|
sharedFields: [
|
|
81
|
+
{
|
|
82
|
+
displayName: "This Zep integration is deprecated and will be removed in a future version.",
|
|
83
|
+
name: "deprecationNotice",
|
|
84
|
+
type: "notice",
|
|
85
|
+
default: ""
|
|
86
|
+
},
|
|
80
87
|
{
|
|
81
88
|
displayName: "Collection Name",
|
|
82
89
|
name: "collectionName",
|