UNPKG

n8n

Version:

n8n Workflow Automation Tool

61 lines 2.58 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.McpRegistryApiClient = void 0; const di_1 = require("@n8n/di"); const strapi_utils_1 = require("../../../utils/strapi-utils"); const MCP_SERVERS_STAGING_URL = 'https://api-staging.n8n.io/api/mcp-servers'; const MCP_SERVERS_PRODUCTION_URL = 'https://api.n8n.io/api/mcp-servers'; const STRAPI_ARRAY_LIMIT = 100; let McpRegistryApiClient = class McpRegistryApiClient { async fetchAllServers() { return await (0, strapi_utils_1.paginatedRequest)(this.getUrl(), { pagination: { page: 1, pageSize: 25 }, }, { throwOnError: true, }); } async fetchServersMetadata() { return await (0, strapi_utils_1.paginatedRequest)(this.getUrl(), { fields: ['slug', 'version', 'updatedAt'], pagination: { page: 1, pageSize: 500 }, }, { throwOnError: true, }); } async fetchServersBySlugs(slugs) { const data = []; for (let i = 0; i < slugs.length; i += STRAPI_ARRAY_LIMIT) { const batch = slugs.slice(i, i + STRAPI_ARRAY_LIMIT); const batchData = await (0, strapi_utils_1.paginatedRequest)(this.getUrl(), { filters: { slug: { $in: batch, }, }, pagination: { page: 1, pageSize: 25 }, }, { throwOnError: true, }); data.push(...batchData); } return data; } getUrl() { const environment = process.env.ENVIRONMENT; if (environment === 'staging') { return MCP_SERVERS_STAGING_URL; } return MCP_SERVERS_PRODUCTION_URL; } }; exports.McpRegistryApiClient = McpRegistryApiClient; exports.McpRegistryApiClient = McpRegistryApiClient = __decorate([ (0, di_1.Service)() ], McpRegistryApiClient); //# sourceMappingURL=mcp-registry-api.client.js.map