@couleetech/n8n-nodes-enlightenedmsp 0.0.1
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/README.md +124 -0
 - package/dist/credentials/BraveSearchApi.credentials.d.ts +9 -0
 - package/dist/credentials/BraveSearchApi.credentials.js +47 -0
 - package/dist/credentials/BraveSearchApi.credentials.js.map +1 -0
 - package/dist/credentials/EnlightenedMspApi.credentials.d.ts +8 -0
 - package/dist/credentials/EnlightenedMspApi.credentials.js +30 -0
 - package/dist/credentials/EnlightenedMspNats.credentials.d.ts +7 -0
 - package/dist/credentials/EnlightenedMspNats.credentials.js +47 -0
 - package/dist/credentials/McpClientApi.credentials.d.ts +7 -0
 - package/dist/credentials/McpClientApi.credentials.js +29 -0
 - package/dist/nodes/BraveSearch/BraveSearch.node.d.ts +5 -0
 - package/dist/nodes/BraveSearch/BraveSearch.node.js +213 -0
 - package/dist/nodes/BraveSearch/BraveSearch.node.js.map +1 -0
 - package/dist/nodes/BraveSearch/brave-logo-sans-text.svg +1 -0
 - package/dist/nodes/BraveSearch/types.d.ts +21 -0
 - package/dist/nodes/BraveSearch/types.js +2 -0
 - package/dist/nodes/BraveSearch/types.js.map +1 -0
 - package/dist/nodes/BraveSearchTool/BraveSearchTool.node.d.ts +7 -0
 - package/dist/nodes/BraveSearchTool/BraveSearchTool.node.js +208 -0
 - package/dist/nodes/BraveSearchTool/brave-logo-sans-text.svg +1 -0
 - package/dist/nodes/EnlightenedMsp/McpClient.node.d.ts +5 -0
 - package/dist/nodes/EnlightenedMsp/McpClient.node.js +95 -0
 - package/dist/nodes/EnlightenedMsp/TicketCreated.node.d.ts +5 -0
 - package/dist/nodes/EnlightenedMsp/TicketCreated.node.js +104 -0
 - package/dist/nodes/EnlightenedMsp/index.d.ts +2 -0
 - package/dist/nodes/EnlightenedMsp/index.js +5 -0
 - package/dist/nodes/EnlightenedMsp/mcpClient.svg +7 -0
 - package/dist/nodes/McpClient/McpClient.node.d.ts +5 -0
 - package/dist/nodes/McpClient/McpClient.node.js +95 -0
 - package/dist/nodes/McpClient/mcpClient.svg +7 -0
 - package/dist/nodes/NpmSearch/NpmSearch.node.d.ts +5 -0
 - package/dist/nodes/NpmSearch/NpmSearch.node.js +94 -0
 - package/dist/nodes/NpmSearch/npm.svg +5 -0
 - package/package.json +77 -0
 
| 
         @@ -0,0 +1,208 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            var __importDefault = (this && this.__importDefault) || function (mod) {
         
     | 
| 
      
 3 
     | 
    
         
            +
                return (mod && mod.__esModule) ? mod : { "default": mod };
         
     | 
| 
      
 4 
     | 
    
         
            +
            };
         
     | 
| 
      
 5 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 6 
     | 
    
         
            +
            exports.BraveSearchTool = void 0;
         
     | 
| 
      
 7 
     | 
    
         
            +
            const n8n_workflow_1 = require("n8n-workflow");
         
     | 
| 
      
 8 
     | 
    
         
            +
            const axios_1 = __importDefault(require("axios"));
         
     | 
