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,248 @@
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 utils_exports = {};
20
+ __export(utils_exports, {
21
+ convertJsonSchemaToResourceMapperFields: () => convertJsonSchemaToResourceMapperFields,
22
+ jsonSchemaTypeToDefaultValue: () => jsonSchemaTypeToDefaultValue,
23
+ jsonSchemaTypeToFieldType: () => jsonSchemaTypeToFieldType
24
+ });
25
+ module.exports = __toCommonJS(utils_exports);
26
+ function pickFirstSchema(schema) {
27
+ if (typeof schema === "object" && (schema?.anyOf || schema?.oneOf)) {
28
+ if (Array.isArray(schema.anyOf) && schema.anyOf[0] !== void 0) {
29
+ return schema.anyOf[0];
30
+ }
31
+ if (Array.isArray(schema.oneOf) && schema.oneOf[0] !== void 0) {
32
+ return schema.oneOf[0];
33
+ }
34
+ }
35
+ return schema;
36
+ }
37
+ function mergeTwoSchemas(a, b) {
38
+ if (a === void 0) {
39
+ return b;
40
+ }
41
+ if (b === void 0) {
42
+ return a;
43
+ }
44
+ a = pickFirstSchema(a);
45
+ b = pickFirstSchema(b);
46
+ if (a === false || b === false) {
47
+ return false;
48
+ }
49
+ if (a === true || b === true) {
50
+ return true;
51
+ }
52
+ if (a.type === "object" && b.type === "object") {
53
+ const properties = { ...a.properties ?? {}, ...b.properties ?? {} };
54
+ const required = [...a.required ?? [], ...b.required ?? []];
55
+ const additionalProperties = mergeTwoSchemas(a.additionalProperties, b.additionalProperties);
56
+ return { ...a, ...b, properties, required, additionalProperties };
57
+ }
58
+ if (a.type === "array" && b.type === "array") {
59
+ if (Array.isArray(a.items) && Array.isArray(b.items)) {
60
+ return a.items.length > b.items.length ? a : b;
61
+ }
62
+ if (Array.isArray(a.items) || Array.isArray(b.items)) {
63
+ return Array.isArray(a.items) ? a : b;
64
+ }
65
+ const items = mergeTwoSchemas(a.items, b.items);
66
+ return { ...a, ...b, items };
67
+ }
68
+ return void 0;
69
+ }
70
+ function mergeAllOfSchemas(schemas) {
71
+ if (schemas.length === 0) {
72
+ return void 0;
73
+ }
74
+ if (schemas.length === 1) {
75
+ return schemas[0];
76
+ }
77
+ return schemas.reduce(
78
+ (acc, schema) => mergeTwoSchemas(acc, schema),
79
+ void 0
80
+ );
81
+ }
82
+ function jsonSchemaTypeToDefaultValue(schema) {
83
+ if (schema === false) {
84
+ return null;
85
+ }
86
+ if (schema === true) {
87
+ return "any";
88
+ }
89
+ if (schema.allOf) {
90
+ const mergedSchema = mergeAllOfSchemas(schema.allOf);
91
+ if (mergedSchema !== void 0) {
92
+ return jsonSchemaTypeToDefaultValue(mergedSchema);
93
+ }
94
+ }
95
+ if (schema.anyOf) {
96
+ const anyOfSchemas = schema.anyOf;
97
+ for (const anyOfSchema of anyOfSchemas) {
98
+ const defaultValue = jsonSchemaTypeToDefaultValue(anyOfSchema);
99
+ if (defaultValue !== null) {
100
+ return defaultValue;
101
+ }
102
+ }
103
+ }
104
+ if (schema.oneOf) {
105
+ const oneOfSchemas = schema.oneOf;
106
+ for (const oneOfSchema of oneOfSchemas) {
107
+ const defaultValue = jsonSchemaTypeToDefaultValue(oneOfSchema);
108
+ if (defaultValue !== null) {
109
+ return defaultValue;
110
+ }
111
+ }
112
+ }
113
+ if (schema.enum && Array.isArray(schema.enum)) {
114
+ return schema.enum[0];
115
+ }
116
+ if (Array.isArray(schema.type)) {
117
+ const types = schema.type;
118
+ for (const type of types) {
119
+ const defaultValue = jsonSchemaTypeToDefaultValue({ type });
120
+ if (defaultValue !== null) {
121
+ return defaultValue;
122
+ }
123
+ }
124
+ }
125
+ if (schema.type === "number" || schema.type === "integer") {
126
+ if (schema.minimum !== void 0) {
127
+ return schema.minimum;
128
+ }
129
+ if (schema.maximum !== void 0) {
130
+ return schema.maximum;
131
+ }
132
+ return 0;
133
+ }
134
+ if (schema.type === "boolean") {
135
+ return false;
136
+ }
137
+ if (schema.type === "string") {
138
+ if (schema.format === "date-time") {
139
+ return "2025-01-01T00:00:00Z";
140
+ }
141
+ if (schema.format === "uri" || schema.format === "url") {
142
+ return "https://example.com";
143
+ }
144
+ if (schema.format === "date") {
145
+ return "2025-01-01";
146
+ }
147
+ if (schema.format === "time") {
148
+ return "00:00:00";
149
+ }
150
+ return "string";
151
+ }
152
+ if (schema.type === "array") {
153
+ if (!schema.items) {
154
+ return [];
155
+ }
156
+ if (Array.isArray(schema.items)) {
157
+ return schema.items.map((item) => jsonSchemaTypeToDefaultValue(item));
158
+ }
159
+ return [jsonSchemaTypeToDefaultValue(schema.items)];
160
+ }
161
+ if (schema.type === "object") {
162
+ const properties = schema.properties ?? {};
163
+ const exampleObject = {};
164
+ for (const [key, propertySchema] of Object.entries(properties)) {
165
+ const propertyValue = jsonSchemaTypeToDefaultValue(propertySchema);
166
+ if (propertyValue !== null) {
167
+ exampleObject[key] = propertyValue;
168
+ }
169
+ }
170
+ if (schema.additionalProperties) {
171
+ const additionalProperties = jsonSchemaTypeToDefaultValue(schema.additionalProperties);
172
+ if (additionalProperties !== null) {
173
+ exampleObject["<additionalProperty>"] = additionalProperties;
174
+ }
175
+ }
176
+ return exampleObject;
177
+ }
178
+ return null;
179
+ }
180
+ function jsonSchemaTypeToFieldType(schema) {
181
+ if (schema.type === "string" && schema.format === "date-time") {
182
+ return "dateTime";
183
+ }
184
+ if (schema.type === "number" || schema.type === "integer") {
185
+ return "number";
186
+ }
187
+ if (schema.type === "boolean" || schema.type === "array" || schema.type === "object") {
188
+ return schema.type;
189
+ }
190
+ return "string";
191
+ }
192
+ function convertJsonSchemaToResourceMapperFields(schema) {
193
+ const fields = [];
194
+ if (schema.type !== "object" || !schema.properties) {
195
+ return fields;
196
+ }
197
+ const required = Array.isArray(schema.required) ? schema.required : [];
198
+ for (const [key, propertySchema] of Object.entries(schema.properties)) {
199
+ if (propertySchema === false) {
200
+ continue;
201
+ }
202
+ if (propertySchema === true) {
203
+ fields.push({
204
+ id: key,
205
+ displayName: key,
206
+ defaultMatch: false,
207
+ required: required.includes(key),
208
+ display: true,
209
+ type: "string"
210
+ // use string as a "catch all" for any values
211
+ });
212
+ continue;
213
+ }
214
+ const schemaType = jsonSchemaTypeToFieldType(propertySchema);
215
+ let defaultValue;
216
+ if (schemaType === "object" || schemaType === "array") {
217
+ const result = jsonSchemaTypeToDefaultValue(propertySchema);
218
+ if (result !== null) {
219
+ defaultValue = JSON.stringify(result, null, 2);
220
+ }
221
+ }
222
+ const field = {
223
+ id: key,
224
+ displayName: propertySchema.title ?? key,
225
+ defaultMatch: false,
226
+ required: required.includes(key),
227
+ display: true,
228
+ type: schemaType,
229
+ defaultValue
230
+ };
231
+ if (propertySchema.enum && Array.isArray(propertySchema.enum)) {
232
+ field.type = "options";
233
+ field.options = propertySchema.enum.map((value) => ({
234
+ name: value,
235
+ value
236
+ }));
237
+ }
238
+ fields.push(field);
239
+ }
240
+ return fields;
241
+ }
242
+ // Annotate the CommonJS export names for ESM import in node:
243
+ 0 && (module.exports = {
244
+ convertJsonSchemaToResourceMapperFields,
245
+ jsonSchemaTypeToDefaultValue,
246
+ jsonSchemaTypeToFieldType
247
+ });
248
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../nodes/McpClient/utils.ts"],"sourcesContent":["import type { JSONSchema7, JSONSchema7Definition } from 'json-schema';\nimport type {\n\tResourceMapperField,\n\tFieldType,\n\tINodePropertyOptions,\n\tIDataObject,\n} from 'n8n-workflow';\n\nfunction pickFirstSchema(schema: JSONSchema7Definition): JSONSchema7Definition {\n\tif (typeof schema === 'object' && (schema?.anyOf || schema?.oneOf)) {\n\t\tif (Array.isArray(schema.anyOf) && schema.anyOf[0] !== undefined) {\n\t\t\treturn schema.anyOf[0];\n\t\t}\n\n\t\tif (Array.isArray(schema.oneOf) && schema.oneOf[0] !== undefined) {\n\t\t\treturn schema.oneOf[0];\n\t\t}\n\t}\n\n\treturn schema;\n}\n\nfunction mergeTwoSchemas(\n\ta?: JSONSchema7Definition,\n\tb?: JSONSchema7Definition,\n): JSONSchema7Definition | undefined {\n\tif (a === undefined) {\n\t\treturn b;\n\t}\n\n\tif (b === undefined) {\n\t\treturn a;\n\t}\n\n\ta = pickFirstSchema(a);\n\tb = pickFirstSchema(b);\n\tif (a === false || b === false) {\n\t\treturn false;\n\t}\n\n\tif (a === true || b === true) {\n\t\treturn true;\n\t}\n\n\tif (a.type === 'object' && b.type === 'object') {\n\t\tconst properties = { ...(a.properties ?? {}), ...(b.properties ?? {}) };\n\t\tconst required = [...(a.required ?? []), ...(b.required ?? [])];\n\t\tconst additionalProperties = mergeTwoSchemas(a.additionalProperties, b.additionalProperties);\n\t\treturn { ...a, ...b, properties, required, additionalProperties };\n\t}\n\n\tif (a.type === 'array' && b.type === 'array') {\n\t\tif (Array.isArray(a.items) && Array.isArray(b.items)) {\n\t\t\t// Two tuples -> pick the longer one\n\t\t\treturn a.items.length > b.items.length ? a : b;\n\t\t}\n\n\t\tif (Array.isArray(a.items) || Array.isArray(b.items)) {\n\t\t\t// One tuple -> pick the tuple\n\t\t\treturn Array.isArray(a.items) ? a : b;\n\t\t}\n\n\t\tconst items = mergeTwoSchemas(a.items, b.items);\n\t\treturn { ...a, ...b, items };\n\t}\n\n\treturn undefined;\n}\n\nfunction mergeAllOfSchemas(schemas: JSONSchema7Definition[]): JSONSchema7Definition | undefined {\n\tif (schemas.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (schemas.length === 1) {\n\t\treturn schemas[0];\n\t}\n\n\treturn schemas.reduce(\n\t\t(acc, schema) => mergeTwoSchemas(acc, schema),\n\t\tundefined as JSONSchema7Definition | undefined,\n\t);\n}\n\nexport function jsonSchemaTypeToDefaultValue(\n\tschema: JSONSchema7Definition,\n): string | number | boolean | object | null {\n\tif (schema === false) {\n\t\treturn null;\n\t}\n\n\tif (schema === true) {\n\t\treturn 'any';\n\t}\n\n\tif (schema.allOf) {\n\t\tconst mergedSchema = mergeAllOfSchemas(schema.allOf);\n\t\tif (mergedSchema !== undefined) {\n\t\t\treturn jsonSchemaTypeToDefaultValue(mergedSchema);\n\t\t}\n\t}\n\n\tif (schema.anyOf) {\n\t\tconst anyOfSchemas = schema.anyOf;\n\t\tfor (const anyOfSchema of anyOfSchemas) {\n\t\t\tconst defaultValue = jsonSchemaTypeToDefaultValue(anyOfSchema);\n\t\t\tif (defaultValue !== null) {\n\t\t\t\treturn defaultValue;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (schema.oneOf) {\n\t\tconst oneOfSchemas = schema.oneOf;\n\t\tfor (const oneOfSchema of oneOfSchemas) {\n\t\t\tconst defaultValue = jsonSchemaTypeToDefaultValue(oneOfSchema);\n\t\t\tif (defaultValue !== null) {\n\t\t\t\treturn defaultValue;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (schema.enum && Array.isArray(schema.enum)) {\n\t\treturn schema.enum[0];\n\t}\n\n\tif (Array.isArray(schema.type)) {\n\t\tconst types = schema.type;\n\t\tfor (const type of types) {\n\t\t\tconst defaultValue = jsonSchemaTypeToDefaultValue({ type });\n\t\t\tif (defaultValue !== null) {\n\t\t\t\treturn defaultValue;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (schema.type === 'number' || schema.type === 'integer') {\n\t\tif (schema.minimum !== undefined) {\n\t\t\treturn schema.minimum;\n\t\t}\n\n\t\tif (schema.maximum !== undefined) {\n\t\t\treturn schema.maximum;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tif (schema.type === 'boolean') {\n\t\treturn false;\n\t}\n\n\tif (schema.type === 'string') {\n\t\tif (schema.format === 'date-time') {\n\t\t\treturn '2025-01-01T00:00:00Z';\n\t\t}\n\n\t\tif (schema.format === 'uri' || schema.format === 'url') {\n\t\t\treturn 'https://example.com';\n\t\t}\n\n\t\tif (schema.format === 'date') {\n\t\t\treturn '2025-01-01';\n\t\t}\n\n\t\tif (schema.format === 'time') {\n\t\t\treturn '00:00:00';\n\t\t}\n\n\t\treturn 'string';\n\t}\n\n\tif (schema.type === 'array') {\n\t\tif (!schema.items) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (Array.isArray(schema.items)) {\n\t\t\treturn schema.items.map((item) => jsonSchemaTypeToDefaultValue(item));\n\t\t}\n\n\t\treturn [jsonSchemaTypeToDefaultValue(schema.items)];\n\t}\n\n\tif (schema.type === 'object') {\n\t\tconst properties = schema.properties ?? {};\n\t\tconst exampleObject: IDataObject = {};\n\t\tfor (const [key, propertySchema] of Object.entries(properties)) {\n\t\t\tconst propertyValue = jsonSchemaTypeToDefaultValue(propertySchema);\n\t\t\tif (propertyValue !== null) {\n\t\t\t\texampleObject[key] = propertyValue;\n\t\t\t}\n\t\t}\n\n\t\tif (schema.additionalProperties) {\n\t\t\tconst additionalProperties = jsonSchemaTypeToDefaultValue(schema.additionalProperties);\n\t\t\tif (additionalProperties !== null) {\n\t\t\t\texampleObject['<additionalProperty>'] = additionalProperties;\n\t\t\t}\n\t\t}\n\n\t\treturn exampleObject;\n\t}\n\n\treturn null;\n}\n\nexport function jsonSchemaTypeToFieldType(schema: JSONSchema7): FieldType {\n\tif (schema.type === 'string' && schema.format === 'date-time') {\n\t\treturn 'dateTime';\n\t}\n\n\tif (schema.type === 'number' || schema.type === 'integer') {\n\t\treturn 'number';\n\t}\n\n\tif (schema.type === 'boolean' || schema.type === 'array' || schema.type === 'object') {\n\t\treturn schema.type;\n\t}\n\n\treturn 'string';\n}\n\nexport function convertJsonSchemaToResourceMapperFields(\n\tschema: JSONSchema7,\n): ResourceMapperField[] {\n\tconst fields: ResourceMapperField[] = [];\n\tif (schema.type !== 'object' || !schema.properties) {\n\t\treturn fields;\n\t}\n\n\tconst required = Array.isArray(schema.required) ? schema.required : [];\n\tfor (const [key, propertySchema] of Object.entries(schema.properties)) {\n\t\tif (propertySchema === false) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (propertySchema === true) {\n\t\t\tfields.push({\n\t\t\t\tid: key,\n\t\t\t\tdisplayName: key,\n\t\t\t\tdefaultMatch: false,\n\t\t\t\trequired: required.includes(key),\n\t\t\t\tdisplay: true,\n\t\t\t\ttype: 'string', // use string as a \"catch all\" for any values\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst schemaType = jsonSchemaTypeToFieldType(propertySchema);\n\t\tlet defaultValue: string | undefined;\n\t\tif (schemaType === 'object' || schemaType === 'array') {\n\t\t\tconst result = jsonSchemaTypeToDefaultValue(propertySchema);\n\t\t\tif (result !== null) {\n\t\t\t\tdefaultValue = JSON.stringify(result, null, 2);\n\t\t\t}\n\t\t}\n\n\t\tconst field: ResourceMapperField = {\n\t\t\tid: key,\n\t\t\tdisplayName: propertySchema.title ?? key,\n\t\t\tdefaultMatch: false,\n\t\t\trequired: required.includes(key),\n\t\t\tdisplay: true,\n\t\t\ttype: schemaType,\n\t\t\tdefaultValue,\n\t\t};\n\n\t\tif (propertySchema.enum && Array.isArray(propertySchema.enum)) {\n\t\t\tfield.type = 'options';\n\t\t\tfield.options = propertySchema.enum.map((value) => ({\n\t\t\t\tname: value,\n\t\t\t\tvalue,\n\t\t\t})) as INodePropertyOptions[];\n\t\t}\n\n\t\tfields.push(field);\n\t}\n\n\treturn fields;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAS,gBAAgB,QAAsD;AAC9E,MAAI,OAAO,WAAW,aAAa,QAAQ,SAAS,QAAQ,QAAQ;AACnE,QAAI,MAAM,Q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,MAAM;AAAA,MACN;AAAA,IACD;AAEA,QAAI,eAAe,QAAQ,MAAM,QAAQ,eAAe,IAAI,GAAG;AAC9D,YAAM,OAAO;AACb,YAAM,UAAU,eAAe,KAAK,IAAI,CAAC,WAAW;AAAA,QACnD,MAAM;AAAA,QACN;AAAA,MACD,EAAE;AAAA,IACH;AAEA,WAAO,KAAK,KAAK;AAAA,EAClB;AAEA,SAAO;AACR;","names":[]}
@@ -0,0 +1,417 @@
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 McpClientTool_node_exports = {};
20
+ __export(McpClientTool_node_exports, {
21
+ McpClientTool: () => McpClientTool
22
+ });
23
+ module.exports = __toCommonJS(McpClientTool_node_exports);
24
+ var import_types = require("@modelcontextprotocol/sdk/types.js");
25
+ var import_n8n_workflow = require("n8n-workflow");
26
+ var import_logWrapper = require("@utils/logWrapper");
27
+ var import_sharedFields = require("@utils/sharedFields");
28
+ var import_loadOptions = require("./loadOptions");
29
+ var import_utils = require("./utils");
30
+ var import_descriptions = require("../shared/descriptions");
31
+ var import_utils2 = require("../shared/utils");
32
+ function getNodeConfig(ctx, itemIndex) {
33
+ const node = ctx.getNode();
34
+ const authentication = ctx.getNodeParameter(
35
+ "authentication",
36
+ itemIndex
37
+ );
38
+ const timeout = ctx.getNodeParameter("options.timeout", itemIndex, 6e4);
39
+ let serverTransport;
40
+ let endpointUrl;
41
+ if (node.typeVersion === 1) {
42
+ serverTransport = "sse";
43
+ endpointUrl = ctx.getNodeParameter("sseEndpoint", itemIndex);
44
+ } else {
45
+ serverTransport = ctx.getNodeParameter("serverTransport", itemIndex);
46
+ endpointUrl = ctx.getNodeParameter("endpointUrl", itemIndex);
47
+ }
48
+ const mode = ctx.getNodeParameter("include", itemIndex);
49
+ const includeTools = ctx.getNodeParameter("includeTools", itemIndex, []);
50
+ const excludeTools = ctx.getNodeParameter("excludeTools", itemIndex, []);
51
+ return {
52
+ authentication,
53
+ timeout,
54
+ serverTransport,
55
+ endpointUrl,
56
+ mode,
57
+ includeTools,
58
+ excludeTools
59
+ };
60
+ }
61
+ async function connectAndGetTools(ctx, config) {
62
+ const node = ctx.getNode();
63
+ const { headers } = await (0, import_utils2.getAuthHeaders)(ctx, config.authentication);
64
+ const client = await (0, import_utils2.connectMcpClient)({
65
+ serverTransport: config.serverTransport,
66
+ endpointUrl: config.endpointUrl,
67
+ headers,
68
+ name: node.type,
69
+ version: node.typeVersion,
70
+ onUnauthorized: async (headers2) => await (0, import_utils2.tryRefreshOAuth2Token)(ctx, config.authentication, headers2)
71
+ });
72
+ if (!client.ok) {
73
+ return { client, mcpTools: null, error: client.error };
74
+ }
75
+ const allTools = await (0, import_utils2.getAllTools)(client.result);
76
+ const mcpTools = (0, import_utils.getSelectedTools)({
77
+ tools: allTools,
78
+ mode: config.mode,
79
+ includeTools: config.includeTools,
80
+ excludeTools: config.excludeTools
81
+ });
82
+ return { client: client.result, mcpTools, error: null };
83
+ }
84
+ class McpClientTool {
85
+ description = {
86
+ displayName: "MCP Client Tool",
87
+ name: "mcpClientTool",
88
+ icon: {
89
+ light: "file:../mcp.svg",
90
+ dark: "file:../mcp.dark.svg"
91
+ },
92
+ group: ["output"],
93
+ version: [1, 1.1, 1.2],
94
+ description: "Connect tools from an MCP Server",
95
+ defaults: {
96
+ name: "MCP Client"
97
+ },
98
+ codex: {
99
+ categories: ["AI"],
100
+ subcategories: {
101
+ AI: ["Model Context Protocol", "Tools"]
102
+ },
103
+ alias: ["Model Context Protocol", "MCP Client"],
104
+ resources: {
105
+ primaryDocumentation: [
106
+ {
107
+ url: "https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/"
108
+ }
109
+ ]
110
+ }
111
+ },
112
+ inputs: [],
113
+ outputs: [{ type: import_n8n_workflow.NodeConnectionTypes.AiTool, displayName: "Tools" }],
114
+ credentials: import_descriptions.credentials,
115
+ properties: [
116
+ (0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiAgent]),
117
+ {
118
+ displayName: "SSE Endpoint",
119
+ name: "sseEndpoint",
120
+ type: "string",
121
+ description: "SSE Endpoint of your MCP server",
122
+ placeholder: "e.g. https://my-mcp-server.ai/sse",
123
+ default: "",
124
+ required: true,
125
+ displayOptions: {
126
+ show: {
127
+ "@version": [1]
128
+ }
129
+ }
130
+ },
131
+ {
132
+ displayName: "Endpoint",
133
+ name: "endpointUrl",
134
+ type: "string",
135
+ description: "Endpoint of your MCP server",
136
+ placeholder: "e.g. https://my-mcp-server.ai/mcp",
137
+ default: "",
138
+ required: true,
139
+ displayOptions: {
140
+ show: {
141
+ "@version": [{ _cnd: { gte: 1.1 } }]
142
+ }
143
+ }
144
+ },
145
+ (0, import_descriptions.transportSelect)({
146
+ defaultOption: "sse",
147
+ displayOptions: {
148
+ show: {
149
+ "@version": [1.1]
150
+ }
151
+ }
152
+ }),
153
+ (0, import_descriptions.transportSelect)({
154
+ defaultOption: "httpStreamable",
155
+ displayOptions: {
156
+ show: {
157
+ "@version": [{ _cnd: { gte: 1.2 } }]
158
+ }
159
+ }
160
+ }),
161
+ {
162
+ displayName: "Authentication",
163
+ name: "authentication",
164
+ type: "options",
165
+ options: [
166
+ {
167
+ name: "Bearer Auth",
168
+ value: "bearerAuth"
169
+ },
170
+ {
171
+ name: "Header Auth",
172
+ value: "headerAuth"
173
+ },
174
+ {
175
+ name: "None",
176
+ value: "none"
177
+ }
178
+ ],
179
+ default: "none",
180
+ description: "The way to authenticate with your endpoint",
181
+ displayOptions: {
182
+ show: {
183
+ "@version": [{ _cnd: { lt: 1.2 } }]
184
+ }
185
+ }
186
+ },
187
+ {
188
+ displayName: "Authentication",
189
+ name: "authentication",
190
+ type: "options",
191
+ options: [
192
+ {
193
+ name: "Bearer Auth",
194
+ value: "bearerAuth"
195
+ },
196
+ {
197
+ name: "Header Auth",
198
+ value: "headerAuth"
199
+ },
200
+ {
201
+ name: "MCP OAuth2",
202
+ value: "mcpOAuth2Api"
203
+ },
204
+ {
205
+ name: "Multiple Headers Auth",
206
+ value: "multipleHeadersAuth"
207
+ },
208
+ {
209
+ name: "None",
210
+ value: "none"
211
+ }
212
+ ],
213
+ default: "none",
214
+ description: "The way to authenticate with your endpoint",
215
+ displayOptions: {
216
+ show: {
217
+ "@version": [{ _cnd: { gte: 1.2 } }]
218
+ }
219
+ }
220
+ },
221
+ {
222
+ displayName: "Credentials",
223
+ name: "credentials",
224
+ type: "credentials",
225
+ default: "",
226
+ displayOptions: {
227
+ show: {
228
+ authentication: ["headerAuth", "bearerAuth", "mcpOAuth2Api", "multipleHeadersAuth"]
229
+ }
230
+ }
231
+ },
232
+ {
233
+ displayName: "Tools to Include",
234
+ name: "include",
235
+ type: "options",
236
+ description: "How to select the tools you want to be exposed to the AI Agent",
237
+ default: "all",
238
+ options: [
239
+ {
240
+ name: "All",
241
+ value: "all",
242
+ description: "Also include all unchanged fields from the input"
243
+ },
244
+ {
245
+ name: "Selected",
246
+ value: "selected",
247
+ description: 'Also include the tools listed in the parameter "Tools to Include"'
248
+ },
249
+ {
250
+ name: "All Except",
251
+ value: "except",
252
+ description: 'Exclude the tools listed in the parameter "Tools to Exclude"'
253
+ }
254
+ ]
255
+ },
256
+ {
257
+ displayName: "Tools to Include",
258
+ name: "includeTools",
259
+ type: "multiOptions",
260
+ default: [],
261
+ description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
262
+ typeOptions: {
263
+ loadOptionsMethod: "getTools",
264
+ loadOptionsDependsOn: ["sseEndpoint"]
265
+ },
266
+ displayOptions: {
267
+ show: {
268
+ include: ["selected"]
269
+ }
270
+ }
271
+ },
272
+ {
273
+ displayName: "Tools to Exclude",
274
+ name: "excludeTools",
275
+ type: "multiOptions",
276
+ default: [],
277
+ description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
278
+ typeOptions: {
279
+ loadOptionsMethod: "getTools"
280
+ },
281
+ displayOptions: {
282
+ show: {
283
+ include: ["except"]
284
+ }
285
+ }
286
+ },
287
+ {
288
+ displayName: "Options",
289
+ name: "options",
290
+ placeholder: "Add Option",
291
+ description: "Additional options to add",
292
+ type: "collection",
293
+ default: {},
294
+ options: [
295
+ {
296
+ displayName: "cdp_endpointUrl",
297
+ name: "cdp_endpointUrl",
298
+ type: "string",
299
+ default: ""
300
+ },
301
+ {
302
+ displayName: "Timeout",
303
+ name: "timeout",
304
+ type: "number",
305
+ typeOptions: {
306
+ minValue: 1
307
+ },
308
+ default: 6e4,
309
+ description: "Time in ms to wait for tool calls to finish"
310
+ },
311
+ {
312
+ displayName: "Timeout",
313
+ name: "timeout",
314
+ type: "number",
315
+ typeOptions: {
316
+ minValue: 1
317
+ },
318
+ default: 6e4,
319
+ description: "Time in ms to wait for tool calls to finish"
320
+ }
321
+ ]
322
+ }
323
+ ]
324
+ };
325
+ methods = {
326
+ loadOptions: {
327
+ getTools: import_loadOptions.getTools
328
+ }
329
+ };
330
+ async supplyData(itemIndex) {
331
+ const node = this.getNode();
332
+ const config = getNodeConfig(this, itemIndex);
333
+ const setError = (error2) => {
334
+ this.addOutputData(import_n8n_workflow.NodeConnectionTypes.AiTool, itemIndex, error2);
335
+ throw error2;
336
+ };
337
+ const { client, mcpTools, error } = await connectAndGetTools(this, config);
338
+ if (error) {
339
+ this.logger.error("McpClientTool: Failed to connect to MCP Server", { error });
340
+ return setError((0, import_utils2.mapToNodeOperationError)(node, error));
341
+ }
342
+ this.logger.debug("McpClientTool: Successfully connected to MCP Server");
343
+ if (!mcpTools?.length) {
344
+ return setError(
345
+ new import_n8n_workflow.NodeOperationError(node, "MCP Server returned no tools", {
346
+ itemIndex,
347
+ description: "Connected successfully to your MCP server but it returned an empty list of tools."
348
+ })
349
+ );
350
+ }
351
+ const tools = mcpTools.map(
352
+ (tool) => (0, import_logWrapper.logWrapper)(
353
+ (0, import_utils.mcpToolToDynamicTool)(
354
+ tool,
355
+ (0, import_utils.createCallTool)(tool.name, client, config.timeout, (errorMessage) => {
356
+ const error2 = new import_n8n_workflow.NodeOperationError(node, errorMessage, { itemIndex });
357
+ void this.addOutputData(import_n8n_workflow.NodeConnectionTypes.AiTool, itemIndex, error2);
358
+ this.logger.error(`McpClientTool: Tool "${tool.name}" failed to execute`, { error: error2 });
359
+ })
360
+ ),
361
+ this
362
+ )
363
+ );
364
+ this.logger.debug(`McpClientTool: Connected to MCP Server with ${tools.length} tools`);
365
+ const toolkit = new import_utils.McpToolkit(tools);
366
+ return { response: toolkit, closeFunction: async () => await client.close() };
367
+ }
368
+ async execute() {
369
+ const node = this.getNode();
370
+ const items = this.getInputData();
371
+ const returnData = [];
372
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
373
+ const item = items[itemIndex];
374
+ const config = getNodeConfig(this, itemIndex);
375
+ const { client, mcpTools, error } = await connectAndGetTools(this, config);
376
+ if (error) {
377
+ throw new import_n8n_workflow.NodeOperationError(node, error.error, { itemIndex });
378
+ }
379
+ if (!mcpTools?.length) {
380
+ throw new import_n8n_workflow.NodeOperationError(node, "MCP Server returned no tools", { itemIndex });
381
+ }
382
+ await client.callTool({ name: "browser_cdp_endpoint", arguments: { endpoint: config.cdp_endpointUrl } }, import_types.CallToolResultSchema, { timeout: config.timeout });
383
+ for (const tool of mcpTools) {
384
+ if (!item.json.tool || typeof item.json.tool !== "string") {
385
+ throw new import_n8n_workflow.NodeOperationError(node, "Tool name not found in item.json.tool or item.tool", {
386
+ itemIndex
387
+ });
388
+ }
389
+ const toolName = item.json.tool;
390
+ if (toolName === tool.name) {
391
+ const { tool: _, ...toolArguments } = item.json;
392
+ const params = {
393
+ name: tool.name,
394
+ arguments: toolArguments
395
+ };
396
+ const result = await client.callTool(params, import_types.CallToolResultSchema, {
397
+ timeout: config.timeout
398
+ });
399
+ returnData.push({
400
+ json: {
401
+ response: result.content || result
402
+ },
403
+ pairedItem: {
404
+ item: itemIndex
405
+ }
406
+ });
407
+ }
408
+ }
409
+ }
410
+ return [returnData];
411
+ }
412
+ }
413
+ // Annotate the CommonJS export names for ESM import in node:
414
+ 0 && (module.exports = {
415
+ McpClientTool
416
+ });
417
+ //# sourceMappingURL=McpClientTool.node.js.map