UNPKG

thoughtmcp

Version:

AI that thinks more like humans do - MCP server with human-like cognitive architecture for enhanced reasoning, memory, and self-monitoring

73 lines 2.84 kB
/** * Response formatting utilities for MCP tool outputs * Provides consistent, structured responses with proper error handling */ import { ThoughtResult } from "../types/core.js"; import { AnalysisResult, MemoryResult, RecallResult } from "../types/mcp.js"; export interface FormattedResponse<T = unknown> { success: boolean; data?: T; error?: ErrorDetails; metadata: ResponseMetadata; } export interface ErrorDetails { code: string; message: string; details?: Record<string, unknown>; suggestions?: string[]; } export interface ResponseMetadata { timestamp: number; processing_time_ms: number; tool_name: string; version: string; request_id?: string; } export declare class ResponseFormatter { private static readonly VERSION; /** * Format a successful ThoughtResult response */ static formatThinkResponse(result: ThoughtResult, processingTimeMs: number, requestId?: string): FormattedResponse<ThoughtResult>; /** * Format a successful MemoryResult response */ static formatRememberResponse(result: MemoryResult, processingTimeMs: number, requestId?: string): FormattedResponse<MemoryResult>; /** * Format a successful RecallResult response */ static formatRecallResponse(result: RecallResult, requestId?: string): FormattedResponse<RecallResult>; /** * Format a successful AnalysisResult response */ static formatAnalyzeResponse(result: AnalysisResult, processingTimeMs: number, requestId?: string): FormattedResponse<AnalysisResult>; /** * Format an error response with appropriate error details */ static formatErrorResponse(error: Error | string, toolName: string, processingTimeMs?: number, requestId?: string, additionalDetails?: Record<string, unknown>): FormattedResponse<never>; /** * Format a graceful degradation response when components fail */ static formatDegradedResponse<T>(partialResult: Partial<T>, failedComponents: string[], toolName: string, processingTimeMs: number, requestId?: string): FormattedResponse<Partial<T>>; /** * Format ReasoningStep for consistent output */ private static formatReasoningStep; /** * Categorize errors for appropriate error codes */ private static categorizeError; /** * Generate helpful suggestions based on error type */ private static generateErrorSuggestions; /** * Validate response structure before sending */ static validateResponse<T>(response: FormattedResponse<T>): boolean; /** * Create a minimal fallback response when formatting fails */ static createFallbackResponse(toolName: string, originalError: Error | string, requestId?: string): FormattedResponse<never>; } //# sourceMappingURL=ResponseFormatter.d.ts.map