/** * Error handling for the Green Design System MCP Server */ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'; /** * Error codes for MCP operations */ export declare enum McpErrorCode { /** Invalid input parameter provided */ INVALID_INPUT = "INVALID_INPUT", /** Requested resource not found */ NOT_FOUND = "NOT_FOUND", /** Failed to load required data files */ DATA_LOAD_FAILED = "DATA_LOAD_FAILED", /** Invalid resource URI format */ INVALID_URI = "INVALID_URI", /** File system operation failed */ FILE_ERROR = "FILE_ERROR", /** Invalid regex pattern */ INVALID_REGEX = "INVALID_REGEX", /** Search operation failed */ SEARCH_FAILED = "SEARCH_FAILED", /** Internal server error */ INTERNAL_ERROR = "INTERNAL_ERROR" } /** * Base error class for MCP server errors * Provides structured error information for better debugging and error handling */ export declare class McpError extends Error { readonly code: McpErrorCode; readonly context?: Record | undefined; /** * Create a new MCP error * @param message - Human-readable error message * @param code - Error code for programmatic handling * @param context - Additional context information about the error */ constructor(message: string, code: McpErrorCode, context?: Record | undefined); /** * Convert error to JSON representation */ toJSON(): Record; } /** * Error thrown when input validation fails */ export declare class ValidationError extends McpError { readonly field?: string | undefined; constructor(message: string, field?: string | undefined, context?: Record); } /** * Error thrown when a resource is not found */ export declare class NotFoundError extends McpError { readonly resourceType: string; readonly resourceId: string; constructor(message: string, resourceType: string, resourceId: string, context?: Record); } /** * Error thrown when data loading fails */ export declare class DataLoadError extends McpError { readonly filePath: string; constructor(message: string, filePath: string, context?: Record); } /** * Error thrown when a regex pattern is invalid */ export declare class RegexError extends McpError { readonly pattern: string; constructor(message: string, pattern: string, context?: Record); } /** * Convert any error to an MCP error response format * @param error - The error to convert * @returns Formatted error response */ export declare function formatErrorResponse(error: unknown): CallToolResult; /** * Log error with structured information * @param error - The error to log * @param operation - The operation that failed */ export declare function logError(error: unknown, operation: string): void;