Skip to main content
Glama
ajv-provider.js3.25 kB
"use strict"; /** * AJV-based JSON Schema validator provider */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AjvJsonSchemaValidator = void 0; const ajv_1 = require("ajv"); const ajv_formats_1 = __importDefault(require("ajv-formats")); function createDefaultAjvInstance() { const ajv = new ajv_1.Ajv({ strict: false, validateFormats: true, validateSchema: false, allErrors: true }); const addFormats = ajv_formats_1.default; addFormats(ajv); return ajv; } /** * @example * ```typescript * // Use with default AJV instance (recommended) * import { AjvJsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/ajv'; * const validator = new AjvJsonSchemaValidator(); * * // Use with custom AJV instance * import { Ajv } from 'ajv'; * const ajv = new Ajv({ strict: true, allErrors: true }); * const validator = new AjvJsonSchemaValidator(ajv); * ``` */ class AjvJsonSchemaValidator { /** * Create an AJV validator * * @param ajv - Optional pre-configured AJV instance. If not provided, a default instance will be created. * * @example * ```typescript * // Use default configuration (recommended for most cases) * import { AjvJsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/ajv'; * const validator = new AjvJsonSchemaValidator(); * * // Or provide custom AJV instance for advanced configuration * import { Ajv } from 'ajv'; * import addFormats from 'ajv-formats'; * * const ajv = new Ajv({ validateFormats: true }); * addFormats(ajv); * const validator = new AjvJsonSchemaValidator(ajv); * ``` */ constructor(ajv) { this._ajv = ajv !== null && ajv !== void 0 ? ajv : createDefaultAjvInstance(); } /** * Create a validator for the given JSON Schema * * The validator is compiled once and can be reused multiple times. * If the schema has an $id, it will be cached by AJV automatically. * * @param schema - Standard JSON Schema object * @returns A validator function that validates input data */ getValidator(schema) { var _a; // Check if schema has $id and is already compiled/cached const ajvValidator = '$id' in schema && typeof schema.$id === 'string' ? ((_a = this._ajv.getSchema(schema.$id)) !== null && _a !== void 0 ? _a : this._ajv.compile(schema)) : this._ajv.compile(schema); return (input) => { const valid = ajvValidator(input); if (valid) { return { valid: true, data: input, errorMessage: undefined }; } else { return { valid: false, data: undefined, errorMessage: this._ajv.errorsText(ajvValidator.errors) }; } }; } } exports.AjvJsonSchemaValidator = AjvJsonSchemaValidator; //# sourceMappingURL=ajv-provider.js.map

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Sunil-paudel/mcpserverasof2025updated'

If you have feedback or need assistance with the MCP directory API, please join our Discord server