UNPKG

@boundless-oss/atlas

Version:

Atlas - MCP Server for comprehensive startup project management

160 lines 4.21 kB
/** * Schema Validation Utility * Implements MCP Design Guide Section 2.3 principles for robust tool input validation */ export interface ValidationRule { field: string; type: string; required?: boolean; min?: number; max?: number; pattern?: string; enum?: any[]; custom?: (value: any) => boolean | string; } export interface SchemaDefinition { type: 'object'; properties: Record<string, any>; required?: string[]; additionalProperties?: boolean; } export declare class SchemaValidator { /** * Enhanced schema patterns for common MCP tool parameters */ static readonly COMMON_SCHEMAS: { ID: { type: string; pattern: string; minLength: number; maxLength: number; description: string; }; UUID: { type: string; pattern: string; description: string; }; NAME: { type: string; minLength: number; maxLength: number; pattern: string; description: string; }; TITLE: { type: string; minLength: number; maxLength: number; description: string; }; SHORT_DESCRIPTION: { type: string; minLength: number; maxLength: number; description: string; }; LONG_DESCRIPTION: { type: string; minLength: number; maxLength: number; description: string; }; DATE: { type: string; format: string; description: string; }; DATETIME: { type: string; format: string; description: string; }; PRIORITY: { type: string; enum: string[]; description: string; }; AGILE_STATUS: { type: string; enum: string[]; description: string; }; TASK_STATUS: { type: string; enum: string[]; description: string; }; STORY_POINTS: { type: string; enum: number[]; description: string; }; SPRINT_DURATION: { type: string; minimum: number; maximum: number; description: string; }; EMAIL: { type: string; format: string; description: string; }; URL: { type: string; format: string; description: string; }; TAG_ARRAY: { type: string; items: { type: string; minLength: number; maxLength: number; pattern: string; }; maxItems: number; uniqueItems: boolean; description: string; }; STRING_ARRAY: { type: string; items: { type: string; minLength: number; maxLength: number; }; maxItems: number; description: string; }; }; /** * Create enhanced schema for tool definitions */ static createToolSchema(fields: Record<string, string | object>, required?: string[]): SchemaDefinition; /** * Validate parameters against schema with detailed error reporting */ static validateParameters(params: any, schema: SchemaDefinition, context: { tool: string; module: string; }): void; /** * Validate individual field against its schema */ private static validateField; /** * Validate data type */ private static validateType; /** * Validate string formats */ private static validateFormat; /** * Create a decorator for automatic parameter validation */ static validateParams(schema: SchemaDefinition): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; } //# sourceMappingURL=schema-validator.d.ts.map