n8n-nodes-browser-smart-automation 0.1.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.
Files changed (71) hide show
  1. package/dist/McpClient/McpClient.node.js +333 -0
  2. package/dist/McpClient/McpClient.node.js.map +1 -0
  3. package/dist/McpClient/listSearch.js +58 -0
  4. package/dist/McpClient/listSearch.js.map +1 -0
  5. package/dist/McpClient/resourceMapping.js +61 -0
  6. package/dist/McpClient/resourceMapping.js.map +1 -0
  7. package/dist/McpClient/utils.js +248 -0
  8. package/dist/McpClient/utils.js.map +1 -0
  9. package/dist/McpClientTool/McpClientTool.node.js +417 -0
  10. package/dist/McpClientTool/McpClientTool.node.js.map +1 -0
  11. package/dist/McpClientTool/loadOptions.js +61 -0
  12. package/dist/McpClientTool/loadOptions.js.map +1 -0
  13. package/dist/McpClientTool/types.js +17 -0
  14. package/dist/McpClientTool/types.js.map +1 -0
  15. package/dist/McpClientTool/utils.js +120 -0
  16. package/dist/McpClientTool/utils.js.map +1 -0
  17. package/dist/McpTrigger/FlushingTransport.js +61 -0
  18. package/dist/McpTrigger/FlushingTransport.js.map +1 -0
  19. package/dist/McpTrigger/McpServer.js +246 -0
  20. package/dist/McpTrigger/McpServer.js.map +1 -0
  21. package/dist/McpTrigger/McpTrigger.node.js +196 -0
  22. package/dist/McpTrigger/McpTrigger.node.js.map +1 -0
  23. package/dist/shared/descriptions.js +89 -0
  24. package/dist/shared/descriptions.js.map +1 -0
  25. package/dist/shared/helpers.js +47 -0
  26. package/dist/shared/helpers.js.map +1 -0
  27. package/dist/shared/httpProxyAgent.js +31 -0
  28. package/dist/shared/httpProxyAgent.js.map +1 -0
  29. package/dist/shared/logWrapper.js +31 -0
  30. package/dist/shared/logWrapper.js.map +1 -0
  31. package/dist/shared/schemaParsing.js +32 -0
  32. package/dist/shared/schemaParsing.js.map +1 -0
  33. package/dist/shared/sharedFields.js +41 -0
  34. package/dist/shared/sharedFields.js.map +1 -0
  35. package/dist/shared/types.js +17 -0
  36. package/dist/shared/types.js.map +1 -0
  37. package/dist/shared/utils.js +231 -0
  38. package/dist/shared/utils.js.map +1 -0
  39. package/jest.config.js +24 -0
  40. package/nodes/McpClient/McpClient.node.ts +327 -0
  41. package/nodes/McpClient/__test__/McpClient.node.test.ts +221 -0
  42. package/nodes/McpClient/__test__/utils.test.ts +302 -0
  43. package/nodes/McpClient/listSearch.ts +48 -0
  44. package/nodes/McpClient/resourceMapping.ts +48 -0
  45. package/nodes/McpClient/utils.ts +281 -0
  46. package/nodes/McpClientTool/McpClientTool.node.ts +468 -0
  47. package/nodes/McpClientTool/__test__/McpClientTool.node.test.ts +730 -0
  48. package/nodes/McpClientTool/loadOptions.ts +45 -0
  49. package/nodes/McpClientTool/types.ts +1 -0
  50. package/nodes/McpClientTool/utils.ts +116 -0
  51. package/nodes/McpTrigger/FlushingTransport.ts +61 -0
  52. package/nodes/McpTrigger/McpServer.ts +317 -0
  53. package/nodes/McpTrigger/McpTrigger.node.ts +204 -0
  54. package/nodes/McpTrigger/__test__/FlushingTransport.test.ts +102 -0
  55. package/nodes/McpTrigger/__test__/McpServer.test.ts +532 -0
  56. package/nodes/McpTrigger/__test__/McpTrigger.node.test.ts +171 -0
  57. package/nodes/mcp.dark.svg +7 -0
  58. package/nodes/mcp.svg +7 -0
  59. package/nodes/shared/__test__/utils.test.ts +318 -0
  60. package/nodes/shared/descriptions.ts +65 -0
  61. package/nodes/shared/helpers.ts +31 -0
  62. package/nodes/shared/httpProxyAgent.ts +11 -0
  63. package/nodes/shared/logWrapper.ts +13 -0
  64. package/nodes/shared/schemaParsing.ts +9 -0
  65. package/nodes/shared/sharedFields.ts +20 -0
  66. package/nodes/shared/types.ts +12 -0
  67. package/nodes/shared/utils.ts +296 -0
  68. package/officail/package.json +255 -0
  69. package/package.json +46 -0
  70. package/tsconfig.json +32 -0
  71. package/tsup.config.ts +11 -0
