export class McpHttpError extends Error { readonly status: number; readonly code: string; readonly headers: Record; constructor(status: number, code: string, message: string, headers: Record = {}) { super(message); this.name = "McpHttpError"; this.status = status; this.code = code; this.headers = headers; } } export function toToolError(error: unknown): string { if (error instanceof McpHttpError) { return `${error.code}: ${error.message}`; } if (error instanceof Error) { return error.message; } return "Unknown MCP tool error."; }