UNPKG

lokalise-mcp

Version:

The Lokalise MCP Server brings Lokalise's localization power to Claude and AI assistants—manage projects, keys, and translations by chat.

117 lines (116 loc) • 3.73 kB
/** * Error types for classification */ export declare enum ErrorType { AUTH_MISSING = "AUTH_MISSING", AUTH_INVALID = "AUTH_INVALID", API_ERROR = "API_ERROR", NETWORK_ERROR = "NETWORK_ERROR", RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED", NOT_FOUND = "NOT_FOUND", INVALID_PROJECT_ID = "INVALID_PROJECT_ID", INSUFFICIENT_PERMISSIONS = "INSUFFICIENT_PERMISSIONS", VALIDATION_ERROR = "VALIDATION_ERROR", TIMEOUT_ERROR = "TIMEOUT_ERROR", UNEXPECTED_ERROR = "UNEXPECTED_ERROR" } /** * Custom error class with type classification */ export declare class McpError extends Error { type: ErrorType; statusCode?: number; originalError?: unknown; constructor(message: string, type: ErrorType, statusCode?: number, originalError?: unknown); } /** * Create an authentication missing error */ export declare function createAuthMissingError(message?: string): McpError; /** * Create an authentication invalid error */ export declare function createAuthInvalidError(message?: string): McpError; /** * Create an API error */ export declare function createApiError(message: string, statusCode?: number, originalError?: unknown): McpError; /** * Create a network error */ export declare function createNetworkError(message?: string, originalError?: unknown): McpError; /** * Create a rate limit exceeded error */ export declare function createRateLimitError(message?: string, retryAfter?: number): McpError; /** * Create a not found error */ export declare function createNotFoundError(message?: string, originalError?: unknown): McpError; /** * Create an invalid project ID error */ export declare function createInvalidProjectIdError(projectId: string, originalError?: unknown): McpError; /** * Create an insufficient permissions error */ export declare function createInsufficientPermissionsError(message?: string, originalError?: unknown): McpError; /** * Create a validation error */ export declare function createValidationError(message?: string, originalError?: unknown): McpError; /** * Create a timeout error */ export declare function createTimeoutError(message?: string, originalError?: unknown): McpError; /** * Create an unexpected error */ export declare function createUnexpectedError(message?: string, originalError?: unknown): McpError; /** * Ensure an error is an McpError */ export declare function ensureMcpError(error: unknown): McpError; /** * Classify an error based on status code and message content * @param error The error to classify * @param statusCode HTTP status code if available * @param message Error message * @returns Appropriate McpError with correct type */ export declare function classifyApiError(error: unknown, statusCode?: number, message?: string): McpError; /** * Get the deepest original error from an error chain * @param error The error to extract the original cause from * @returns The deepest original error or the error itself */ export declare function getDeepOriginalError(error: unknown): unknown; /** * Format error for MCP tool response */ export declare function formatErrorForMcpTool(error: unknown): { content: Array<{ type: "text"; text: string; }>; metadata?: { errorType: ErrorType; statusCode?: number; errorDetails?: unknown; }; }; /** * Format error for MCP resource response */ export declare function formatErrorForMcpResource(error: unknown, uri: string): { contents: Array<{ uri: string; text: string; mimeType: string; description?: string; }>; }; /** * Handle error in CLI context with improved user feedback */ export declare function handleCliError(error: unknown): never;