@toolprint/hypertool-mcp
Version:
HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers
154 lines • 9.6 kB
TypeScript
/**
* User-friendly error messages and message templates
*/
/**
* Common error scenarios and their user-friendly messages
*/
export declare const ERROR_MESSAGES: {
readonly INVALID_CONFIG: "Configuration file is invalid or corrupted. Please check your .mcp.json file.";
readonly MISSING_CONFIG: "Configuration file not found. Please create a .mcp.json file with your server configurations.";
readonly INVALID_SERVER_CONFIG: "Server configuration is invalid. Please check the server settings in your configuration file.";
readonly SERVER_NOT_FOUND: "The specified server could not be found. Please check that the server name is correct.";
readonly CONNECTION_REFUSED: "Unable to connect to the server. Please ensure the server is running and accessible.";
readonly CONNECTION_TIMEOUT: "Connection attempt timed out. The server may be overloaded or unreachable.";
readonly CONNECTION_LOST: "Connection to the server was lost. The system will attempt to reconnect automatically.";
readonly SERVER_UNAVAILABLE: "The server is temporarily unavailable. Please try again in a few moments.";
readonly SERVER_MAINTENANCE: "The server is currently undergoing maintenance. Please try again later.";
readonly SERVER_OVERLOADED: "The server is currently overloaded. Please try again in a few moments.";
readonly TOOL_NOT_FOUND: "The requested tool is not available. Please check the tool name or your configuration.";
readonly TOOL_DISABLED: "This tool has been disabled. Please contact your administrator for assistance.";
readonly TOOL_EXECUTION_FAILED: "The tool failed to execute. Please check your parameters and try again.";
readonly INVALID_TOOL_PARAMS: "Invalid parameters provided to the tool. Please check the tool documentation.";
readonly UNAUTHORIZED: "You are not authorized to perform this action. Please check your permissions.";
readonly AUTHENTICATION_FAILED: "Authentication failed. Please check your credentials.";
readonly TOKEN_EXPIRED: "Your session has expired. Please log in again.";
readonly RATE_LIMITED: "Too many requests. Please wait a moment before trying again.";
readonly QUOTA_EXCEEDED: "You have exceeded your usage quota. Please contact your administrator.";
readonly INTERNAL_ERROR: "An internal error occurred. Our team has been notified and is working to resolve the issue.";
readonly SERVICE_DEGRADED: "The service is experiencing degraded performance. Some features may be unavailable.";
readonly MAINTENANCE_MODE: "The system is currently in maintenance mode. Please try again later.";
readonly NETWORK_ERROR: "A network error occurred. Please check your internet connection and try again.";
readonly DNS_ERROR: "Unable to resolve server address. Please check your network configuration.";
readonly SSL_ERROR: "SSL/TLS connection error. Please check your security settings.";
readonly MISSING_REQUIRED_FIELD: "A required field is missing. Please provide all necessary information.";
readonly INVALID_FORMAT: "The provided data is in an invalid format. Please check and correct your input.";
readonly VALUE_OUT_OF_RANGE: "The provided value is outside the acceptable range.";
readonly UNKNOWN_ERROR: "An unexpected error occurred. Please try again, and contact support if the problem persists.";
};
/**
* Error message templates with parameter substitution
*/
export declare const ERROR_TEMPLATES: {
readonly SERVER_UNAVAILABLE_WITH_NAME: "Server '{serverName}' is currently unavailable. Please try again later.";
readonly TOOL_NOT_FOUND_WITH_NAME: "Tool '{toolName}' is not available. Please check your configuration.";
readonly CONNECTION_FAILED_WITH_SERVER: "Failed to connect to server '{serverName}'. Please ensure it is running and accessible.";
readonly TIMEOUT_WITH_OPERATION: "Operation '{operation}' timed out after {timeout}ms. Please try again.";
readonly VALIDATION_FAILED_WITH_FIELD: "Invalid value for field '{field}': {reason}";
readonly TOOL_ERROR_WITH_DETAILS: "Tool '{toolName}' failed: {error}";
readonly SERVER_ERROR_WITH_CODE: "Server error (code: {code}): {message}";
readonly RATE_LIMITED_WITH_RETRY: "Too many requests. Please wait {retryAfter} seconds before trying again.";
readonly QUOTA_EXCEEDED_WITH_LIMIT: "Usage quota exceeded. Limit: {limit}, Current: {current}. Resets at {resetTime}.";
readonly CIRCUIT_BREAKER_OPEN: "Service '{serviceName}' is temporarily unavailable due to repeated failures. Please try again in {recoveryTime} seconds.";
};
/**
* Suggestion messages for common errors
*/
export declare const ERROR_SUGGESTIONS: {
readonly CONNECTION_ERROR: readonly ["Check that the server is running and accessible", "Verify your network connection", "Ensure the server configuration is correct", "Try again in a few moments"];
readonly SERVER_UNAVAILABLE: readonly ["Wait a few moments and try again", "Check if the server is undergoing maintenance", "Verify the server is properly configured", "Contact your administrator if the issue persists"];
readonly TOOL_NOT_FOUND: readonly ["Check the tool name spelling", "Verify the tool is configured in your .mcp.json file", "Ensure the underlying server is connected", "Check if the tool has been renamed or removed"];
readonly CONFIG_ERROR: readonly ["Review your .mcp.json configuration file", "Check for syntax errors in the configuration", "Verify all required fields are present", "Refer to the configuration documentation"];
readonly VALIDATION_ERROR: readonly ["Check that all required parameters are provided", "Verify parameter types and formats", "Review the tool documentation for parameter requirements", "Ensure values are within acceptable ranges"];
readonly TIMEOUT_ERROR: readonly ["Try the operation again", "Check your network connection speed", "Consider breaking large operations into smaller parts", "Contact support if timeouts persist"];
};
/**
* Error category descriptions for users
*/
export declare const ERROR_CATEGORY_DESCRIPTIONS: {
readonly configuration: "Issues with server or tool configuration";
readonly connection: "Problems connecting to underlying servers";
readonly availability: "Temporary server or service unavailability";
readonly tool: "Issues with tool execution or availability";
readonly validation: "Invalid parameters or request format";
readonly routing: "Problems routing requests to the correct server";
readonly health: "Server health monitoring issues";
readonly timeout: "Operations that took too long to complete";
readonly discovery: "Issues discovering available tools";
};
/**
* Utility class for generating user-friendly error messages
*/
export declare class ErrorMessageGenerator {
/**
* Generate a user-friendly message for an error
*/
static getUserMessage(error: Error): string;
/**
* Generate message from template with parameter substitution
*/
static fromTemplate(template: string, params: Record<string, any>): string;
/**
* Get suggestions for an error
*/
static getSuggestions(error: Error): string[];
/**
* Generate a comprehensive error response for users
*/
static generateErrorResponse(error: Error, includeDetails?: boolean): any;
/**
* Format error for logging (with full details)
*/
static formatForLogging(error: Error, context?: Record<string, any>): {
context?: Record<string, any> | undefined;
code?: string | undefined;
category?: string | undefined;
isRetryable?: boolean | undefined;
errorContext?: Record<string, any> | undefined;
name: string;
message: string;
stack: string | undefined;
timestamp: string;
};
/**
* Check if error should be shown to user
*/
static shouldShowToUser(error: Error): boolean;
}
/**
* Common error scenarios with pre-built responses
*/
export declare const COMMON_ERROR_RESPONSES: {
serverUnavailable: (serverName: string) => {
content: {
type: string;
text: string;
}[];
isError: boolean;
suggestions: readonly ["Wait a few moments and try again", "Check if the server is undergoing maintenance", "Verify the server is properly configured", "Contact your administrator if the issue persists"];
};
toolNotFound: (toolName: string) => {
content: {
type: string;
text: string;
}[];
isError: boolean;
suggestions: readonly ["Check the tool name spelling", "Verify the tool is configured in your .mcp.json file", "Ensure the underlying server is connected", "Check if the tool has been renamed or removed"];
};
connectionFailed: (serverName: string, reason?: string) => {
content: {
type: string;
text: string;
}[];
isError: boolean;
suggestions: readonly ["Check that the server is running and accessible", "Verify your network connection", "Ensure the server configuration is correct", "Try again in a few moments"];
};
validationFailed: (field: string, reason: string) => {
content: {
type: string;
text: string;
}[];
isError: boolean;
suggestions: readonly ["Check that all required parameters are provided", "Verify parameter types and formats", "Review the tool documentation for parameter requirements", "Ensure values are within acceptable ranges"];
};
};
//# sourceMappingURL=messages.d.ts.map