/** * MCP Response Formatters * * Utilities for formatting SDK responses for MCP tool consumption. * These formatters handle: * - Content truncation with sensible defaults * - Output size controls * - Schema versioning * - Structured error responses */ import { type ErrorContext, type ClassificationContext } from '../types/errors.js'; import type { SmartBrowseResult } from '../core/smart-browser.js'; /** * MCP response content type * This matches the expected return type for MCP tool handlers */ export type McpResponse = { content: Array<{ type: 'text'; text: string; }>; isError?: boolean; }; /** * Options for formatting browse results */ export interface BrowseFormatOptions { maxChars?: number; includeTables?: boolean; includeNetwork?: boolean; includeConsole?: boolean; includeHtml?: boolean; includeInsights?: boolean; } /** * Create a versioned JSON response for MCP tools * All successful responses include schemaVersion for client compatibility */ export declare function jsonResponse(data: object, indent?: number): McpResponse; /** * Create a structured error response for MCP tools (CX-004) * * Returns a structured error with: * - category: High-level error category (network, auth, content, etc.) * - code: Specific error code for programmatic handling * - retryable: Whether the error is likely to succeed on retry * - recommendedActions: Suggested actions for LLM recovery * - context: Additional context about the error */ export declare function errorResponse(error: Error | string, classificationContext?: ClassificationContext, errorContext?: ErrorContext): McpResponse; /** * Truncate content to a maximum length, breaking at word boundaries */ export declare function truncateContent(content: string, maxChars: number): { content: string; wasTruncated: boolean; originalLength: number; }; /** * Format a SmartBrowseResult for MCP consumption * * Applies output size controls and structures the response for LLM consumption. */ export declare function formatBrowseResult(result: SmartBrowseResult, options?: BrowseFormatOptions): Record; /** * Format batch browse results for MCP consumption */ export declare function formatBatchResults(results: Array<{ url: string; status: string; durationMs: number; index: number; error?: string; errorCode?: string; result?: SmartBrowseResult; }>, options?: BrowseFormatOptions): Record[]; //# sourceMappingURL=response-formatters.d.ts.map