UNPKG

@boundless-oss/atlas

Version:

Atlas - MCP Server for comprehensive startup project management

144 lines 4.16 kB
/** * Enhanced Error Handling Utility * Implements MCP Design Guide Section 5.1 principles for error visibility and self-correction */ export interface DetailedError { message: string; code: string; category: 'validation' | 'execution' | 'external' | 'system'; details: Record<string, any>; context?: Record<string, any>; recoverable: boolean; suggestedActions?: string[]; originalError?: Error; } export interface RetryConfig { maxAttempts: number; baseDelay: number; maxDelay: number; backoffMultiplier: number; retryableErrors: string[]; } export declare class MCPError extends Error { readonly code: string; readonly category: string; readonly details: Record<string, any>; readonly context?: Record<string, any>; readonly recoverable: boolean; readonly suggestedActions?: string[]; readonly originalError?: Error; constructor(error: DetailedError); toMCPResponse(): { content: { type: string; text: string; }[]; structured: { error: boolean; code: string; category: string; recoverable: boolean; details: Record<string, any>; context: Record<string, any>; suggestedActions: string[]; }; }; private formatErrorMessage; } export declare class ErrorHandler { private static readonly DEFAULT_RETRY_CONFIG; /** * Wraps a function with comprehensive error handling and retry logic */ static withErrorHandling<T>(operation: () => Promise<T>, context: { tool: string; module: string; params?: any; }, retryConfig?: Partial<RetryConfig>): Promise<T>; /** * Transform generic errors into detailed MCP errors with full visibility */ static transformError(error: Error, context: { tool: string; module: string; params?: any; }): MCPError; /** * Create a validation error for schema violations */ static createValidationError(field: string, value: any, constraint: string, context: { tool: string; module: string; }): MCPError; /** * Create a resource not found error */ static createNotFoundError(resourceType: string, identifier: string, context: { tool: string; module: string; }): MCPError; /** * Create a dependency error for missing prerequisites */ static createDependencyError(dependency: string, context: { tool: string; module: string; }): MCPError; private static sleep; /** * Get detailed information about a specific error */ getErrorDetails(errorId: string): Promise<any>; /** * Analyze patterns in errors */ analyzeErrorPatterns(options: { timeRange?: string; errorTypes?: string[]; minOccurrences?: number; groupBy?: string; }): Promise<any>; /** * Get timeline of errors */ getErrorTimeline(options: { timeRange?: string; toolName?: string; severity?: string; includeContext?: boolean; }): Promise<any[]>; /** * Generate error report */ generateErrorReport(options: { reportType?: string; timeRange?: string; includeRecommendations?: boolean; outputFormat?: string; saveToFile?: boolean; }): Promise<any>; /** * Track error resolution */ resolveErrorSuggestion(options: { errorId: string; suggestionId: string; implementation?: string; effectiveness?: number; notes?: string; }): Promise<any>; /** * Simulate error recovery */ simulateErrorRecovery(options: { errorType: string; severity?: string; context?: any; dryRun?: boolean; }): Promise<any>; } /** * Decorator for automatic error handling in tool functions */ export declare function withMCPErrorHandling(target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor; //# sourceMappingURL=error-handler.d.ts.map