| 
      
 9 
     | 
    
         
            +
            class BraveSearchTool {
         
     | 
| 
      
 10 
     | 
    
         
            +
                constructor() {
         
     | 
| 
      
 11 
     | 
    
         
            +
                    this.description = {
         
     | 
| 
      
 12 
     | 
    
         
            +
                        displayName: 'Brave Search Tool',
         
     | 
| 
      
 13 
     | 
    
         
            +
                        name: 'braveSearchTool',
         
     | 
| 
      
 14 
     | 
    
         
            +
                        icon: 'file:brave-logo-sans-text.svg',
         
     | 
| 
      
 15 
     | 
    
         
            +
                        group: ['transform', 'output'],
         
     | 
| 
      
 16 
     | 
    
         
            +
                        version: 1,
         
     | 
| 
      
 17 
     | 
    
         
            +
                        subtitle: '={{$parameter["operation"]}}',
         
     | 
| 
      
 18 
     | 
    
         
            +
                        description: 'Make requests to Brave Search API',
         
     | 
| 
      
 19 
     | 
    
         
            +
                        defaults: {
         
     | 
| 
      
 20 
     | 
    
         
            +
                            name: 'Brave Search Tool',
         
     | 
| 
      
 21 
     | 
    
         
            +
                        },
         
     | 
| 
      
 22 
     | 
    
         
            +
                        inputs: ["main"],
         
     | 
| 
      
 23 
     | 
    
         
            +
                        outputs: ["main"],
         
     | 
| 
      
 24 
     | 
    
         
            +
                        usableAsTool: true,
         
     | 
| 
      
 25 
     | 
    
         
            +
                        credentials: [
         
     | 
| 
      
 26 
     | 
    
         
            +
                            {
         
     | 
| 
      
 27 
     | 
    
         
            +
                                name: 'braveSearchApi',
         
     | 
| 
      
 28 
     | 
    
         
            +
                                required: true,
         
     | 
| 
      
 29 
     | 
    
         
            +
                            },
         
     | 
| 
      
 30 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 31 
     | 
    
         
            +
                        properties: [
         
     | 
| 
      
 32 
     | 
    
         
            +
                            {
         
     | 
| 
      
 33 
     | 
    
         
            +
                                displayName: 'Operation',
         
     | 
| 
      
 34 
     | 
    
         
            +
                                name: 'operation',
         
     | 
| 
      
 35 
     | 
    
         
            +
                                type: 'options',
         
     | 
| 
      
 36 
     | 
    
         
            +
                                noDataExpression: true,
         
     | 
| 
      
 37 
     | 
    
         
            +
                                options: [
         
     | 
| 
      
 38 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 39 
     | 
    
         
            +
                                        name: 'Web Search',
         
     | 
| 
      
 40 
     | 
    
         
            +
                                        value: 'webSearch',
         
     | 
| 
      
 41 
     | 
    
         
            +
                                        description: 'Perform a web search',
         
     | 
| 
      
 42 
     | 
    
         
            +
                                        action: 'Perform a web search',
         
     | 
| 
      
 43 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 44 
     | 
    
         
            +
                                ],
         
     | 
| 
      
 45 
     | 
    
         
            +
                                default: 'webSearch',
         
     | 
| 
      
 46 
     | 
    
         
            +
                            },
         
     | 
| 
      
 47 
     | 
    
         
            +
                            {
         
     | 
| 
      
 48 
     | 
    
         
            +
                                displayName: 'Query',
         
     | 
| 
      
 49 
     | 
    
         
            +
                                name: 'query',
         
     | 
| 
      
 50 
     | 
    
         
            +
                                type: 'string',
         
     | 
| 
      
 51 
     | 
    
         
            +
                                default: '',
         
     | 
| 
      
 52 
     | 
    
         
            +
                                required: true,
         
     | 
| 
      
 53 
     | 
    
         
            +
                                displayOptions: {
         
     | 
| 
      
 54 
     | 
    
         
            +
                                    show: {
         
     | 
| 
      
 55 
     | 
    
         
            +
                                        operation: ['webSearch'],
         
     | 
| 
      
 56 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 57 
     | 
    
         
            +
                                },
         
     | 
| 
      
 58 
     | 
    
         
            +
                                description: 'The search query to execute',
         
     | 
| 
      
 59 
     | 
    
         
            +
                            },
         
     | 
| 
      
 60 
     | 
    
         
            +
                            {
         
     | 
| 
      
 61 
     | 
    
         
            +
                                displayName: 'Additional Fields',
         
     | 
| 
      
 62 
     | 
    
         
            +
                                name: 'additionalFields',
         
     | 
| 
      
 63 
     | 
    
         
            +
                                type: 'collection',
         
     | 
| 
      
 64 
     | 
    
         
            +
                                placeholder: 'Add Field',
         
     | 
| 
      
 65 
     | 
    
         
            +
                                default: {},
         
     | 
| 
      
 66 
     | 
    
         
            +
                                displayOptions: {
         
     | 
| 
      
 67 
     | 
    
         
            +
                                    show: {
         
     | 
| 
      
 68 
     | 
    
         
            +
                                        operation: ['webSearch'],
         
     | 
| 
      
 69 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 70 
     | 
    
         
            +
                                },
         
     | 
| 
      
 71 
     | 
    
         
            +
                                options: [
         
     | 
| 
      
 72 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 73 
     | 
    
         
            +
                                        displayName: 'Country',
         
     | 
| 
      
 74 
     | 
    
         
            +
                                        name: 'country',
         
     | 
| 
      
 75 
     | 
    
         
            +
                                        type: 'string',
         
     | 
| 
      
 76 
     | 
    
         
            +
                                        default: '',
         
     | 
| 
      
 77 
     | 
    
         
            +
                                        description: 'Country code for search results (e.g., US, GB)',
         
     | 
| 
      
 78 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 79 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 80 
     | 
    
         
            +
                                        displayName: 'Results Count',
         
     | 
| 
      
 81 
     | 
    
         
            +
                                        name: 'count',
         
     | 
| 
      
 82 
     | 
    
         
            +
                                        type: 'number',
         
     | 
| 
      
 83 
     | 
    
         
            +
                                        typeOptions: {
         
     | 
| 
      
 84 
     | 
    
         
            +
                                            minValue: 1,
         
     | 
| 
      
 85 
     | 
    
         
            +
                                            maxValue: 20,
         
     | 
| 
      
 86 
     | 
    
         
            +
                                        },
         
     | 
| 
      
 87 
     | 
    
         
            +
                                        default: 10,
         
     | 
| 
      
 88 
     | 
    
         
            +
                                        description: 'Number of results to return (max: 20)',
         
     | 
| 
      
 89 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 90 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 91 
     | 
    
         
            +
                                        displayName: 'Offset',
         
     | 
| 
      
 92 
     | 
    
         
            +
                                        name: 'offset',
         
     | 
| 
      
 93 
     | 
    
         
            +
                                        type: 'number',
         
     | 
| 
      
 94 
     | 
    
         
            +
                                        typeOptions: {
         
     | 
| 
      
 95 
     | 
    
         
            +
                                            minValue: 0,
         
     | 
| 
      
 96 
     | 
    
         
            +
                                        },
         
     | 
| 
      
 97 
     | 
    
         
            +
                                        default: 0,
         
     | 
| 
      
 98 
     | 
    
         
            +
                                        description: 'Offset for pagination',
         
     | 
| 
      
 99 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 100 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 101 
     | 
    
         
            +
                                        displayName: 'Safe Search',
         
     | 
| 
      
 102 
     | 
    
         
            +
                                        name: 'safesearch',
         
     | 
| 
      
 103 
     | 
    
         
            +
                                        type: 'options',
         
     | 
| 
      
 104 
     | 
    
         
            +
                                        options: [
         
     | 
| 
      
 105 
     | 
    
         
            +
                                            {
         
     | 
| 
      
 106 
     | 
    
         
            +
                                                name: 'Strict',
         
     | 
| 
      
 107 
     | 
    
         
            +
                                                value: 'strict',
         
     | 
| 
      
 108 
     | 
    
         
            +
                                            },
         
     | 
| 
      
 109 
     | 
    
         
            +
                                            {
         
     | 
| 
      
 110 
     | 
    
         
            +
                                                name: 'Moderate',
         
     | 
| 
      
 111 
     | 
    
         
            +
                                                value: 'moderate',
         
     | 
| 
      
 112 
     | 
    
         
            +
                                            },
         
     | 
| 
      
 113 
     | 
    
         
            +
                                            {
         
     | 
| 
      
 114 
     | 
    
         
            +
                                                name: 'Off',
         
     | 
| 
      
 115 
     | 
    
         
            +
                                                value: 'off',
         
     | 
| 
      
 116 
     | 
    
         
            +
                                            },
         
     | 
| 
      
 117 
     | 
    
         
            +
                                        ],
         
     | 
| 
      
 118 
     | 
    
         
            +
                                        default: 'moderate',
         
     | 
| 
      
 119 
     | 
    
         
            +
                                        description: 'Safe search setting',
         
     | 
| 
      
 120 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 121 
     | 
    
         
            +
                                ],
         
     | 
| 
      
 122 
     | 
    
         
            +
                            },
         
     | 
| 
      
 123 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 124 
     | 
    
         
            +
                    };
         
     | 
| 
      
 125 
     | 
    
         
            +
                }
         
     | 
| 
      
 126 
     | 
    
         
            +
                async execute() {
         
     | 
| 
      
 127 
     | 
    
         
            +
                    var _a, _b, _c, _d, _e;
         
     | 
| 
      
 128 
     | 
    
         
            +
                    const items = this.getInputData();
         
     | 
| 
      
 129 
     | 
    
         
            +
                    const returnData = [];
         
     | 
| 
      
 130 
     | 
    
         
            +
                    let query = '';
         
     | 
| 
      
 131 
     | 
    
         
            +
                    let params;
         
     | 
| 
      
 132 
     | 
    
         
            +
                    for (let i = 0; i < items.length; i++) {
         
     | 
| 
      
 133 
     | 
    
         
            +
                        try {
         
     | 
| 
      
 134 
     | 
    
         
            +
                            const operation = this.getNodeParameter('operation', i);
         
     | 
| 
      
 135 
     | 
    
         
            +
                            if (operation === 'webSearch') {
         
     | 
| 
      
 136 
     | 
    
         
            +
                                query = this.getNodeParameter('query', i);
         
     | 
| 
      
 137 
     | 
    
         
            +
                                const additionalFields = this.getNodeParameter('additionalFields', i);
         
     | 
| 
      
 138 
     | 
    
         
            +
                                const credentials = await this.getCredentials('braveSearchApi');
         
     | 
| 
      
 139 
     | 
    
         
            +
                                if (!(credentials === null || credentials === void 0 ? void 0 : credentials.apiKey)) {
         
     | 
| 
      
 140 
     | 
    
         
            +
                                    throw new Error('No API key provided in credentials');
         
     | 
| 
      
 141 
     | 
    
         
            +
                                }
         
     | 
| 
      
 142 
     | 
    
         
            +
                                params = {
         
     | 
| 
      
 143 
     | 
    
         
            +
                                    q: query,
         
     | 
| 
      
 144 
     | 
    
         
            +
                                    ...additionalFields,
         
     | 
| 
      
 145 
     | 
    
         
            +
                                };
         
     | 
| 
      
 146 
     | 
    
         
            +
                                try {
         
     | 
| 
      
 147 
     | 
    
         
            +
                                    const response = await axios_1.default.get('https://api.search.brave.com/res/v1/web/search', {
         
     | 
| 
      
 148 
     | 
    
         
            +
                                        params,
         
     | 
| 
      
 149 
     | 
    
         
            +
                                        headers: {
         
     | 
| 
      
 150 
     | 
    
         
            +
                                            'X-Subscription-Token': credentials.apiKey,
         
     | 
| 
      
 151 
     | 
    
         
            +
                                            'Accept': 'application/json',
         
     | 
| 
      
 152 
     | 
    
         
            +
                                        },
         
     | 
| 
      
 153 
     | 
    
         
            +
                                    });
         
     | 
| 
      
 154 
     | 
    
         
            +
                                    if (!response.data) {
         
     | 
| 
      
 155 
     | 
    
         
            +
                                        throw new Error('Empty response from Brave Search API');
         
     | 
| 
      
 156 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 157 
     | 
    
         
            +
                                    if (!response.data.web || !Array.isArray(response.data.web.results)) {
         
     | 
| 
      
 158 
     | 
    
         
            +
                                        throw new Error(`Invalid response structure. Got: ${JSON.stringify(response.data)}`);
         
     | 
| 
      
 159 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 160 
     | 
    
         
            +
                                    const responseData = {
         
     | 
| 
      
 161 
     | 
    
         
            +
                                        ...response.data,
         
     | 
| 
      
 162 
     | 
    
         
            +
                                        web: {
         
     | 
| 
      
 163 
     | 
    
         
            +
                                            ...(response.data.web || {}),
         
     | 
| 
      
 164 
     | 
    
         
            +
                                            results: response.data.web.results.map((result) => ({
         
     | 
| 
      
 165 
     | 
    
         
            +
                                                ...result,
         
     | 
| 
      
 166 
     | 
    
         
            +
                                                title: result.title || '',
         
     | 
| 
      
 167 
     | 
    
         
            +
                                                url: result.url || '',
         
     | 
| 
      
 168 
     | 
    
         
            +
                                                description: result.description || ''
         
     | 
| 
      
 169 
     | 
    
         
            +
                                            }))
         
     | 
| 
      
 170 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 171 
     | 
    
         
            +
                                    };
         
     | 
| 
      
 172 
     | 
    
         
            +
                                    const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
         
     | 
| 
      
 173 
     | 
    
         
            +
                                    returnData.push(...executionData);
         
     | 
| 
      
 174 
     | 
    
         
            +
                                }
         
     | 
| 
      
 175 
     | 
    
         
            +
                                catch (error) {
         
     | 
| 
      
 176 
     | 
    
         
            +
                                    if (axios_1.default.isAxiosError(error)) {
         
     | 
| 
      
 177 
     | 
    
         
            +
                                        throw new Error(`API Request failed: ${error.message}. ` +
         
     | 
| 
      
 178 
     | 
    
         
            +
                                            `Status: ${(_a = error.response) === null || _a === void 0 ? void 0 : _a.status}. ` +
         
     | 
| 
      
 179 
     | 
    
         
            +
                                            `Response: ${JSON.stringify((_b = error.response) === null || _b === void 0 ? void 0 : _b.data)}`);
         
     | 
| 
      
 180 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 181 
     | 
    
         
            +
                                    throw error;
         
     | 
| 
      
 182 
     | 
    
         
            +
                                }
         
     | 
| 
      
 183 
     | 
    
         
            +
                            }
         
     | 
| 
      
 184 
     | 
    
         
            +
                        }
         
     | 
| 
      
 185 
     | 
    
         
            +
                        catch (error) {
         
     | 
| 
      
 186 
     | 
    
         
            +
                            if (this.continueOnFail()) {
         
     | 
| 
      
 187 
     | 
    
         
            +
                                const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({
         
     | 
| 
      
 188 
     | 
    
         
            +
                                    error: error.message,
         
     | 
| 
      
 189 
     | 
    
         
            +
                                    details: ((_c = error.response) === null || _c === void 0 ? void 0 : _c.data) || 'No additional error details available',
         
     | 
| 
      
 190 
     | 
    
         
            +
                                    status: ((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) || 'Unknown status',
         
     | 
| 
      
 191 
     | 
    
         
            +
                                    query: query || 'No query provided',
         
     | 
| 
      
 192 
     | 
    
         
            +
                                    params: params || 'No params available'
         
     | 
| 
      
 193 
     | 
    
         
            +
                                }), { itemData: { item: i } });
         
     | 
| 
      
 194 
     | 
    
         
            +
                                returnData.push(...executionErrorData);
         
     | 
| 
      
 195 
     | 
    
         
            +
                                continue;
         
     | 
| 
      
 196 
     | 
    
         
            +
                            }
         
     | 
| 
      
 197 
     | 
    
         
            +
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Execution failed: ${error.message}`, {
         
     | 
| 
      
 198 
     | 
    
         
            +
                                description: ((_e = error.response) === null || _e === void 0 ? void 0 : _e.data)
         
     | 
| 
      
 199 
     | 
    
         
            +
                                    ? `API Response: ${JSON.stringify(error.response.data)}`
         
     | 
| 
      
 200 
     | 
    
         
            +
                                    : undefined,
         
     | 
| 
      
 201 
     | 
    
         
            +
                                itemIndex: i,
         
     | 
| 
      
 202 
     | 
    
         
            +
                            });
         
     | 
| 
      
 203 
     | 
    
         
            +
                        }
         
     | 
| 
      
 204 
     | 
    
         
            +
                    }
         
     | 
| 
      
 205 
     | 
    
         
            +
                    return [returnData];
         
     | 
| 
      
 206 
     | 
    
         
            +
                }
         
     | 
| 
      
 207 
     | 
    
         
            +
            }
         
     | 
| 
      
 208 
     | 
    
         
            +
            exports.BraveSearchTool = BraveSearchTool;
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <svg width="56" height="64" viewBox="0 0 56 64" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M53.292 15.321l1.5-3.676s-1.909-2.043-4.227-4.358c-2.317-2.315-7.225-.953-7.225-.953L37.751 0H18.12l-5.589 6.334s-4.908-1.362-7.225.953C2.988 9.602 1.08 11.645 1.08 11.645l1.5 3.676-1.91 5.447s5.614 21.236 6.272 23.83c1.295 5.106 2.181 7.08 5.862 9.668 3.68 2.587 10.36 7.08 11.45 7.762 1.091.68 2.455 1.84 3.682 1.84 1.227 0 2.59-1.16 3.68-1.84 1.091-.681 7.77-5.175 11.452-7.762 3.68-2.587 4.567-4.562 5.862-9.668.657-2.594 6.27-23.83 6.27-23.83l-1.908-5.447z" fill="url(#paint0_linear)"/><path fill-rule="evenodd" clip-rule="evenodd" d="M34.888 11.508c.818 0 6.885-1.157 6.885-1.157s7.189 8.68 7.189 10.536c0 1.534-.619 2.134-1.347 2.842-.152.148-.31.3-.467.468l-5.39 5.717a9.42 9.42 0 01-.176.18c-.538.54-1.33 1.336-.772 2.658l.115.269c.613 1.432 1.37 3.2.407 4.99-1.025 1.906-2.78 3.178-3.905 2.967-1.124-.21-3.766-1.589-4.737-2.218-.971-.63-4.05-3.166-4.05-4.137 0-.809 2.214-2.155 3.29-2.81.214-.13.383-.232.48-.298.111-.075.297-.19.526-.332.981-.61 2.754-1.71 2.799-2.197.055-.602.034-.778-.758-2.264-.168-.316-.365-.654-.568-1.004-.754-1.295-1.598-2.745-1.41-3.784.21-1.173 2.05-1.845 3.608-2.415.194-.07.385-.14.567-.209l1.623-.609c1.556-.582 3.284-1.229 3.57-1.36.394-.181.292-.355-.903-.468a54.655 54.655 0 01-.58-.06c-1.48-.157-4.209-.446-5.535-.077-.261.073-.553.152-.86.235-1.49.403-3.317.897-3.493 1.182-.03.05-.06.093-.089.133-.168.238-.277.394-.091 1.406.055.302.169.895.31 1.629.41 2.148 1.053 5.498 1.134 6.25.011.106.024.207.036.305.103.84.171 1.399-.805 1.622l-.255.058c-1.102.252-2.717.623-3.3.623-.584 0-2.2-.37-3.302-.623l-.254-.058c-.976-.223-.907-.782-.804-1.622.012-.098.024-.2.035-.305.081-.753.725-4.112 1.137-6.259.14-.73.253-1.32.308-1.62.185-1.012.076-1.168-.092-1.406a3.743 3.743 0 01-.09-.133c-.174-.285-2-.779-3.491-1.182-.307-.083-.6-.162-.86-.235-1.327-.37-4.055-.08-5.535.077-.226.024-.422.045-.58.06-1.196.113-1.297.287-.903.468.285.131 2.013.778 3.568 1.36.597.223 1.17.437 1.624.609.183.069.373.138.568.21 1.558.57 3.398 1.241 3.608 2.414.187 1.039-.657 2.489-1.41 3.784-.204.35-.4.688-.569 1.004-.791 1.486-.812 1.662-.757 2.264.044.488 1.816 1.587 2.798 2.197.229.142.415.257.526.332.098.066.266.168.48.298 1.076.654 3.29 2 3.29 2.81 0 .97-3.078 3.507-4.05 4.137-.97.63-3.612 2.008-4.737 2.218-1.124.21-2.88-1.061-3.904-2.966-.963-1.791-.207-3.559.406-4.99l.115-.27c.559-1.322-.233-2.118-.772-2.658a9.377 9.377 0 01-.175-.18l-5.39-5.717c-.158-.167-.316-.32-.468-.468-.728-.707-1.346-1.308-1.346-2.842 0-1.855 7.189-10.536 7.189-10.536s6.066 1.157 6.884 1.157c.653 0 1.913-.433 3.227-.885.333-.114.669-.23 1-.34 1.635-.545 2.726-.549 2.726-.549s1.09.004 2.726.549c.33.11.667.226 1 .34 1.313.452 2.574.885 3.226.885zm-1.041 30.706c1.282.66 2.192 1.128 2.536 1.343.445.278.174.803-.232 1.09-.405.285-5.853 4.499-6.381 4.965l-.215.191c-.509.459-1.159 1.044-1.62 1.044-.46 0-1.11-.586-1.62-1.044l-.213-.191c-.53-.466-5.977-4.68-6.382-4.966-.405-.286-.677-.81-.232-1.09.344-.214 1.255-.683 2.539-1.344l1.22-.629c1.92-.992 4.315-1.837 4.689-1.837.373 0 2.767.844 4.689 1.837.436.226.845.437 1.222.63z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M43.34 6.334L37.751 0H18.12l-5.589 6.334s-4.908-1.362-7.225.953c0 0 6.544-.59 8.793 3.064 0 0 6.066 1.157 6.884 1.157.818 0 2.59-.68 4.226-1.225 1.636-.545 2.727-.549 2.727-.549s1.09.004 2.726.549 3.408 1.225 4.226 1.225c.818 0 6.885-1.157 6.885-1.157 2.249-3.654 8.792-3.064 8.792-3.064-2.317-2.315-7.225-.953-7.225-.953z" fill="url(#paint1_linear)"/><defs><linearGradient id="paint0_linear" x1=".671" y1="64.319" x2="55.2" y2="64.319" gradientUnits="userSpaceOnUse"><stop stop-color="#F50"/><stop offset=".41" stop-color="#F50"/><stop offset=".582" stop-color="#FF2000"/><stop offset="1" stop-color="#FF2000"/></linearGradient><linearGradient id="paint1_linear" x1="6.278" y1="11.466" x2="50.565" y2="11.466" gradientUnits="userSpaceOnUse"><stop stop-color="#FF452A"/><stop offset="1" stop-color="#FF2000"/></linearGradient></defs></svg>
         
     | 
| 
         @@ -0,0 +1,95 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 3 
     | 
    
         
            +
            exports.McpClient = void 0;
         
     | 
| 
      
 4 
     | 
    
         
            +
            const n8n_workflow_1 = require("n8n-workflow");
         
     | 
| 
      
 5 
     | 
    
         
            +
            const child_process_1 = require("child_process");
         
     | 
| 
      
 6 
     | 
    
         
            +
            class McpClient {
         
     | 
| 
      
 7 
     | 
    
         
            +
                constructor() {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    this.description = {
         
     | 
| 
      
 9 
     | 
    
         
            +
                        displayName: 'MCP Client',
         
     | 
| 
      
 10 
     | 
    
         
            +
                        name: 'mcpClient',
         
     | 
| 
      
 11 
     | 
    
         
            +
                        icon: 'file:mcpClient.svg',
         
     | 
| 
      
 12 
     | 
    
         
            +
                        group: ['transform'],
         
     | 
| 
      
 13 
     | 
    
         
            +
                        version: 1,
         
     | 
| 
      
 14 
     | 
    
         
            +
                        description: 'Provide Model Context Protocol (MCP) tools to AI nodes',
         
     | 
| 
      
 15 
     | 
    
         
            +
                        defaults: {
         
     | 
| 
      
 16 
     | 
    
         
            +
                            name: 'MCP Client',
         
     | 
| 
      
 17 
     | 
    
         
            +
                        },
         
     | 
| 
      
 18 
     | 
    
         
            +
                        inputs: ['main'],
         
     | 
| 
      
 19 
     | 
    
         
            +
                        outputs: ["ai_tool"],
         
     | 
| 
      
 20 
     | 
    
         
            +
                        credentials: [
         
     | 
| 
      
 21 
     | 
    
         
            +
                            {
         
     | 
| 
      
 22 
     | 
    
         
            +
                                name: 'mcpClientApi',
         
     | 
| 
      
 23 
     | 
    
         
            +
                                required: true,
         
     | 
| 
      
 24 
     | 
    
         
            +
                            },
         
     | 
| 
      
 25 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 26 
     | 
    
         
            +
                        properties: [],
         
     | 
| 
      
 27 
     | 
    
         
            +
                    };
         
     | 
| 
      
 28 
     | 
    
         
            +
                }
         
     | 
| 
      
 29 
     | 
    
         
            +
                async execute() {
         
     | 
| 
      
 30 
     | 
    
         
            +
                    var _a;
         
     | 
| 
      
 31 
     | 
    
         
            +
                    const credentials = await this.getCredentials('mcpClientApi');
         
     | 
| 
      
 32 
     | 
    
         
            +
                    const command = credentials.command;
         
     | 
| 
      
 33 
     | 
    
         
            +
                    const args = credentials.args;
         
     | 
| 
      
 34 
     | 
    
         
            +
                    const executeMcpCommand = async (input) => {
         
     | 
| 
      
 35 
     | 
    
         
            +
                        return new Promise((resolve, reject) => {
         
     | 
| 
      
 36 
     | 
    
         
            +
                            const process = (0, child_process_1.spawn)(command, args);
         
     | 
| 
      
 37 
     | 
    
         
            +
                            let stdout = '';
         
     | 
| 
      
 38 
     | 
    
         
            +
                            let stderr = '';
         
     | 
| 
      
 39 
     | 
    
         
            +
                            process.stdin.write(JSON.stringify(input) + '\n');
         
     | 
| 
      
 40 
     | 
    
         
            +
                            process.stdin.end();
         
     | 
| 
      
 41 
     | 
    
         
            +
                            process.stdout.on('data', (data) => {
         
     | 
| 
      
 42 
     | 
    
         
            +
                                stdout += data.toString();
         
     | 
| 
      
 43 
     | 
    
         
            +
                            });
         
     | 
| 
      
 44 
     | 
    
         
            +
                            process.stderr.on('data', (data) => {
         
     | 
| 
      
 45 
     | 
    
         
            +
                                stderr += data.toString();
         
     | 
| 
      
 46 
     | 
    
         
            +
                            });
         
     | 
| 
      
 47 
     | 
    
         
            +
                            process.on('close', (code) => {
         
     | 
| 
      
 48 
     | 
    
         
            +
                                if (code !== 0) {
         
     | 
| 
      
 49 
     | 
    
         
            +
                                    reject(new Error(`Process exited with code ${code}: ${stderr}`));
         
     | 
| 
      
 50 
     | 
    
         
            +
                                    return;
         
     | 
| 
      
 51 
     | 
    
         
            +
                                }
         
     | 
| 
      
 52 
     | 
    
         
            +
                                try {
         
     | 
| 
      
 53 
     | 
    
         
            +
                                    const response = JSON.parse(stdout);
         
     | 
| 
      
 54 
     | 
    
         
            +
                                    resolve(response);
         
     | 
| 
      
 55 
     | 
    
         
            +
                                }
         
     | 
| 
      
 56 
     | 
    
         
            +
                                catch (error) {
         
     | 
| 
      
 57 
     | 
    
         
            +
                                    reject(new Error(`Failed to parse MCP response: ${error.message}`));
         
     | 
| 
      
 58 
     | 
    
         
            +
                                }
         
     | 
| 
      
 59 
     | 
    
         
            +
                            });
         
     | 
| 
      
 60 
     | 
    
         
            +
                            process.on('error', (error) => {
         
     | 
| 
      
 61 
     | 
    
         
            +
                                reject(error);
         
     | 
| 
      
 62 
     | 
    
         
            +
                            });
         
     | 
| 
      
 63 
     | 
    
         
            +
                        });
         
     | 
| 
      
 64 
     | 
    
         
            +
                    };
         
     | 
| 
      
 65 
     | 
    
         
            +
                    try {
         
     | 
| 
      
 66 
     | 
    
         
            +
                        const toolsResponse = await executeMcpCommand({
         
     | 
| 
      
 67 
     | 
    
         
            +
                            method: 'tools/list',
         
     | 
| 
      
 68 
     | 
    
         
            +
                            params: {},
         
     | 
| 
      
 69 
     | 
    
         
            +
                        });
         
     | 
| 
      
 70 
     | 
    
         
            +
                        const tools = ((_a = toolsResponse.result) === null || _a === void 0 ? void 0 : _a.tools) || [];
         
     | 
| 
      
 71 
     | 
    
         
            +
                        const aiTools = tools.map((tool) => ({
         
     | 
| 
      
 72 
     | 
    
         
            +
                            name: tool.name,
         
     | 
| 
      
 73 
     | 
    
         
            +
                            description: tool.description,
         
     | 
| 
      
 74 
     | 
    
         
            +
                            execute: async (params) => {
         
     | 
| 
      
 75 
     | 
    
         
            +
                                const response = await executeMcpCommand({
         
     | 
| 
      
 76 
     | 
    
         
            +
                                    method: 'tools/call',
         
     | 
| 
      
 77 
     | 
    
         
            +
                                    params: {
         
     | 
| 
      
 78 
     | 
    
         
            +
                                        name: tool.name,
         
     | 
| 
      
 79 
     | 
    
         
            +
                                        arguments: params,
         
     | 
| 
      
 80 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 81 
     | 
    
         
            +
                                });
         
     | 
| 
      
 82 
     | 
    
         
            +
                                if (response.error) {
         
     | 
| 
      
 83 
     | 
    
         
            +
                                    throw new Error(`Tool execution failed: ${response.error.message}`);
         
     | 
| 
      
 84 
     | 
    
         
            +
                                }
         
     | 
| 
      
 85 
     | 
    
         
            +
                                return response.result;
         
     | 
| 
      
 86 
     | 
    
         
            +
                            },
         
     | 
| 
      
 87 
     | 
    
         
            +
                        }));
         
     | 
| 
      
 88 
     | 
    
         
            +
                        return [[{ json: { tools: aiTools } }]];
         
     | 
| 
      
 89 
     | 
    
         
            +
                    }
         
     | 
| 
      
 90 
     | 
    
         
            +
                    catch (error) {
         
     | 
| 
      
 91 
     | 
    
         
            +
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
         
     | 
| 
      
 92 
     | 
    
         
            +
                    }
         
     | 
| 
      
 93 
     | 
    
         
            +
                }
         
     | 
| 
      
 94 
     | 
    
         
            +
            }
         
     | 
| 
      
 95 
     | 
    
         
            +
            exports.McpClient = McpClient;
         
     | 
| 
         @@ -0,0 +1,104 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
         
     | 
| 
      
 3 
     | 
    
         
            +
                if (k2 === undefined) k2 = k;
         
     | 
| 
      
 4 
     | 
    
         
            +
                var desc = Object.getOwnPropertyDescriptor(m, k);
         
     | 
| 
      
 5 
     | 
    
         
            +
                if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  desc = { enumerable: true, get: function() { return m[k]; } };
         
     | 
| 
      
 7 
     | 
    
         
            +
                }
         
     | 
| 
      
 8 
     | 
    
         
            +
                Object.defineProperty(o, k2, desc);
         
     | 
| 
      
 9 
     | 
    
         
            +
            }) : (function(o, m, k, k2) {
         
     | 
| 
      
 10 
     | 
    
         
            +
                if (k2 === undefined) k2 = k;
         
     | 
| 
      
 11 
     | 
    
         
            +
                o[k2] = m[k];
         
     | 
| 
      
 12 
     | 
    
         
            +
            }));
         
     | 
| 
      
 13 
     | 
    
         
            +
            var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
         
     | 
| 
      
 14 
     | 
    
         
            +
                Object.defineProperty(o, "default", { enumerable: true, value: v });
         
     | 
| 
      
 15 
     | 
    
         
            +
            }) : function(o, v) {
         
     | 
| 
      
 16 
     | 
    
         
            +
                o["default"] = v;
         
     | 
| 
      
 17 
     | 
    
         
            +
            });
         
     | 
| 
      
 18 
     | 
    
         
            +
            var __importStar = (this && this.__importStar) || function (mod) {
         
     | 
| 
      
 19 
     | 
    
         
            +
                if (mod && mod.__esModule) return mod;
         
     | 
| 
      
 20 
     | 
    
         
            +
                var result = {};
         
     | 
| 
      
 21 
     | 
    
         
            +
                if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
         
     | 
| 
      
 22 
     | 
    
         
            +
                __setModuleDefault(result, mod);
         
     | 
| 
      
 23 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 24 
     | 
    
         
            +
            };
         
     | 
| 
      
 25 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 26 
     | 
    
         
            +
            exports.TicketCreated = void 0;
         
     | 
| 
      
 27 
     | 
    
         
            +
            class TicketCreated {
         
     | 
| 
      
 28 
     | 
    
         
            +
                constructor() {
         
     | 
| 
      
 29 
     | 
    
         
            +
                    this.description = {
         
     | 
| 
      
 30 
     | 
    
         
            +
                        displayName: 'Ticket Created Trigger',
         
     | 
| 
      
 31 
     | 
    
         
            +
                        name: 'ticketCreated',
         
     | 
| 
      
 32 
     | 
    
         
            +
                        icon: 'file:enlightenedmsp.svg',
         
     | 
| 
      
 33 
     | 
    
         
            +
                        group: ['trigger'],
         
     | 
| 
      
 34 
     | 
    
         
            +
                        version: 1,
         
     | 
| 
      
 35 
     | 
    
         
            +
                        description: 'Triggers when a new ticket is created in EnlightenedMSP',
         
     | 
| 
      
 36 
     | 
    
         
            +
                        defaults: {
         
     | 
| 
      
 37 
     | 
    
         
            +
                            name: 'Ticket Created Trigger',
         
     | 
| 
      
 38 
     | 
    
         
            +
                        },
         
     | 
| 
      
 39 
     | 
    
         
            +
                        inputs: [],
         
     | 
| 
      
 40 
     | 
    
         
            +
                        outputs: ['main'],
         
     | 
| 
      
 41 
     | 
    
         
            +
                        credentials: [
         
     | 
| 
      
 42 
     | 
    
         
            +
                            {
         
     | 
| 
      
 43 
     | 
    
         
            +
                                name: 'enlightenedMspNats',
         
     | 
| 
      
 44 
     | 
    
         
            +
                                required: true,
         
     | 
| 
      
 45 
     | 
    
         
            +
                            },
         
     | 
| 
      
 46 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 47 
     | 
    
         
            +
                        properties: [
         
     | 
| 
      
 48 
     | 
    
         
            +
                            {
         
     | 
| 
      
 49 
     | 
    
         
            +
                                displayName: 'Namespace',
         
     | 
| 
      
 50 
     | 
    
         
            +
                                name: 'namespace',
         
     | 
| 
      
 51 
     | 
    
         
            +
                                type: 'string',
         
     | 
| 
      
 52 
     | 
    
         
            +
                                default: '',
         
     | 
| 
      
 53 
     | 
    
         
            +
                                required: true,
         
     | 
| 
      
 54 
     | 
    
         
            +
                                description: 'The namespace for the NATS event (e.g., "production", "staging")',
         
     | 
| 
      
 55 
     | 
    
         
            +
                            },
         
     | 
| 
      
 56 
     | 
    
         
            +
                            {
         
     | 
| 
      
 57 
     | 
    
         
            +
                                displayName: 'Queue Group',
         
     | 
| 
      
 58 
     | 
    
         
            +
                                name: 'queue',
         
     | 
| 
      
 59 
     | 
    
         
            +
                                type: 'string',
         
     | 
| 
      
 60 
     | 
    
         
            +
                                default: '',
         
     | 
| 
      
 61 
     | 
    
         
            +
                                required: false,
         
     | 
| 
      
 62 
     | 
    
         
            +
                                description: 'Optional queue group name for load balancing',
         
     | 
| 
      
 63 
     | 
    
         
            +
                            },
         
     | 
| 
      
 64 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 65 
     | 
    
         
            +
                    };
         
     | 
| 
      
 66 
     | 
    
         
            +
                }
         
     | 
| 
      
 67 
     | 
    
         
            +
                async trigger() {
         
     | 
| 
      
 68 
     | 
    
         
            +
                    const namespace = this.getNodeParameter('namespace');
         
     | 
| 
      
 69 
     | 
    
         
            +
                    const queue = this.getNodeParameter('queue');
         
     | 
| 
      
 70 
     | 
    
         
            +
                    const credentials = await this.getCredentials('enlightenedMspNats');
         
     | 
| 
      
 71 
     | 
    
         
            +
                    const { connect } = await Promise.resolve().then(() => __importStar(require('nats')));
         
     | 
| 
      
 72 
     | 
    
         
            +
                    const natsConnection = await connect({
         
     | 
| 
      
 73 
     | 
    
         
            +
                        servers: credentials.natsServer,
         
     | 
| 
      
 74 
     | 
    
         
            +
                        user: credentials.username,
         
     | 
| 
      
 75 
     | 
    
         
            +
                        pass: credentials.password,
         
     | 
| 
      
 76 
     | 
    
         
            +
                        token: credentials.token,
         
     | 
| 
      
 77 
     | 
    
         
            +
                    });
         
     | 
| 
      
 78 
     | 
    
         
            +
                    const subject = `${namespace}.core.ticket.created`;
         
     | 
| 
      
 79 
     | 
    
         
            +
                    const subscription = queue
         
     | 
| 
      
 80 
     | 
    
         
            +
                        ? natsConnection.subscribe(subject, { queue })
         
     | 
| 
      
 81 
     | 
    
         
            +
                        : natsConnection.subscribe(subject);
         
     | 
| 
      
 82 
     | 
    
         
            +
                    (async () => {
         
     | 
| 
      
 83 
     | 
    
         
            +
                        for await (const message of subscription) {
         
     | 
| 
      
 84 
     | 
    
         
            +
                            try {
         
     | 
| 
      
 85 
     | 
    
         
            +
                                const payload = JSON.parse(new TextDecoder().decode(message.data));
         
     | 
| 
      
 86 
     | 
    
         
            +
                                this.emit([this.helpers.returnJsonArray([payload])]);
         
     | 
| 
      
 87 
     | 
    
         
            +
                            }
         
     | 
| 
      
 88 
     | 
    
         
            +
                            catch (error) {
         
     | 
| 
      
 89 
     | 
    
         
            +
                                console.error('Error processing NATS message:', error);
         
     | 
| 
      
 90 
     | 
    
         
            +
                            }
         
     | 
| 
      
 91 
     | 
    
         
            +
                        }
         
     | 
| 
      
 92 
     | 
    
         
            +
                    })();
         
     | 
| 
      
 93 
     | 
    
         
            +
                    async function closeFunction() {
         
     | 
| 
      
 94 
     | 
    
         
            +
                        await subscription.unsubscribe();
         
     | 
| 
      
 95 
     | 
    
         
            +
                        await natsConnection.close();
         
     | 
| 
      
 96 
     | 
    
         
            +
                    }
         
     | 
| 
      
 97 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 98 
     | 
    
         
            +
                        closeFunction,
         
     | 
| 
      
 99 
     | 
    
         
            +
                        async manualTriggerFunction() {
         
     | 
| 
      
 100 
     | 
    
         
            +
                        },
         
     | 
| 
      
 101 
     | 
    
         
            +
                    };
         
     | 
| 
      
 102 
     | 
    
         
            +
                }
         
     | 
| 
      
 103 
     | 
    
         
            +
            }
         
     | 
| 
      
 104 
     | 
    
         
            +
            exports.TicketCreated = TicketCreated;
         
     | 
| 
         @@ -0,0 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 3 
     | 
    
         
            +
            exports.TicketCreated = void 0;
         
     | 
| 
      
 4 
     | 
    
         
            +
            const TicketCreated_node_1 = require("./TicketCreated.node");
         
     | 
| 
      
 5 
     | 
    
         
            +
            Object.defineProperty(exports, "TicketCreated", { enumerable: true, get: function () { return TicketCreated_node_1.TicketCreated; } });
         
     | 
| 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <?xml version="1.0" encoding="UTF-8"?>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
         
     | 
| 
      
 4 
     | 
    
         
            +
                    <circle fill="#6772E5" cx="16" cy="16" r="16"/>
         
     | 
| 
      
 5 
     | 
    
         
            +
                    <path d="M10,8 L22,8 C23.1045695,8 24,8.8954305 24,10 L24,22 C24,23.1045695 23.1045695,24 22,24 L10,24 C8.8954305,24 8,23.1045695 8,22 L8,10 C8,8.8954305 8.8954305,8 10,8 Z M11,12 L21,12 L21,14 L11,14 L11,12 Z M11,16 L21,16 L21,18 L11,18 L11,16 Z M11,20 L17,20 L17,22 L11,22 L11,20 Z" fill="#FFFFFF"/>
         
     | 
| 
      
 6 
     | 
    
         
            +
                </g>
         
     | 
| 
      
 7 
     | 
    
         
            +
            </svg> 
         
     | 
| 
         @@ -0,0 +1,95 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 3 
     | 
    
         
            +
            exports.McpClient = void 0;
         
     | 
| 
      
 4 
     | 
    
         
            +
            const n8n_workflow_1 = require("n8n-workflow");
         
     | 
| 
      
 5 
     | 
    
         
            +
            const child_process_1 = require("child_process");
         
     | 
| 
      
 6 
     | 
    
         
            +
            class McpClient {
         
     | 
| 
      
 7 
     | 
    
         
            +
                constructor() {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    this.description = {
         
     | 
| 
      
 9 
     | 
    
         
            +
                        displayName: 'MCP Client',
         
     | 
| 
      
 10 
     | 
    
         
            +
                        name: 'mcpClient',
         
     | 
| 
      
 11 
     | 
    
         
            +
                        icon: 'file:mcpClient.svg',
         
     | 
| 
      
 12 
     | 
    
         
            +
                        group: ['transform'],
         
     | 
| 
      
 13 
     | 
    
         
            +
                        version: 1,
         
     | 
| 
      
 14 
     | 
    
         
            +
                        description: 'Provide Model Context Protocol (MCP) tools to AI nodes',
         
     | 
| 
      
 15 
     | 
    
         
            +
                        defaults: {
         
     | 
| 
      
 16 
     | 
    
         
            +
                            name: 'MCP Client',
         
     | 
| 
      
 17 
     | 
    
         
            +
                        },
         
     | 
| 
      
 18 
     | 
    
         
            +
                        inputs: ['main'],
         
     | 
| 
      
 19 
     | 
    
         
            +
                        outputs: ["ai_tool"],
         
     | 
| 
      
 20 
     | 
    
         
            +
                        credentials: [
         
     | 
| 
      
 21 
     | 
    
         
            +
                            {
         
     | 
| 
      
 22 
     | 
    
         
            +
                                name: 'mcpClientApi',
         
     | 
| 
      
 23 
     | 
    
         
            +
                                required: true,
         
     | 
| 
      
 24 
     | 
    
         
            +
                            },
         
     | 
| 
      
 25 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 26 
     | 
    
         
            +
                        properties: [],
         
     | 
| 
      
 27 
     | 
    
         
            +
                    };
         
     | 
| 
      
 28 
     | 
    
         
            +
                }
         
     | 
| 
      
 29 
     | 
    
         
            +
                async execute() {
         
     | 
| 
      
 30 
     | 
    
         
            +
                    var _a;
         
     | 
| 
      
 31 
     | 
    
         
            +
                    const credentials = await this.getCredentials('mcpClientApi');
         
     | 
| 
      
 32 
     | 
    
         
            +
                    const command = credentials.command;
         
     | 
| 
      
 33 
     | 
    
         
            +
                    const args = credentials.args;
         
     | 
| 
      
 34 
     | 
    
         
            +
                    const executeMcpCommand = async (input) => {
         
     | 
| 
      
 35 
     | 
    
         
            +
                        return new Promise((resolve, reject) => {
         
     | 
| 
      
 36 
     | 
    
         
            +
                            const process = (0, child_process_1.spawn)(command, args);
         
     | 
| 
      
 37 
     | 
    
         
            +
                            let stdout = '';
         
     | 
| 
      
 38 
     | 
    
         
            +
                            let stderr = '';
         
     | 
| 
      
 39 
     | 
    
         
            +
                            process.stdin.write(JSON.stringify(input) + '\n');
         
     | 
| 
      
 40 
     | 
    
         
            +
                            process.stdin.end();
         
     | 
| 
      
 41 
     | 
    
         
            +
                            process.stdout.on('data', (data) => {
         
     | 
| 
      
 42 
     | 
    
         
            +
                                stdout += data.toString();
         
     | 
| 
      
 43 
     | 
    
         
            +
                            });
         
     | 
| 
      
 44 
     | 
    
         
            +
                            process.stderr.on('data', (data) => {
         
     | 
| 
      
 45 
     | 
    
         
            +
                                stderr += data.toString();
         
     | 
| 
      
 46 
     | 
    
         
            +
                            });
         
     | 
| 
      
 47 
     | 
    
         
            +
                            process.on('close', (code) => {
         
     | 
| 
      
 48 
     | 
    
         
            +
                                if (code !== 0) {
         
     | 
| 
      
 49 
     | 
    
         
            +
                                    reject(new Error(`Process exited with code ${code}: ${stderr}`));
         
     | 
| 
      
 50 
     | 
    
         
            +
                                    return;
         
     | 
| 
      
 51 
     | 
    
         
            +
                                }
         
     | 
| 
      
 52 
     | 
    
         
            +
                                try {
         
     | 
| 
      
 53 
     | 
    
         
            +
                                    const response = JSON.parse(stdout);
         
     | 
| 
      
 54 
     | 
    
         
            +
                                    resolve(response);
         
     | 
| 
      
 55 
     | 
    
         
            +
                                }
         
     | 
| 
      
 56 
     | 
    
         
            +
                                catch (error) {
         
     | 
| 
      
 57 
     | 
    
         
            +
                                    reject(new Error(`Failed to parse MCP response: ${error.message}`));
         
     | 
| 
      
 58 
     | 
    
         
            +
                                }
         
     | 
| 
      
 59 
     | 
    
         
            +
                            });
         
     | 
| 
      
 60 
     | 
    
         
            +
                            process.on('error', (error) => {
         
     | 
| 
      
 61 
     | 
    
         
            +
                                reject(error);
         
     | 
| 
      
 62 
     | 
    
         
            +
                            });
         
     | 
| 
      
 63 
     | 
    
         
            +
                        });
         
     | 
| 
      
 64 
     | 
    
         
            +
                    };
         
     | 
| 
      
 65 
     | 
    
         
            +
                    try {
         
     | 
| 
      
 66 
     | 
    
         
            +
                        const toolsResponse = await executeMcpCommand({
         
     | 
| 
      
 67 
     | 
    
         
            +
                            method: 'tools/list',
         
     | 
| 
      
 68 
     | 
    
         
            +
                            params: {},
         
     | 
| 
      
 69 
     | 
    
         
            +
                        });
         
     | 
| 
      
 70 
     | 
    
         
            +
                        const tools = ((_a = toolsResponse.result) === null || _a === void 0 ? void 0 : _a.tools) || [];
         
     | 
| 
      
 71 
     | 
    
         
            +
                        const aiTools = tools.map((tool) => ({
         
     | 
| 
      
 72 
     | 
    
         
            +
                            name: tool.name,
         
     | 
| 
      
 73 
     | 
    
         
            +
                            description: tool.description,
         
     | 
| 
      
 74 
     | 
    
         
            +
                            execute: async (params) => {
         
     | 
| 
      
 75 
     | 
    
         
            +
                                const response = await executeMcpCommand({
         
     | 
| 
      
 76 
     | 
    
         
            +
                                    method: 'tools/call',
         
     | 
| 
      
 77 
     | 
    
         
            +
                                    params: {
         
     | 
| 
      
 78 
     | 
    
         
            +
                                        name: tool.name,
         
     | 
| 
      
 79 
     | 
    
         
            +
                                        arguments: params,
         
     | 
| 
      
 80 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 81 
     | 
    
         
            +
                                });
         
     | 
| 
      
 82 
     | 
    
         
            +
                                if (response.error) {
         
     | 
| 
      
 83 
     | 
    
         
            +
                                    throw new Error(`Tool execution failed: ${response.error.message}`);
         
     | 
| 
      
 84 
     | 
    
         
            +
                                }
         
     | 
| 
      
 85 
     | 
    
         
            +
                                return response.result;
         
     | 
| 
      
 86 
     | 
    
         
            +
                            },
         
     | 
| 
      
 87 
     | 
    
         
            +
                        }));
         
     | 
| 
      
 88 
     | 
    
         
            +
                        return [[{ json: { tools: aiTools } }]];
         
     | 
| 
      
 89 
     | 
    
         
            +
                    }
         
     | 
| 
      
 90 
     | 
    
         
            +
                    catch (error) {
         
     | 
| 
      
 91 
     | 
    
         
            +
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
         
     | 
| 
      
 92 
     | 
    
         
            +
                    }
         
     | 
| 
      
 93 
     | 
    
         
            +
                }
         
     | 
| 
      
 94 
     | 
    
         
            +
            }
         
     | 
| 
      
 95 
     | 
    
         
            +
            exports.McpClient = McpClient;
         
     | 
| 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <?xml version="1.0" encoding="UTF-8"?>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
         
     | 
| 
      
 4 
     | 
    
         
            +
                    <circle fill="#6772E5" cx="16" cy="16" r="16"/>
         
     | 
| 
      
 5 
     | 
    
         
            +
                    <path d="M10,8 L22,8 C23.1045695,8 24,8.8954305 24,10 L24,22 C24,23.1045695 23.1045695,24 22,24 L10,24 C8.8954305,24 8,23.1045695 8,22 L8,10 C8,8.8954305 8.8954305,8 10,8 Z M11,12 L21,12 L21,14 L11,14 L11,12 Z M11,16 L21,16 L21,18 L11,18 L11,16 Z M11,20 L17,20 L17,22 L11,22 L11,20 Z" fill="#FFFFFF"/>
         
     | 
| 
      
 6 
     | 
    
         
            +
                </g>
         
     | 
| 
      
 7 
     | 
    
         
            +
            </svg> 
         
     | 
| 
         @@ -0,0 +1,94 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            var __importDefault = (this && this.__importDefault) || function (mod) {
         
     | 
| 
      
 3 
     | 
    
         
            +
                return (mod && mod.__esModule) ? mod : { "default": mod };
         
     | 
| 
      
 4 
     | 
    
         
            +
            };
         
     | 
| 
      
 5 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 6 
     | 
    
         
            +
            exports.NpmSearch = void 0;
         
     | 
| 
      
 7 
     | 
    
         
            +
            const axios_1 = __importDefault(require("axios"));
         
     | 
| 
      
 8 
     | 
    
         
            +
            class NpmSearch {
         
     | 
| 
      
 9 
     | 
    
         
            +
                constructor() {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    this.description = {
         
     | 
| 
      
 11 
     | 
    
         
            +
                        displayName: 'NPM Search',
         
     | 
| 
      
 12 
     | 
    
         
            +
                        name: 'npmSearch',
         
     | 
| 
      
 13 
     | 
    
         
            +
                        icon: 'file:npm.svg',
         
     | 
| 
      
 14 
     | 
    
         
            +
                        group: ['transform'],
         
     | 
| 
      
 15 
     | 
    
         
            +
                        version: 1,
         
     | 
| 
      
 16 
     | 
    
         
            +
                        description: 'Search for NPM packages using AI-powered relevance scoring',
         
     | 
| 
      
 17 
     | 
    
         
            +
                        defaults: {
         
     | 
| 
      
 18 
     | 
    
         
            +
                            name: 'NPM Search',
         
     | 
| 
      
 19 
     | 
    
         
            +
                        },
         
     | 
| 
      
 20 
     | 
    
         
            +
                        codex: {
         
     | 
| 
      
 21 
     | 
    
         
            +
                            categories: ['AI'],
         
     | 
| 
      
 22 
     | 
    
         
            +
                            subcategories: {
         
     | 
| 
      
 23 
     | 
    
         
            +
                                'AI': ['Tools']
         
     | 
| 
      
 24 
     | 
    
         
            +
                            },
         
     | 
| 
      
 25 
     | 
    
         
            +
                            resources: {
         
     | 
| 
      
 26 
     | 
    
         
            +
                                primaryDocumentation: [
         
     | 
| 
      
 27 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 28 
     | 
    
         
            +
                                        url: 'https://github.com/yourusername/n8n-nodes-npm-tools',
         
     | 
| 
      
 29 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 30 
     | 
    
         
            +
                                ],
         
     | 
| 
      
 31 
     | 
    
         
            +
                            },
         
     | 
| 
      
 32 
     | 
    
         
            +
                        },
         
     | 
| 
      
 33 
     | 
    
         
            +
                        inputs: [],
         
     | 
| 
      
 34 
     | 
    
         
            +
                        outputs: ["ai_tool"],
         
     | 
| 
      
 35 
     | 
    
         
            +
                        properties: [],
         
     | 
| 
      
 36 
     | 
    
         
            +
                    };
         
     | 
| 
      
 37 
     | 
    
         
            +
                }
         
     | 
| 
      
 38 
     | 
    
         
            +
                async execute() {
         
     | 
| 
      
 39 
     | 
    
         
            +
                    const npmSearchTool = {
         
     | 
| 
      
 40 
     | 
    
         
            +
                        name: 'npm_search',
         
     | 
| 
      
 41 
     | 
    
         
            +
                        description: 'Search for NPM packages. Use this when you need to find Node.js packages, their versions, descriptions, and relevance scores.',
         
     | 
| 
      
 42 
     | 
    
         
            +
                        schema: {
         
     | 
| 
      
 43 
     | 
    
         
            +
                            type: 'object',
         
     | 
| 
      
 44 
     | 
    
         
            +
                            properties: {
         
     | 
| 
      
 45 
     | 
    
         
            +
                                searchQuery: {
         
     | 
| 
      
 46 
     | 
    
         
            +
                                    type: 'string',
         
     | 
| 
      
 47 
     | 
    
         
            +
                                    description: 'The search term to look for in NPM packages',
         
     | 
| 
      
 48 
     | 
    
         
            +
                                },
         
     | 
| 
      
 49 
     | 
    
         
            +
                                size: {
         
     | 
| 
      
 50 
     | 
    
         
            +
                                    type: 'number',
         
     | 
| 
      
 51 
     | 
    
         
            +
                                    description: 'Number of results to return (default: 20)',
         
     | 
| 
      
 52 
     | 
    
         
            +
                                    optional: true,
         
     | 
| 
      
 53 
     | 
    
         
            +
                                },
         
     | 
| 
      
 54 
     | 
    
         
            +
                                from: {
         
     | 
| 
      
 55 
     | 
    
         
            +
                                    type: 'number',
         
     | 
| 
      
 56 
     | 
    
         
            +
                                    description: 'Offset for pagination (default: 0)',
         
     | 
| 
      
 57 
     | 
    
         
            +
                                    optional: true,
         
     | 
| 
      
 58 
     | 
    
         
            +
                                },
         
     | 
| 
      
 59 
     | 
    
         
            +
                            },
         
     | 
| 
      
 60 
     | 
    
         
            +
                            required: ['searchQuery'],
         
     | 
| 
      
 61 
     | 
    
         
            +
                        },
         
     | 
| 
      
 62 
     | 
    
         
            +
                        async function({ searchQuery, size = 20, from = 0 }) {
         
     | 
| 
      
 63 
     | 
    
         
            +
                            try {
         
     | 
| 
      
 64 
     | 
    
         
            +
                                const response = await axios_1.default.get(`https://registry.npmjs.org/-/v1/search`, {
         
     | 
| 
      
 65 
     | 
    
         
            +
                                    params: {
         
     | 
| 
      
 66 
     | 
    
         
            +
                                        text: searchQuery,
         
     | 
| 
      
 67 
     | 
    
         
            +
                                        size,
         
     | 
| 
      
 68 
     | 
    
         
            +
                                        from,
         
     | 
| 
      
 69 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 70 
     | 
    
         
            +
                                });
         
     | 
| 
      
 71 
     | 
    
         
            +
                                const packages = response.data.objects.map((pkg) => ({
         
     | 
| 
      
 72 
     | 
    
         
            +
                                    name: pkg.package.name,
         
     | 
| 
      
 73 
     | 
    
         
            +
                                    version: pkg.package.version,
         
     | 
| 
      
 74 
     | 
    
         
            +
                                    description: pkg.package.description,
         
     | 
| 
      
 75 
     | 
    
         
            +
                                    keywords: pkg.package.keywords,
         
     | 
| 
      
 76 
     | 
    
         
            +
                                    author: pkg.package.author,
         
     | 
| 
      
 77 
     | 
    
         
            +
                                    publisher: pkg.package.publisher,
         
     | 
| 
      
 78 
     | 
    
         
            +
                                    maintainers: pkg.package.maintainers,
         
     | 
| 
      
 79 
     | 
    
         
            +
                                    links: pkg.package.links,
         
     | 
| 
      
 80 
     | 
    
         
            +
                                    score: pkg.score,
         
     | 
| 
      
 81 
     | 
    
         
            +
                                    searchScore: pkg.searchScore,
         
     | 
| 
      
 82 
     | 
    
         
            +
                                    aiRelevanceScore: pkg.score.final * pkg.searchScore,
         
     | 
| 
      
 83 
     | 
    
         
            +
                                }));
         
     | 
| 
      
 84 
     | 
    
         
            +
                                return JSON.stringify(packages);
         
     | 
| 
      
 85 
     | 
    
         
            +
                            }
         
     | 
| 
      
 86 
     | 
    
         
            +
                            catch (error) {
         
     | 
| 
      
 87 
     | 
    
         
            +
                                throw new Error(`Failed to search NPM: ${error.message}`);
         
     | 
| 
      
 88 
     | 
    
         
            +
                            }
         
     | 
| 
      
 89 
     | 
    
         
            +
                        },
         
     | 
| 
      
 90 
     | 
    
         
            +
                    };
         
     | 
| 
      
 91 
     | 
    
         
            +
                    return [[{ json: { tools: [npmSearchTool] } }]];
         
     | 
| 
      
 92 
     | 
    
         
            +
                }
         
     | 
| 
      
 93 
     | 
    
         
            +
            }
         
     | 
| 
      
 94 
     | 
    
         
            +
            exports.NpmSearch = NpmSearch;
         
     | 
| 
         @@ -0,0 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <?xml version="1.0" encoding="UTF-8"?>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <rect x="0" y="0" width="100" height="100" fill="#CB3837"/>
         
     | 
| 
      
 4 
     | 
    
         
            +
                <path d="M15,85 L15,15 L85,15 L85,85 L50,85 L50,30 L35,30 L35,85 Z" fill="#FFFFFF"/>
         
     | 
| 
      
 5 
     | 
    
         
            +
            </svg> 
         
     |