il2cpp-dump-analyzer-mcp
Version:
Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games
116 lines (115 loc) • 3.81 kB
TypeScript
/**
* MCP Response Formatting Utilities
* Standardizes response formatting across all MCP tools to eliminate duplication
*/
import { Document } from '@langchain/core/documents';
/**
* Standard MCP response structure
*/
export interface MCPResponse {
content: Array<{
type: 'text' | 'resource';
text?: string;
uri?: string;
metadata?: Record<string, any>;
}>;
}
/**
* Search result metadata interface
*/
export interface SearchResultMetadata {
searchQuery?: string;
appliedFilters?: Record<string, any>;
resultCount: number;
totalTime?: number;
adjustedParameters?: Record<string, any>;
warnings?: string[];
}
/**
* Tool execution metadata interface
*/
export interface ToolExecutionMetadata {
toolName: string;
executionTime: number;
parametersUsed: Record<string, any>;
warnings?: string[];
adjustments?: Record<string, any>;
}
/**
* MCP response formatting utilities
*/
export declare class MCPResponseFormatter {
/**
* Format a simple text response
*/
static formatTextResponse(content: string | object, metadata?: Record<string, any>): MCPResponse;
/**
* Format search results from vector store
*/
static formatSearchResults(results: Document[], searchQuery: string, appliedFilters?: Record<string, any>, metadata?: Partial<SearchResultMetadata>): MCPResponse;
/**
* Format error response with consistent structure
*/
static formatErrorResponse(error: Error | string, toolName: string, parameters?: Record<string, any>): MCPResponse;
/**
* Format analysis results with summary and details
*/
static formatAnalysisResults(analysis: any, toolName: string, parameters: Record<string, any>, executionTime?: number): MCPResponse;
/**
* Format generation results (for code generation tools)
*/
static formatGenerationResults(generatedCode: string, metadata: {
className?: string;
fileName?: string;
language?: string;
warnings?: string[];
statistics?: Record<string, any>;
}): MCPResponse;
/**
* Format list results with pagination info
*/
static formatListResults(items: any[], pagination?: {
offset?: number;
limit?: number;
total?: number;
hasMore?: boolean;
}, metadata?: Record<string, any>): MCPResponse;
/**
* Format resource response for MCP resource handlers
*/
static formatResourceResponse(results: Document[], resourceUri: string, queryString?: string, filter?: Record<string, any>): {
contents: Array<{
uri: string;
text: string;
metadata: any;
}>;
};
/**
* Format validation results with errors and warnings
*/
static formatValidationResults(isValid: boolean, errors?: string[], warnings?: string[], data?: any): MCPResponse;
/**
* Format pattern detection results
*/
static formatPatternResults(detectedPatterns: Record<string, any[]>, summary: {
totalPatternsFound: number;
patternTypeCount: number;
architecturalInsights: string[];
}, metadata: Record<string, any>): MCPResponse;
/**
* Safe JSON stringify with circular reference handling
*/
static safeJsonStringify(obj: any, indent?: number): string;
/**
* Add execution timing to response
*/
static addExecutionTiming<T extends MCPResponse>(response: T, startTime: number, toolName: string): T;
/**
* Add warnings to response
*/
static addWarnings<T extends MCPResponse>(response: T, warnings: string[]): T;
/**
* Create a standardized "not found" response
*/
static formatNotFoundResponse(searchTerm: string, searchType?: string): MCPResponse;
}