UNPKG

@sigyl-dev/sdk

Version:

Sigyl SDK

114 lines 4.29 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SigylSDK = void 0; const registry_1 = require("./registry"); /** * SigylSDK - Advanced SDK class for working with MCP registry and tools */ class SigylSDK { /** * SigylSDK always uses the Sigyl registry API at https://api.sigyl.dev/api/v1 * The registryUrl cannot be overridden by user config. * @param config - Only apiKey, timeout, and requireAuth are respected */ constructor(config = {}) { if (!config.apiKey) { throw new Error('An API key is required to use the SigylSDK.'); } this.config = { registryUrl: 'https://api.sigyl.dev/api/v1', timeout: config.timeout || 10000, apiKey: config.apiKey, requireAuth: true, }; } /** * Search for MCP servers in the registry */ searchMCP(query_1, tags_1) { return __awaiter(this, arguments, void 0, function* (query, tags, limit = 1, offset = 0) { return (0, registry_1.searchMCP)(query, tags, limit, offset, this.config); }); } /** * Get detailed information about a specific MCP server */ getMCP(name) { return __awaiter(this, void 0, void 0, function* () { return (0, registry_1.getMCP)(name, this.config); }); } /** * Search all servers (public operation - limited results) * This uses the public search endpoint with a high limit */ searchAllServers() { return __awaiter(this, arguments, void 0, function* (limit = 100) { const response = yield this.searchMCP(undefined, undefined, limit, 0); return response.servers; }); } /** * Get all servers (admin operation - requires admin API key) * This calls the admin endpoint that requires admin permissions */ getAllServers() { return __awaiter(this, void 0, void 0, function* () { return (0, registry_1.getAllServers)(this.config); }); } /** * Update SDK configuration */ updateConfig(newConfig) { if (newConfig.apiKey === undefined && !this.config.apiKey) { throw new Error('An API key is required to use the SigylSDK.'); } this.config = Object.assign(Object.assign(Object.assign({}, this.config), newConfig), { requireAuth: true }); } /** * Get current SDK configuration */ getConfig() { return Object.assign({}, this.config); } /** * Retrieve MCP server URL and metadata by name */ getMCPUrl(name) { return __awaiter(this, void 0, void 0, function* () { return (0, registry_1.getMCPUrl)(name, this.config); }); } /** * Semantic search for MCP servers * @param query - user prompt or search string * @param count - number of results to return (default 1) */ semanticMCP(query_1) { return __awaiter(this, arguments, void 0, function* (query, count = 1) { return (0, registry_1.semanticMCP)(query, count, this.config); }); } /** * Semantic search for tools across all MCP servers * @param query - user prompt or search string * @param count - number of results to return (default 1) */ semanticTools(query_1) { return __awaiter(this, arguments, void 0, function* (query, count = 1) { return (0, registry_1.semanticTools)(query, count, this.config); }); } } exports.SigylSDK = SigylSDK; //# sourceMappingURL=sdk.js.map