UNPKG

mushcode-mcp-server

Version:

A specialized Model Context Protocol server for MUSHCODE development assistance. Provides AI-powered code generation, validation, optimization, and examples for MUD development.

221 lines 6.77 kB
/** * Error severity levels for classification */ export declare enum ErrorSeverity { LOW = "low", MEDIUM = "medium", HIGH = "high", CRITICAL = "critical" } /** * Error categories for classification */ export declare enum ErrorCategory { PROTOCOL = "protocol", VALIDATION = "validation", TOOL_EXECUTION = "tool_execution", KNOWLEDGE_BASE = "knowledge_base", PERFORMANCE = "performance", SECURITY = "security", CONFIGURATION = "configuration" } /** * Interface for actionable error suggestions */ export interface ErrorSuggestion { action: string; description: string; documentation?: string; example?: string; } /** * Base class for all MUSHCODE MCP server errors */ export declare abstract class MushcodeError extends Error { readonly details?: Record<string, unknown> | undefined; abstract readonly code: string; abstract readonly mcpErrorCode: number; abstract readonly severity: ErrorSeverity; abstract readonly category: ErrorCategory; readonly suggestions: ErrorSuggestion[]; readonly userMessage: string; readonly canRecover: boolean; constructor(message: string, userMessage?: string, details?: Record<string, unknown> | undefined, suggestions?: ErrorSuggestion[]); /** * Add a suggestion for resolving this error */ addSuggestion(suggestion: ErrorSuggestion): void; /** * Get user-friendly error information */ getUserInfo(): { message: string; severity: ErrorSeverity; category: ErrorCategory; suggestions: ErrorSuggestion[]; canRecover: boolean; }; } /** * Protocol-level communication errors */ export declare class ProtocolError extends MushcodeError { readonly code = "INTERNAL_ERROR"; readonly mcpErrorCode = -32603; readonly severity = ErrorSeverity.HIGH; readonly category = ErrorCategory.PROTOCOL; readonly canRecover = false; constructor(message: string, details?: Record<string, unknown>); } /** * Input validation errors */ export declare class ValidationError extends MushcodeError { readonly code = "INVALID_PARAMS"; readonly mcpErrorCode = -32602; readonly severity = ErrorSeverity.MEDIUM; readonly category = ErrorCategory.VALIDATION; readonly canRecover = true; constructor(message: string, details?: Record<string, unknown>); } /** * Tool execution errors */ export declare class ToolExecutionError extends MushcodeError { readonly code = "INTERNAL_ERROR"; readonly mcpErrorCode = -32603; readonly severity = ErrorSeverity.HIGH; readonly category = ErrorCategory.TOOL_EXECUTION; readonly canRecover = true; constructor(toolName: string, message: string, details?: Record<string, unknown>); } /** * Tool not found errors */ export declare class ToolNotFoundError extends MushcodeError { readonly code = "METHOD_NOT_FOUND"; readonly mcpErrorCode = -32601; readonly severity = ErrorSeverity.MEDIUM; readonly category = ErrorCategory.VALIDATION; readonly canRecover = true; constructor(toolName: string); } /** * Knowledge base errors */ export declare class KnowledgeBaseError extends MushcodeError { readonly code = "INTERNAL_ERROR"; readonly mcpErrorCode = -32603; readonly severity = ErrorSeverity.MEDIUM; readonly category = ErrorCategory.KNOWLEDGE_BASE; readonly canRecover = true; constructor(message: string, details?: Record<string, unknown>); } /** * Performance-related errors */ export declare class PerformanceError extends MushcodeError { readonly code = "INTERNAL_ERROR"; readonly mcpErrorCode = -32603; readonly severity = ErrorSeverity.MEDIUM; readonly category = ErrorCategory.PERFORMANCE; readonly canRecover = true; constructor(operation: string, timeout: number, details?: Record<string, unknown>); } /** * Security-related errors */ export declare class SecurityError extends MushcodeError { readonly code = "INTERNAL_ERROR"; readonly mcpErrorCode = -32603; readonly severity = ErrorSeverity.HIGH; readonly category = ErrorCategory.SECURITY; readonly canRecover = true; constructor(message: string, details?: Record<string, unknown>); } /** * Configuration errors */ export declare class ConfigurationError extends MushcodeError { readonly code = "INTERNAL_ERROR"; readonly mcpErrorCode = -32603; readonly severity = ErrorSeverity.HIGH; readonly category = ErrorCategory.CONFIGURATION; readonly canRecover = false; constructor(message: string, details?: Record<string, unknown>); } /** * Graceful degradation options */ export interface DegradationOptions { useGenericPatterns?: boolean; skipOptionalFeatures?: boolean; reduceComplexity?: boolean; fallbackToBasicMode?: boolean; } /** * Graceful degradation manager */ export declare class GracefulDegradation { private static degradationLevel; private static maxDegradationLevel; /** * Check if we should degrade functionality */ static shouldDegrade(): boolean; /** * Get current degradation level */ static getDegradationLevel(): number; /** * Increase degradation level */ static increaseDegradation(): void; /** * Reset degradation level */ static resetDegradation(): void; /** * Get degradation options for current level */ static getDegradationOptions(): DegradationOptions; /** * Execute operation with graceful degradation */ static executeWithDegradation<T>(operation: () => Promise<T>, fallback: (options: DegradationOptions) => Promise<T>, _context?: string): Promise<T>; } /** * Enhanced error handling with user-friendly messages and logging */ export declare function handleError(error: unknown, context?: string): { code: string; message: string; userMessage: string; severity: ErrorSeverity; category: ErrorCategory; suggestions: ErrorSuggestion[]; canRecover: boolean; details?: Record<string, unknown>; }; /** * Create user-friendly error response for MCP protocol */ export declare function createMCPErrorResponse(error: unknown, context?: string): { error: { code: number; message: string; data?: { userMessage: string; severity: ErrorSeverity; category: ErrorCategory; suggestions: ErrorSuggestion[]; canRecover: boolean; details?: Record<string, unknown>; }; }; }; /** * Validate tool parameters against schema */ export declare function validateToolParameters(toolName: string, parameters: unknown, schema: Record<string, unknown>): void; //# sourceMappingURL=errors.d.ts.map