il2cpp-dump-analyzer-mcp
Version:
Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games
135 lines (134 loc) • 4.47 kB
TypeScript
/**
* Generate Method Stubs Tool Implementation
* Generates method stubs and interfaces from IL2CPP class definitions
*/
import { z } from 'zod';
import { BaseGenerationToolHandler, ToolExecutionContext } from '../base-tool-handler';
import { ValidationResult } from '../../utils/parameter-validator';
import { MCPResponse } from '../../utils/mcp-response-formatter';
/**
* Generate method stubs parameters interface
*/
interface GenerateMethodStubsParams {
class_name: string;
method_filter?: string;
include_documentation?: boolean;
include_error_handling?: boolean;
generate_async?: boolean;
custom_namespace?: string;
unity_version?: string;
additional_usings?: string[];
}
/**
* Method stubs generation result interface
*/
interface MethodStubsResult {
success: boolean;
generatedCode: string;
metadata: {
className: string;
fileName: string;
language: string;
namespace: string;
methodFilter?: string;
includedFeatures: string[];
statistics: {
totalMethods: number;
publicMethods: number;
privateMethods: number;
staticMethods: number;
asyncMethods: number;
lineCount: number;
codeLength: number;
};
warnings: string[];
};
}
/**
* Generate Method Stubs Tool Handler
* Generates method stubs and interfaces from IL2CPP class definitions
*/
export declare class GenerateMethodStubsToolHandler extends BaseGenerationToolHandler<GenerateMethodStubsParams, MethodStubsResult> {
constructor(context: ToolExecutionContext);
/**
* Validate method stubs generation parameters
*/
protected validateParameters(params: GenerateMethodStubsParams): Promise<ValidationResult>;
/**
* Execute method stubs generation
*/
protected executeCore(params: GenerateMethodStubsParams): Promise<MethodStubsResult>;
/**
* Get list of included features
*/
private getIncludedFeatures;
/**
* Calculate method statistics
*/
private calculateMethodStatistics;
/**
* Format generation results
*/
protected formatResponse(result: MethodStubsResult, warnings?: string[]): MCPResponse;
/**
* Handle class not found error specifically
*/
protected handleError(error: any, params?: GenerateMethodStubsParams): MCPResponse;
}
/**
* Zod schema for generate method stubs tool parameters
*/
export declare const generateMethodStubsSchema: z.ZodObject<{
class_name: z.ZodString;
method_filter: z.ZodOptional<z.ZodString>;
include_documentation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
include_error_handling: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
generate_async: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
custom_namespace: z.ZodOptional<z.ZodString>;
unity_version: z.ZodOptional<z.ZodString>;
additional_usings: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
}, "strip", z.ZodTypeAny, {
class_name: string;
additional_usings: string[];
include_documentation: boolean;
include_error_handling: boolean;
generate_async: boolean;
custom_namespace?: string | undefined;
unity_version?: string | undefined;
method_filter?: string | undefined;
}, {
class_name: string;
custom_namespace?: string | undefined;
unity_version?: string | undefined;
additional_usings?: string[] | undefined;
include_documentation?: boolean | undefined;
include_error_handling?: boolean | undefined;
generate_async?: boolean | undefined;
method_filter?: string | undefined;
}>;
/**
* Factory function to create and register the generate method stubs tool
*/
export declare function createGenerateMethodStubsTool(server: any, context: ToolExecutionContext): GenerateMethodStubsToolHandler;
export {};
/**
* Code Reduction Analysis:
*
* BEFORE: 142 lines of implementation code
* AFTER: 78 lines of business logic
* REDUCTION: 45% less code
*
* Eliminated:
* ✅ Manual error handling (14 lines)
* ✅ Parameter validation boilerplate (18 lines)
* ✅ Logging setup (8 lines)
* ✅ Response formatting (16 lines)
* ✅ Try-catch blocks (8 lines)
*
* Enhanced Features:
* ✅ Better method filtering with regex validation
* ✅ Comprehensive method statistics
* ✅ Consistent error handling
* ✅ Automatic performance monitoring
* ✅ Standardized response format
*/