@@ -0,0 +1,333 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var McpClient_node_exports = {};
30
+ __export(McpClient_node_exports, {
31
+ McpClient: () => McpClient
32
+ });
33
+ module.exports = __toCommonJS(McpClient_node_exports);
34
+ var import_n8n_workflow = require("n8n-workflow");
35
+ var import_zod = require("zod");
36
+ var import_core = require("zod/v4/core");
37
+ var listSearch = __toESM(require("./listSearch"));
38
+ var resourceMapping = __toESM(require("./resourceMapping"));
39
+ var import_descriptions = require("../shared/descriptions");
40
+ var import_utils = require("../shared/utils");
41
+ class McpClient {
42
+ description = {
43
+ displayName: "MCP Client",
44
+ description: "Standalone MCP Client",
45
+ name: "mcpClient",
46
+ icon: {
47
+ light: "file:../mcp.svg",
48
+ dark: "file:../mcp.dark.svg"
49
+ },
50
+ group: ["transform"],
51
+ version: 1,
52
+ defaults: {
53
+ name: "MCP Client"
54
+ },
55
+ credentials: import_descriptions.credentials,
56
+ inputs: [import_n8n_workflow.NodeConnectionTypes.Main],
57
+ outputs: [import_n8n_workflow.NodeConnectionTypes.Main],
58
+ properties: [
59
+ (0, import_descriptions.transportSelect)({
60
+ defaultOption: "httpStreamable"
61
+ }),
62
+ {
63
+ displayName: "MCP Endpoint URL",
64
+ name: "endpointUrl",
65
+ type: "string",
66
+ default: "",
67
+ placeholder: "e.g. https://my-mcp-server.ai/mcp",
68
+ required: true,
69
+ description: "The URL of the MCP server to connect to"
70
+ },
71
+ {
72
+ displayName: "Authentication",
73
+ name: "authentication",
74
+ type: "options",
75
+ options: [
76
+ {
77
+ name: "Bearer Auth",
78
+ value: "bearerAuth"
79
+ },
80
+ {
81
+ name: "Header Auth",
82
+ value: "headerAuth"
83
+ },
84
+ {
85
+ name: "MCP OAuth2",
86
+ value: "mcpOAuth2Api"
87
+ },
88
+ {
89
+ name: "Multiple Headers Auth",
90
+ value: "multipleHeadersAuth"
91
+ },
92
+ {
93
+ name: "None",
94
+ value: "none"
95
+ }
96
+ ],
97
+ default: "none",
98
+ description: "The way to authenticate with your endpoint"
99
+ },
100
+ {
101
+ displayName: "Credentials",
102
+ name: "credentials",
103
+ type: "credentials",
104
+ default: "",
105
+ displayOptions: {
106
+ show: {
107
+ authentication: ["headerAuth", "bearerAuth", "mcpOAuth2Api", "multipleHeadersAuth"]
108
+ }
109
+ }
110
+ },
111
+ {
112
+ displayName: "Tool",
113
+ name: "tool",
114
+ type: "resourceLocator",
115
+ default: { mode: "list", value: "" },
116
+ required: true,
117
+ description: "The tool to use",
118
+ modes: [
119
+ {
120
+ displayName: "From List",
121
+ name: "list",
122
+ type: "list",
123
+ typeOptions: {
124
+ searchListMethod: "getTools",
125
+ searchable: true,
126
+ skipCredentialsCheckInRLC: true
127
+ }
128
+ },
129
+ {
130
+ displayName: "ID",
131
+ name: "id",
132
+ type: "string"
133
+ }
134
+ ]
135
+ },
136
+ {
137
+ displayName: "Input Mode",
138
+ name: "inputMode",
139
+ type: "options",
140
+ default: "manual",
141
+ noDataExpression: true,
142
+ options: [
143
+ {
144
+ name: "Manual",
145
+ value: "manual",
146
+ description: "Manually specify the input data for each tool parameter"
147
+ },
148
+ {
149
+ name: "JSON",
150
+ value: "json",
151
+ description: "Specify the input data as a JSON object"
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ displayName: "Parameters",
157
+ name: "parameters",
158
+ type: "resourceMapper",
159
+ default: {
160
+ mappingMode: "defineBelow",
161
+ value: null
162
+ },
163
+ noDataExpression: true,
164
+ required: true,
165
+ typeOptions: {
166
+ loadOptionsDependsOn: ["tool.value"],
167
+ resourceMapper: {
168
+ resourceMapperMethod: "getToolParameters",
169
+ hideNoDataError: true,
170
+ addAllFields: false,
171
+ supportAutoMap: false,
172
+ mode: "add",
173
+ fieldWords: {
174
+ singular: "parameter",
175
+ plural: "parameters"
176
+ }
177
+ }
178
+ },
179
+ displayOptions: {
180
+ show: {
181
+ inputMode: ["manual"]
182
+ }
183
+ }
184
+ },
185
+ {
186
+ displayName: "JSON",
187
+ name: "jsonInput",
188
+ type: "json",
189
+ typeOptions: {
190
+ rows: 5
191
+ },
192
+ default: '{\n "my_field_1": "value",\n "my_field_2": 1\n}\n',
193
+ validateType: "object",
194
+ displayOptions: {
195
+ show: {
196
+ inputMode: ["json"]
197
+ }
198
+ }
199
+ },
200
+ {
201
+ displayName: "Options",
202
+ name: "options",
203
+ placeholder: "Add Option",
204
+ description: "Additional options to add",
205
+ type: "collection",
206
+ default: {},
207
+ options: [
208
+ {
209
+ displayName: "Convert to Binary",
210
+ name: "convertToBinary",
211
+ type: "boolean",
212
+ default: true,
213
+ description: "Whether to convert images and audio to binary data. If false, images and audio will be returned as base64 encoded strings."
214
+ },
215
+ {
216
+ displayName: "Timeout",
217
+ name: "timeout",
218
+ type: "number",
219
+ typeOptions: {
220
+ minValue: 1
221
+ },
222
+ default: 6e4,
223
+ description: "Time in ms to wait for tool calls to finish"
224
+ }
225
+ ]
226
+ }
227
+ ]
228
+ };
229
+ methods = {
230
+ listSearch,
231
+ resourceMapping
232
+ };
233
+ async execute() {
234
+ const authentication = this.getNodeParameter("authentication", 0);
235
+ const serverTransport = this.getNodeParameter("serverTransport", 0);
236
+ const endpointUrl = this.getNodeParameter("endpointUrl", 0);
237
+ const node = this.getNode();
238
+ const { headers } = await (0, import_utils.getAuthHeaders)(this, authentication);
239
+ const client = await (0, import_utils.connectMcpClient)({
240
+ serverTransport,
241
+ endpointUrl,
242
+ headers,
243
+ name: node.type,
244
+ version: node.typeVersion,
245
+ onUnauthorized: async (headers2) => await (0, import_utils.tryRefreshOAuth2Token)(this, authentication, headers2)
246
+ });
247
+ if (!client.ok) {
248
+ throw (0, import_utils.mapToNodeOperationError)(node, client.error);
249
+ }
250
+ const inputMode = this.getNodeParameter("inputMode", 0, "manual");
251
+ const items = this.getInputData();
252
+ const returnData = [];
253
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
254
+ try {
255
+ const tool = this.getNodeParameter("tool.value", itemIndex);
256
+ const options = this.getNodeParameter("options", itemIndex);
257
+ let parameters = {};
258
+ if (inputMode === "manual") {
259
+ parameters = this.getNodeParameter("parameters.value", itemIndex);
260
+ } else {
261
+ parameters = this.getNodeParameter("jsonInput", itemIndex);
262
+ }
263
+ const result = await client.result.callTool(
264
+ {
265
+ name: tool,
266
+ arguments: parameters
267
+ },
268
+ void 0,
269
+ {
270
+ timeout: options.timeout ? Number(options.timeout) : void 0
271
+ }
272
+ );
273
+ let binaryIndex = 0;
274
+ const binary = {};
275
+ const content = [];
276
+ const convertToBinary = options.convertToBinary ?? true;
277
+ for (const contentItem of result.content) {
278
+ if (contentItem.type === "text") {
279
+ content.push({
280
+ ...contentItem,
281
+ text: (0, import_n8n_workflow.jsonParse)(contentItem.text, { fallbackValue: contentItem.text })
282
+ });
283
+ continue;
284
+ }
285
+ if (convertToBinary && (contentItem.type === "image" || contentItem.type === "audio")) {
286
+ binary[`data_${binaryIndex}`] = await this.helpers.prepareBinaryData(
287
+ Buffer.from(contentItem.data, "base64"),
288
+ void 0,
289
+ contentItem.mimeType
290
+ );
291
+ binaryIndex++;
292
+ continue;
293
+ }
294
+ content.push(contentItem);
295
+ }
296
+ returnData.push({
297
+ json: {
298
+ content: content.length > 0 ? content : void 0
299
+ },
300
+ binary: Object.keys(binary).length > 0 ? binary : void 0,
301
+ pairedItem: {
302
+ item: itemIndex
303
+ }
304
+ });
305
+ } catch (e) {
306
+ const errorMessage = e instanceof import_zod.ZodError ? (0, import_core.prettifyError)(e) : e instanceof Error ? e.message : String(e);
307
+ if (this.continueOnFail()) {
308
+ returnData.push({
309
+ json: {
310
+ error: {
311
+ message: errorMessage,
312
+ issues: e instanceof import_zod.ZodError ? e.issues : void 0
313
+ }
314
+ },
315
+ pairedItem: {
316
+ item: itemIndex
317
+ }
318
+ });
319
+ continue;
320
+ }
321
+ throw new import_n8n_workflow.NodeOperationError(node, errorMessage, {
322
+ itemIndex
323
+ });
324
+ }
325
+ }
326
+ return [returnData];
327
+ }
328
+ }
329
+ // Annotate the CommonJS export names for ESM import in node:
330
+ 0 && (module.exports = {
331
+ McpClient
332
+ });
333
+ //# sourceMappingURL=McpClient.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../nodes/McpClient/McpClient.node.ts"],"sourcesContent":["import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport type {\n\tIBinaryKeyData,\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tNodeExecutionWithMetadata,\n} from 'n8n-workflow';\nimport { jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport { ZodError } from 'zod';\nimport { prettifyError } from 'zod/v4/core';\n\nimport * as listSearch from './listSearch';\nimport * as resourceMapping from './resourceMapping';\nimport { credentials, transportSelect } from '../shared/descriptions';\nimport type { McpAuthenticationOption, McpServerTransport } from '../shared/types';\nimport {\n\tgetAuthHeaders,\n\ttryRefreshOAuth2Token,\n\tconnectMcpClient,\n\tmapToNodeOperationError,\n} from '../shared/utils';\n\nexport class McpClient implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'MCP Client',\n\t\tdescription: 'Standalone MCP Client',\n\t\tname: 'mcpClient',\n\t\ticon: {\n\t\t\tlight: 'file:../mcp.svg',\n\t\t\tdark: 'file:../mcp.dark.svg',\n\t\t},\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdefaults: {\n\t\t\tname: 'MCP Client',\n\t\t},\n\t\tcredentials,\n\t\tinputs: [NodeConnectionTypes.Main],\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tproperties: [\n\t\t\ttransportSelect({\n\t\t\t\tdefaultOption: 'httpStreamable',\n\t\t\t}),\n\t\t\t{\n\t\t\t\tdisplayName: 'MCP Endpoint URL',\n\t\t\t\tname: 'endpointUrl',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. https://my-mcp-server.ai/mcp',\n\t\t\t\trequired: true,\n\t\t\t\tdescription: 'The URL of the MCP server to connect to',\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},\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: 'Tool',\n\t\t\t\tname: 'tool',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: { mode: 'list', value: '' },\n\t\t\t\trequired: true,\n\t\t\t\tdescription: 'The tool to use',\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'getTools',\n\t\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\t\tskipCredentialsCheckInRLC: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Input Mode',\n\t\t\t\tname: 'inputMode',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'manual',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Manual',\n\t\t\t\t\t\tvalue: 'manual',\n\t\t\t\t\t\tdescription: 'Manually specify the input data for each tool parameter',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'JSON',\n\t\t\t\t\t\tvalue: 'json',\n\t\t\t\t\t\tdescription: 'Specify the input data as a JSON object',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Parameters',\n\t\t\t\tname: 'parameters',\n\t\t\t\ttype: 'resourceMapper',\n\t\t\t\tdefault: {\n\t\t\t\t\tmappingMode: 'defineBelow',\n\t\t\t\t\tvalue: null,\n\t\t\t\t},\n\t\t\t\tnoDataExpression: true,\n\t\t\t\trequired: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsDependsOn: ['tool.value'],\n\t\t\t\t\tresourceMapper: {\n\t\t\t\t\t\tresourceMapperMethod: 'getToolParameters',\n\t\t\t\t\t\thideNoDataError: true,\n\t\t\t\t\t\taddAllFields: false,\n\t\t\t\t\t\tsupportAutoMap: false,\n\t\t\t\t\t\tmode: 'add',\n\t\t\t\t\t\tfieldWords: {\n\t\t\t\t\t\t\tsingular: 'parameter',\n\t\t\t\t\t\t\tplural: 'parameters',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tinputMode: ['manual'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'JSON',\n\t\t\t\tname: 'jsonInput',\n\t\t\t\ttype: 'json',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 5,\n\t\t\t\t},\n\t\t\t\tdefault: '{\\n \"my_field_1\": \"value\",\\n \"my_field_2\": 1\\n}\\n',\n\t\t\t\tvalidateType: 'object',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tinputMode: ['json'],\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: 'Convert to Binary',\n\t\t\t\t\t\tname: 'convertToBinary',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: true,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Whether to convert images and audio to binary data. If false, images and audio will be returned as base64 encoded strings.',\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\tlistSearch,\n\t\tresourceMapping,\n\t};\n\n\tasync execute(\n\t\tthis: IExecuteFunctions,\n\t): Promise<INodeExecutionData[][] | NodeExecutionWithMetadata[][] | null> {\n\t\tconst authentication = this.getNodeParameter('authentication', 0) as McpAuthenticationOption;\n\t\tconst serverTransport = this.getNodeParameter('serverTransport', 0) as McpServerTransport;\n\t\tconst endpointUrl = this.getNodeParameter('endpointUrl', 0) as string;\n\t\tconst node = this.getNode();\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\tonUnauthorized: async (headers) => await tryRefreshOAuth2Token(this, authentication, headers),\n\t\t});\n\t\tif (!client.ok) {\n\t\t\tthrow mapToNodeOperationError(node, client.error);\n\t\t}\n\n\t\tconst inputMode = this.getNodeParameter('inputMode', 0, 'manual') as 'manual' | 'json';\n\t\tconst items = this.getInputData();\n\t\tconst returnData: INodeExecutionData[] = [];\n\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\ttry {\n\t\t\t\tconst tool = this.getNodeParameter('tool.value', itemIndex) as string;\n\t\t\t\tconst options = this.getNodeParameter('options', itemIndex);\n\t\t\t\tlet parameters: IDataObject = {};\n\t\t\t\tif (inputMode === 'manual') {\n\t\t\t\t\tparameters = this.getNodeParameter('parameters.value', itemIndex) as IDataObject;\n\t\t\t\t} else {\n\t\t\t\t\tparameters = this.getNodeParameter('jsonInput', itemIndex) as IDataObject;\n\t\t\t\t}\n\n\t\t\t\tconst result = (await client.result.callTool(\n\t\t\t\t\t{\n\t\t\t\t\t\tname: tool,\n\t\t\t\t\t\targuments: parameters,\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t\t{\n\t\t\t\t\t\ttimeout: options.timeout ? Number(options.timeout) : undefined,\n\t\t\t\t\t},\n\t\t\t\t)) as CallToolResult;\n\n\t\t\t\tlet binaryIndex = 0;\n\t\t\t\tconst binary: IBinaryKeyData = {};\n\t\t\t\tconst content: IDataObject[] = [];\n\t\t\t\tconst convertToBinary = options.convertToBinary ?? true;\n\t\t\t\tfor (const contentItem of result.content) {\n\t\t\t\t\tif (contentItem.type === 'text') {\n\t\t\t\t\t\tcontent.push({\n\t\t\t\t\t\t\t...contentItem,\n\t\t\t\t\t\t\ttext: jsonParse(contentItem.text, { fallbackValue: contentItem.text }),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (convertToBinary && (contentItem.type === 'image' || contentItem.type === 'audio')) {\n\t\t\t\t\t\tbinary[`data_${binaryIndex}`] = await this.helpers.prepareBinaryData(\n\t\t\t\t\t\t\tBuffer.from(contentItem.data, 'base64'),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tcontentItem.mimeType,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbinaryIndex++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tcontent.push(contentItem as IDataObject);\n\t\t\t\t}\n\n\t\t\t\treturnData.push({\n\t\t\t\t\tjson: {\n\t\t\t\t\t\tcontent: content.length > 0 ? content : undefined,\n\t\t\t\t\t},\n\t\t\t\t\tbinary: Object.keys(binary).length > 0 ? binary : undefined,\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} catch (e) {\n\t\t\t\tconst errorMessage =\n\t\t\t\t\te instanceof ZodError ? prettifyError(e) : e instanceof Error ? e.message : String(e);\n\t\t\t\tif (this.continueOnFail()) {\n\t\t\t\t\treturnData.push({\n\t\t\t\t\t\tjson: {\n\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\tmessage: errorMessage,\n\t\t\t\t\t\t\t\tissues: e instanceof ZodError ? e.issues : undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpairedItem: {\n\t\t\t\t\t\t\titem: itemIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthrow new NodeOperationError(node, errorMessage, {\n\t\t\t\t\titemIndex,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn [returnData];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,0BAAmE;AACnE,iBAAyB;AACzB,kBAA8B;AAE9B,iBAA4B;AAC5B,sBAAiC;AACjC,0BAA6C;AAE7C,mBAKO;AAEA,MAAM,UAA+B;AAAA,EAC3C,cAAoC;AAAA,IACnC,aAAa;AAAA,I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;AAAA,UACP;AAAA,QACD,CAAC;AAAA,MACF,SAAS,GAAG;AACX,cAAM,eACL,aAAa,0BAAW,2BAAc,CAAC,IAAI,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AACrF,YAAI,KAAK,eAAe,GAAG;AAC1B,qBAAW,KAAK;AAAA,YACf,MAAM;AAAA,cACL,OAAO;AAAA,gBACN,SAAS;AAAA,gBACT,QAAQ,aAAa,sBAAW,EAAE,SAAS;AAAA,cAC5C;AAAA,YACD;AAAA,YACA,YAAY;AAAA,cACX,MAAM;AAAA,YACP;AAAA,UACD,CAAC;AACD;AAAA,QACD;AAEA,cAAM,IAAI,uCAAmB,MAAM,cAAc;AAAA,UAChD;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAEA,WAAO,CAAC,UAAU;AAAA,EACnB;AACD;","names":["headers"]}
@@ -0,0 +1,58 @@
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 listSearch_exports = {};
20
+ __export(listSearch_exports, {
21
+ getTools: () => getTools
22
+ });
23
+ module.exports = __toCommonJS(listSearch_exports);
24
+ var import_utils = require("../shared/utils");
25
+ async function getTools(filter, paginationToken) {
26
+ const authentication = this.getNodeParameter("authentication");
27
+ const serverTransport = this.getNodeParameter("serverTransport");
28
+ const endpointUrl = this.getNodeParameter("endpointUrl");
29
+ const node = this.getNode();
30
+ const { headers } = await (0, import_utils.getAuthHeaders)(this, authentication);
31
+ const client = await (0, import_utils.connectMcpClient)({
32
+ serverTransport,
33
+ endpointUrl,
34
+ headers,
35
+ name: node.type,
36
+ version: node.typeVersion,
37
+ onUnauthorized: async (headers2) => await (0, import_utils.tryRefreshOAuth2Token)(this, authentication, headers2)
38
+ });
39
+ if (!client.ok) {
40
+ throw (0, import_utils.mapToNodeOperationError)(node, client.error);
41
+ }
42
+ const result = await client.result.listTools({ cursor: paginationToken });
43
+ const tools = filter ? result.tools.filter((tool) => tool.name.toLowerCase().includes(filter.toLowerCase())) : result.tools;
44
+ return {
45
+ results: tools.map((tool) => ({
46
+ name: tool.name,
47
+ value: tool.name,
48
+ description: tool.description,
49
+ inputSchema: tool.inputSchema
50
+ })),
51
+ paginationToken: result.nextCursor
52
+ };
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ getTools
57
+ });
58
+ //# sourceMappingURL=listSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../nodes/McpClient/listSearch.ts"],"sourcesContent":["import type { ILoadOptionsFunctions, INodeListSearchResult } from 'n8n-workflow';\n\nimport type { McpAuthenticationOption, McpServerTransport } from '../shared/types';\nimport {\n\tconnectMcpClient,\n\tgetAuthHeaders,\n\tmapToNodeOperationError,\n\ttryRefreshOAuth2Token,\n} from '../shared/utils';\n\nexport async function getTools(\n\tthis: ILoadOptionsFunctions,\n\tfilter?: string,\n\tpaginationToken?: string,\n): Promise<INodeListSearchResult> {\n\tconst authentication = this.getNodeParameter('authentication') as McpAuthenticationOption;\n\tconst serverTransport = this.getNodeParameter('serverTransport') as McpServerTransport;\n\tconst endpointUrl = this.getNodeParameter('endpointUrl') as string;\n\tconst node = this.getNode();\n\tconst { headers } = await getAuthHeaders(this, authentication);\n\tconst client = await connectMcpClient({\n\t\tserverTransport,\n\t\tendpointUrl,\n\t\theaders,\n\t\tname: node.type,\n\t\tversion: node.typeVersion,\n\t\tonUnauthorized: async (headers) => await tryRefreshOAuth2Token(this, authentication, headers),\n\t});\n\n\tif (!client.ok) {\n\t\tthrow mapToNodeOperationError(node, client.error);\n\t}\n\n\tconst result = await client.result.listTools({ cursor: paginationToken });\n\tconst tools = filter\n\t\t? result.tools.filter((tool) => tool.name.toLowerCase().includes(filter.toLowerCase()))\n\t\t: result.tools;\n\n\treturn {\n\t\tresults: tools.map((tool) => ({\n\t\t\tname: tool.name,\n\t\t\tvalue: tool.name,\n\t\t\tdescription: tool.description,\n\t\t\tinputSchema: tool.inputSchema,\n\t\t})),\n\t\tpaginationToken: result.nextCursor,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAKO;AAEP,eAAsB,SAErB,QACA,iBACiC;AACjC,QAAM,iBAAiB,KAAK,iBAAiB,gBAAgB;AAC7D,QAAM,kBAAkB,KAAK,iBAAiB,iBAAiB;AAC/D,QAAM,cAAc,KAAK,iBAAiB,aAAa;AACvD,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,EAAE,QAAQ,IAAI,UAAM,6BAAe,MAAM,cAAc;AAC7D,QAAM,SAAS,UAAM,+BAAiB;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,KAAK;AAAA,IACX,SAAS,KAAK;AAAA,IACd,gBAAgB,OAAOA,aAAY,UAAM,oCAAsB,MAAM,gBAAgBA,QAAO;AAAA,EAC7F,CAAC;AAED,MAAI,CAAC,OAAO,IAAI;AACf,cAAM,sCAAwB,MAAM,OAAO,KAAK;AAAA,EACjD;AAEA,QAAM,SAAS,MAAM,OAAO,OAAO,UAAU,EAAE,QAAQ,gBAAgB,CAAC;AACxE,QAAM,QAAQ,SACX,OAAO,MAAM,OAAO,CAAC,SAAS,KAAK,KAAK,YAAY,EAAE,SAAS,OAAO,YAAY,CAAC,CAAC,IACpF,OAAO;AAEV,SAAO;AAAA,IACN,SAAS,MAAM,IAAI,CAAC,UAAU;AAAA,MAC7B,MAAM,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,aAAa,KAAK;AAAA,IACnB,EAAE;AAAA,IACF,iBAAiB,OAAO;AAAA,EACzB;AACD;","names":["headers"]}
@@ -0,0 +1,61 @@
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 resourceMapping_exports = {};
20
+ __export(resourceMapping_exports, {
21
+ getToolParameters: () => getToolParameters
22
+ });
23
+ module.exports = __toCommonJS(resourceMapping_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
25
+ var import_utils = require("./utils");
26
+ var import_utils2 = require("../shared/utils");
27
+ async function getToolParameters() {
28
+ const toolId = this.getNodeParameter("tool", 0, {
29
+ extractValue: true
30
+ });
31
+ const authentication = this.getNodeParameter("authentication");
32
+ const serverTransport = this.getNodeParameter("serverTransport");
33
+ const endpointUrl = this.getNodeParameter("endpointUrl");
34
+ const node = this.getNode();
35
+ const { headers } = await (0, import_utils2.getAuthHeaders)(this, authentication);
36
+ const client = await (0, import_utils2.connectMcpClient)({
37
+ serverTransport,
38
+ endpointUrl,
39
+ headers,
40
+ name: node.type,
41
+ version: node.typeVersion,
42
+ onUnauthorized: async (headers2) => await (0, import_utils2.tryRefreshOAuth2Token)(this, authentication, headers2)
43
+ });
44
+ if (!client.ok) {
45
+ throw (0, import_utils2.mapToNodeOperationError)(node, client.error);
46
+ }
47
+ const result = await (0, import_utils2.getAllTools)(client.result);
48
+ const tool = result.find((tool2) => tool2.name === toolId);
49
+ if (!tool) {
50
+ throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Tool not found");
51
+ }
52
+ const fields = (0, import_utils.convertJsonSchemaToResourceMapperFields)(tool.inputSchema);
53
+ return {
54
+ fields
55
+ };
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ getToolParameters
60
+ });
61
+ //# sourceMappingURL=resourceMapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../nodes/McpClient/resourceMapping.ts"],"sourcesContent":["import type { ILoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';\nimport { NodeOperationError } from 'n8n-workflow';\n\nimport { convertJsonSchemaToResourceMapperFields } from './utils';\nimport type { McpAuthenticationOption, McpServerTransport } from '../shared/types';\nimport {\n\tgetAuthHeaders,\n\tconnectMcpClient,\n\tgetAllTools,\n\ttryRefreshOAuth2Token,\n\tmapToNodeOperationError,\n} from '../shared/utils';\n\nexport async function getToolParameters(\n\tthis: ILoadOptionsFunctions,\n): Promise<ResourceMapperFields> {\n\tconst toolId = this.getNodeParameter('tool', 0, {\n\t\textractValue: true,\n\t}) as string;\n\tconst authentication = this.getNodeParameter('authentication') as McpAuthenticationOption;\n\tconst serverTransport = this.getNodeParameter('serverTransport') as McpServerTransport;\n\tconst endpointUrl = this.getNodeParameter('endpointUrl') as string;\n\tconst node = this.getNode();\n\tconst { headers } = await getAuthHeaders(this, authentication);\n\tconst client = await connectMcpClient({\n\t\tserverTransport,\n\t\tendpointUrl,\n\t\theaders,\n\t\tname: node.type,\n\t\tversion: node.typeVersion,\n\t\tonUnauthorized: async (headers) => await tryRefreshOAuth2Token(this, authentication, headers),\n\t});\n\n\tif (!client.ok) {\n\t\tthrow mapToNodeOperationError(node, client.error);\n\t}\n\n\tconst result = await getAllTools(client.result);\n\tconst tool = result.find((tool) => tool.name === toolId);\n\tif (!tool) {\n\t\tthrow new NodeOperationError(this.getNode(), 'Tool not found');\n\t}\n\n\tconst fields = convertJsonSchemaToResourceMapperFields(tool.inputSchema);\n\treturn {\n\t\tfields,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAmC;AAEnC,mBAAwD;AAExD,IAAAA,gBAMO;AAEP,eAAsB,oBAEW;AAChC,QAAM,SAAS,KAAK,iBAAiB,QAAQ,GAAG;AAAA,IAC/C,cAAc;AAAA,EACf,CAAC;AACD,QAAM,iBAAiB,KAAK,iBAAiB,gBAAgB;AAC7D,QAAM,kBAAkB,KAAK,iBAAiB,iBAAiB;AAC/D,QAAM,cAAc,KAAK,iBAAiB,aAAa;AACvD,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,EAAE,QAAQ,IAAI,UAAM,8BAAe,MAAM,cAAc;AAC7D,QAAM,SAAS,UAAM,gCAAiB;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,KAAK;AAAA,IACX,SAAS,KAAK;AAAA,IACd,gBAAgB,OAAOC,aAAY,UAAM,qCAAsB,MAAM,gBAAgBA,QAAO;AAAA,EAC7F,CAAC;AAED,MAAI,CAAC,OAAO,IAAI;AACf,cAAM,uCAAwB,MAAM,OAAO,KAAK;AAAA,EACjD;AAEA,QAAM,SAAS,UAAM,2BAAY,OAAO,MAAM;AAC9C,QAAM,OAAO,OAAO,KAAK,CAACC,UAASA,MAAK,SAAS,MAAM;AACvD,MAAI,CAAC,MAAM;AACV,UAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,gBAAgB;AAAA,EAC9D;AAEA,QAAM,aAAS,sDAAwC,KAAK,WAAW;AACvE,SAAO;AAAA,IACN;AAAA,EACD;AACD;","names":["import_utils","headers","tool"]}