/** * Agentic QE v3 - MCP Security: JSON Schema Validator * Validates all MCP tool inputs using JSON Schema (ADR-012) * * Features: * - Type-safe JSON Schema validation * - Custom validators and formats * - Detailed validation error messages * - Schema caching for performance */ /** * JSON Schema type definitions */ export type JSONSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null'; /** * JSON Schema format definitions */ export type JSONSchemaFormat = 'date' | 'date-time' | 'time' | 'email' | 'uri' | 'uri-reference' | 'uuid' | 'hostname' | 'ipv4' | 'ipv6' | 'regex' | 'json-pointer' | 'relative-json-pointer' | 'file-path' | 'safe-path'; /** * JSON Schema definition */ export interface JSONSchema { type?: JSONSchemaType | JSONSchemaType[]; properties?: Record; required?: string[]; additionalProperties?: boolean | JSONSchema; items?: JSONSchema | JSONSchema[]; minItems?: number; maxItems?: number; uniqueItems?: boolean; minimum?: number; maximum?: number; exclusiveMinimum?: number; exclusiveMaximum?: number; minLength?: number; maxLength?: number; pattern?: string; format?: JSONSchemaFormat; enum?: unknown[]; const?: unknown; default?: unknown; description?: string; title?: string; $ref?: string; allOf?: JSONSchema[]; anyOf?: JSONSchema[]; oneOf?: JSONSchema[]; not?: JSONSchema; if?: JSONSchema; then?: JSONSchema; else?: JSONSchema; } /** * Validation error */ export interface ValidationError { path: string; message: string; keyword: string; schemaPath: string; params?: Record; } /** * Validation result */ export interface ValidationResult { valid: boolean; errors: ValidationError[]; } /** * Custom format validator */ export type FormatValidator = (value: string) => boolean; /** * Schema validator configuration */ export interface SchemaValidatorConfig { strictMode?: boolean; coerceTypes?: boolean; removeAdditional?: boolean; customFormats?: Record; } /** * JSON Schema Validator for MCP tool inputs */ export declare class SchemaValidator { private readonly config; private readonly formats; private readonly schemaCache; constructor(config?: SchemaValidatorConfig); /** * Register a custom format validator */ registerFormat(name: string, validator: FormatValidator): void; /** * Register a schema for caching */ registerSchema(id: string, schema: JSONSchema): void; /** * Validate data against a schema */ validate(data: unknown, schema: JSONSchema): ValidationResult; /** * Validate and return typed result */ validateTyped(data: unknown, schema: JSONSchema): { valid: true; data: T; } | { valid: false; errors: ValidationError[]; }; /** * Create a validator function for a schema */ compile(schema: JSONSchema): (data: unknown) => ValidationResult & { data?: T; }; private validateValue; private validateString; private validateNumber; private validateArray; private validateObject; private getType; private deepEqual; } /** * Create a new schema validator instance */ export declare function createSchemaValidator(config?: SchemaValidatorConfig): SchemaValidator; /** * Create a strict schema validator (no additional properties allowed) */ export declare function createStrictSchemaValidator(): SchemaValidator; /** * Common parameter schemas */ export declare const CommonSchemas: { FilePath: { type: "string"; format: "safe-path"; maxLength: number; description: string; }; Domain: { type: "string"; enum: string[]; description: string; }; Priority: { type: "string"; enum: string[]; description: string; }; UUID: { type: "string"; format: "uuid"; description: string; }; PositiveInteger: { type: "integer"; minimum: number; description: string; }; Percentage: { type: "number"; minimum: number; maximum: number; description: string; }; NonEmptyString: { type: "string"; minLength: number; maxLength: number; description: string; }; Email: { type: "string"; format: "email"; description: string; }; URL: { type: "string"; format: "uri"; description: string; }; DateTime: { type: "string"; format: "date-time"; description: string; }; }; /** * Get the default schema validator instance */ export declare function getSchemaValidator(): SchemaValidator; //# sourceMappingURL=schema-validator.d.ts.map