/** * Shared error handling for MCP tool handlers. * * Converts arbitrary errors into a typed user-facing tool result, * distinguishing between not-found (404), client errors (400-499), * server errors (500-599), and network/timeout issues. */ export interface ToolErrorContext { /** MCP tool name, e.g. "search_tenders" (used in stderr logs). */ toolName: string; /** Short gerund describing what failed, e.g. "searching tenders". */ action: string; } /** * Converts an unknown error thrown from a tool handler into a typed tool result * with a user-facing message that matches the failure mode. * * Always logs the underlying error to stderr for operator debugging. */ export declare function toToolErrorResult(error: unknown, ctx: ToolErrorContext): { content: { type: "text"; text: string; }[]; isError: boolean; };