@n8n/n8n-nodes-langchain 1.120.1 → 1.121.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/VercelAiGatewayApi.credentials.js +1 -1
- package/dist/credentials/VercelAiGatewayApi.credentials.js.map +1 -1
- package/dist/known/credentials.json +1 -0
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/agents/Agent/V3/AgentV3.node.js +1 -1
- package/dist/nodes/agents/Agent/V3/AgentV3.node.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js +20 -399
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildExecutionContext.js +74 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildExecutionContext.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildResponseMetadata.js +37 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildResponseMetadata.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/checkMaxIterations.js +40 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/checkMaxIterations.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/createAgentSequence.js +61 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/createAgentSequence.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/executeBatch.js +88 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/executeBatch.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/finalizeResult.js +58 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/finalizeResult.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/index.js +50 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/index.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/prepareItemContext.js +66 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/prepareItemContext.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js +99 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/types.js +17 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/types.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js +55 -19
- package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js.map +1 -1
- package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js +1 -0
- package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js.map +1 -1
- package/dist/nodes/mcp/McpClient/McpClient.node.js +335 -0
- package/dist/nodes/mcp/McpClient/McpClient.node.js.map +1 -0
- package/dist/nodes/mcp/McpClient/listSearch.js +58 -0
- package/dist/nodes/mcp/McpClient/listSearch.js.map +1 -0
- package/dist/nodes/mcp/McpClient/resourceMapping.js +61 -0
- package/dist/nodes/mcp/McpClient/resourceMapping.js.map +1 -0
- package/dist/nodes/mcp/McpClient/utils.js +248 -0
- package/dist/nodes/mcp/McpClient/utils.js.map +1 -0
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js +13 -55
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js +2 -3
- package/dist/nodes/mcp/McpClientTool/loadOptions.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/types.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/utils.js +2 -174
- package/dist/nodes/mcp/McpClientTool/utils.js.map +1 -1
- package/dist/nodes/mcp/{McpClientTool → shared}/descriptions.js +40 -0
- package/dist/nodes/mcp/shared/descriptions.js.map +1 -0
- package/dist/nodes/mcp/shared/types.js +17 -0
- package/dist/nodes/mcp/shared/types.js.map +1 -0
- package/dist/nodes/mcp/shared/utils.js +231 -0
- package/dist/nodes/mcp/shared/utils.js.map +1 -0
- package/dist/nodes/tools/ToolHttpRequest/utils.js +5 -11
- package/dist/nodes/tools/ToolHttpRequest/utils.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js +3 -2
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/audio/index.js +2 -2
- package/dist/nodes/vendors/OpenAi/v1/actions/audio/index.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v2/OpenAiV2.node.js +1 -1
- package/dist/nodes/vendors/OpenAi/v2/OpenAiV2.node.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/index.js +2 -2
- package/dist/nodes/vendors/OpenAi/v2/actions/audio/index.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v2/actions/text/classify.operation.js +12 -3
- package/dist/nodes/vendors/OpenAi/v2/actions/text/classify.operation.js.map +1 -1
- package/dist/types/credentials.json +2 -2
- package/dist/types/nodes.json +5 -4
- package/dist/utils/agent-execution/buildSteps.js +77 -0
- package/dist/utils/agent-execution/buildSteps.js.map +1 -0
- package/dist/utils/agent-execution/createEngineRequests.js +48 -0
- package/dist/utils/agent-execution/createEngineRequests.js.map +1 -0
- package/dist/utils/agent-execution/index.js +42 -0
- package/dist/utils/agent-execution/index.js.map +1 -0
- package/dist/utils/agent-execution/memoryManagement.js +66 -0
- package/dist/utils/agent-execution/memoryManagement.js.map +1 -0
- package/dist/utils/agent-execution/processEventStream.js +128 -0
- package/dist/utils/agent-execution/processEventStream.js.map +1 -0
- package/dist/utils/agent-execution/types.js +17 -0
- package/dist/utils/agent-execution/types.js.map +1 -0
- package/package.json +12 -10
- package/dist/nodes/mcp/McpClientTool/descriptions.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/mcp/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,EAArC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,MACP;AAAA,MACA,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA;AAAA,MACA,QAAQ,CAAC,wCAAoB,IAAI;AAAA,MACjC,SAAS,CAAC,wCAAoB,IAAI;AAAA,MAClC,YAAY;AAAA,YACX,qCAAgB;AAAA,UACf,eAAe;AAAA,QAChB,CAAC;AAAA,QACD;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,UACb,UAAU;AAAA,UACV,aAAa;AAAA,QACd;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;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AAC;AACD;AAAA,UACD;AAEA,cAAI,oBAAoB,YAAY,SAAS,WAAW,YAAY,SAAS,UAAU;AACtF,mBAAO,QAAQ,WAAW,EAAE,IAAI,MAAM,KAAK,QAAQ;AAAA,cAClD,OAAO,KAAK,YAAY,MAAM,QAAQ;AAAA,cACtC;AAAA,cACA,YAAY;AAAA,YACb;AACA;AACA;AAAA,UACD;AAEA,kBAAQ,KAAK,WAA0B;AAAA,QACxC;AAEA,mBAAW,KAAK;AAAA,UACf,MAAM;AAAA,YACL,SAAS,QAAQ,SAAS,IAAI,UAAU;AAAA,UACzC;AAAA,UACA,QAAQ,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS;AAAA,UAClD,YAAY;AAAA,YACX,MAAM;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/mcp/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/mcp/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"]}
|
|
@@ -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/mcp/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,QAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM,QAAW;AACjE,aAAO,OAAO,MAAM,CAAC;AAAA,IACtB;AAEA,QAAI,MAAM,QAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM,QAAW;AACjE,aAAO,OAAO,MAAM,CAAC;AAAA,IACtB;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,gBACR,GACA,GACoC;AACpC,MAAI,MAAM,QAAW;AACpB,WAAO;AAAA,EACR;AAEA,MAAI,MAAM,QAAW;AACpB,WAAO;AAAA,EACR;A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ACR;AAEO,SAAS,wCACf,QACwB;AACxB,QAAM,SAAgC,CAAC;AACvC,MAAI,OAAO,SAAS,YAAY,CAAC,OAAO,YAAY;AACnD,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,MAAM,QAAQ,OAAO,QAAQ,IAAI,OAAO,WAAW,CAAC;AACrE,aAAW,CAAC,KAAK,cAAc,KAAK,OAAO,QAAQ,OAAO,UAAU,GAAG;AACtE,QAAI,mBAAmB,OAAO;AAC7B;AAAA,IACD;AAEA,QAAI,mBAAmB,MAAM;AAC5B,aAAO,KAAK;AAAA,QACX,IAAI;AAAA,QACJ,aAAa;AAAA,QACb,cAAc;AAAA,QACd,UAAU,SAAS,SAAS,GAAG;AAAA,QAC/B,SAAS;AAAA,QACT,MAAM;AAAA;AAAA,MACP,CAAC;AACD;AAAA,IACD;AAEA,UAAM,aAAa,0BAA0B,cAAc;AAC3D,QAAI;AACJ,QAAI,eAAe,YAAY,eAAe,SAAS;AACtD,YAAM,SAAS,6BAA6B,cAAc;AAC1D,UAAI,WAAW,MAAM;AACpB,uBAAe,KAAK,UAAU,QAAQ,MAAM,CAAC;AAAA,MAC9C;AAAA,IACD;AAEA,UAAM,QAA6B;AAAA,MAClC,IAAI;AAAA,MACJ,aAAa,eAAe,SAAS;AAAA,MACrC,cAAc;AAAA,MACd,UAAU,SAAS,SAAS,GAAG;AAAA,MAC/B,SAAS;AAAA,MACT,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":[]}
|
|
@@ -25,9 +25,10 @@ var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
26
|
var import_logWrapper = require("../../../utils/logWrapper");
|
|
27
27
|
var import_sharedFields = require("../../../utils/sharedFields");
|
|
28
|
-
var import_descriptions = require("./descriptions");
|
|
29
28
|
var import_loadOptions = require("./loadOptions");
|
|
30
29
|
var import_utils = require("./utils");
|
|
30
|
+
var import_descriptions = require("../shared/descriptions");
|
|
31
|
+
var import_utils2 = require("../shared/utils");
|
|
31
32
|
function getNodeConfig(ctx, itemIndex) {
|
|
32
33
|
const node = ctx.getNode();
|
|
33
34
|
const authentication = ctx.getNodeParameter(
|
|
@@ -59,19 +60,19 @@ function getNodeConfig(ctx, itemIndex) {
|
|
|
59
60
|
}
|
|
60
61
|
async function connectAndGetTools(ctx, config) {
|
|
61
62
|
const node = ctx.getNode();
|
|
62
|
-
const { headers } = await (0,
|
|
63
|
-
const client = await (0,
|
|
63
|
+
const { headers } = await (0, import_utils2.getAuthHeaders)(ctx, config.authentication);
|
|
64
|
+
const client = await (0, import_utils2.connectMcpClient)({
|
|
64
65
|
serverTransport: config.serverTransport,
|
|
65
66
|
endpointUrl: config.endpointUrl,
|
|
66
67
|
headers,
|
|
67
68
|
name: node.type,
|
|
68
69
|
version: node.typeVersion,
|
|
69
|
-
onUnauthorized: async (headers2) => await (0,
|
|
70
|
+
onUnauthorized: async (headers2) => await (0, import_utils2.tryRefreshOAuth2Token)(ctx, config.authentication, headers2)
|
|
70
71
|
});
|
|
71
72
|
if (!client.ok) {
|
|
72
73
|
return { client, mcpTools: null, error: client.error };
|
|
73
74
|
}
|
|
74
|
-
const allTools = await (0,
|
|
75
|
+
const allTools = await (0, import_utils2.getAllTools)(client.result);
|
|
75
76
|
const mcpTools = (0, import_utils.getSelectedTools)({
|
|
76
77
|
tools: allTools,
|
|
77
78
|
mode: config.mode,
|
|
@@ -111,45 +112,7 @@ class McpClientTool {
|
|
|
111
112
|
},
|
|
112
113
|
inputs: [],
|
|
113
114
|
outputs: [{ type: import_n8n_workflow.NodeConnectionTypes.AiTool, displayName: "Tools" }],
|
|
114
|
-
credentials:
|
|
115
|
-
{
|
|
116
|
-
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
|
|
117
|
-
name: "httpBearerAuth",
|
|
118
|
-
required: true,
|
|
119
|
-
displayOptions: {
|
|
120
|
-
show: {
|
|
121
|
-
authentication: ["bearerAuth"]
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: "httpHeaderAuth",
|
|
127
|
-
required: true,
|
|
128
|
-
displayOptions: {
|
|
129
|
-
show: {
|
|
130
|
-
authentication: ["headerAuth"]
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: "httpMultipleHeadersAuth",
|
|
136
|
-
required: true,
|
|
137
|
-
displayOptions: {
|
|
138
|
-
show: {
|
|
139
|
-
authentication: ["multipleHeadersAuth"]
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: "mcpOAuth2Api",
|
|
145
|
-
required: true,
|
|
146
|
-
displayOptions: {
|
|
147
|
-
show: {
|
|
148
|
-
authentication: ["mcpOAuth2Api"]
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
],
|
|
115
|
+
credentials: import_descriptions.credentials,
|
|
153
116
|
properties: [
|
|
154
117
|
(0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiAgent]),
|
|
155
118
|
{
|
|
@@ -353,27 +316,22 @@ class McpClientTool {
|
|
|
353
316
|
async supplyData(itemIndex) {
|
|
354
317
|
const node = this.getNode();
|
|
355
318
|
const config = getNodeConfig(this, itemIndex);
|
|
356
|
-
const setError = (
|
|
357
|
-
const error2 = new import_n8n_workflow.NodeOperationError(node, message, { itemIndex, description });
|
|
319
|
+
const setError = (error2) => {
|
|
358
320
|
this.addOutputData(import_n8n_workflow.NodeConnectionTypes.AiTool, itemIndex, error2);
|
|
359
321
|
throw error2;
|
|
360
322
|
};
|
|
361
323
|
const { client, mcpTools, error } = await connectAndGetTools(this, config);
|
|
362
324
|
if (error) {
|
|
363
325
|
this.logger.error("McpClientTool: Failed to connect to MCP Server", { error });
|
|
364
|
-
|
|
365
|
-
case "invalid_url":
|
|
366
|
-
return setError("Could not connect to your MCP server. The provided URL is invalid.");
|
|
367
|
-
case "connection":
|
|
368
|
-
default:
|
|
369
|
-
return setError("Could not connect to your MCP server");
|
|
370
|
-
}
|
|
326
|
+
return setError((0, import_utils2.mapToNodeOperationError)(node, error));
|
|
371
327
|
}
|
|
372
328
|
this.logger.debug("McpClientTool: Successfully connected to MCP Server");
|
|
373
329
|
if (!mcpTools?.length) {
|
|
374
330
|
return setError(
|
|
375
|
-
"MCP Server returned no tools",
|
|
376
|
-
|
|
331
|
+
new import_n8n_workflow.NodeOperationError(node, "MCP Server returned no tools", {
|
|
332
|
+
itemIndex,
|
|
333
|
+
description: "Connected successfully to your MCP server but it returned an empty list of tools."
|
|
334
|
+
})
|
|
377
335
|
);
|
|
378
336
|
}
|
|
379
337
|
const tools = mcpTools.map(
|