@n8n/n8n-nodes-langchain
Version:

61 lines • 2.24 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var loadOptions_exports = {};
__export(loadOptions_exports, {
getTools: () => getTools
});
module.exports = __toCommonJS(loadOptions_exports);
var import_utils = require("../shared/utils");
async function getTools() {
const authentication = this.getNodeParameter("authentication");
const node = this.getNode();
let serverTransport;
let endpointUrl;
if (node.typeVersion === 1) {
serverTransport = "sse";
endpointUrl = this.getNodeParameter("sseEndpoint");
} else {
serverTransport = this.getNodeParameter("serverTransport");
endpointUrl = this.getNodeParameter("endpointUrl");
}
const { headers } = await (0, import_utils.getAuthHeaders)(this, authentication);
const client = await (0, import_utils.connectMcpClient)({
serverTransport,
endpointUrl,
headers,
name: node.type,
version: node.typeVersion,
onUnauthorized: async (headers2) => await (0, import_utils.tryRefreshOAuth2Token)(this, authentication, headers2)
});
if (!client.ok) {
throw (0, import_utils.mapToNodeOperationError)(node, client.error);
}
const tools = await (0, import_utils.getAllTools)(client.result);
return tools.map((tool) => ({
name: tool.name,
value: tool.name,
description: tool.description,
inputSchema: tool.inputSchema
}));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getTools
});
//# sourceMappingURL=loadOptions.js.map