il2cpp-dump-analyzer-mcp
Version:
Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games
90 lines (89 loc) • 3 kB
TypeScript
/**
* Find MonoBehaviours Tool Implementation
* Demonstrates the base handler pattern for specialized search tools
*/
import { z } from 'zod';
import { Document } from '@langchain/core/documents';
import { BaseSearchToolHandler, ToolExecutionContext } from '../base-tool-handler';
import { ValidationResult } from '../../utils/parameter-validator';
import { MCPResponse } from '../../utils/mcp-response-formatter';
/**
* Find MonoBehaviours tool parameters interface
*/
interface FindMonoBehavioursParams {
query?: string;
top_k?: number;
}
/**
* Find MonoBehaviours Tool Handler
* Specialized tool for finding Unity MonoBehaviour classes
*/
export declare class FindMonoBehavioursToolHandler extends BaseSearchToolHandler<FindMonoBehavioursParams> {
private currentParams?;
constructor(context: ToolExecutionContext);
/**
* Validate MonoBehaviour search parameters
*/
protected validateParameters(params: FindMonoBehavioursParams): Promise<ValidationResult>;
/**
* Execute MonoBehaviour search
*/
protected executeCore(params: FindMonoBehavioursParams): Promise<Document[]>;
/**
* Format MonoBehaviour results with specialized metadata
*/
protected formatResponse(results: Document[], warnings?: string[]): MCPResponse;
/**
* Extract query from parameters (handles optional query)
*/
protected extractQuery(params: FindMonoBehavioursParams): string;
/**
* Create filter for MonoBehaviour search (always the same)
*/
protected createSearchFilter(params: FindMonoBehavioursParams): Record<string, any>;
}
/**
* Zod schema for find MonoBehaviours tool parameters
*/
export declare const findMonoBehavioursSchema: z.ZodObject<{
query: z.ZodOptional<z.ZodString>;
top_k: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
top_k: number;
query?: string | undefined;
}, {
top_k?: number | undefined;
query?: string | undefined;
}>;
/**
* Factory function to create and register the find MonoBehaviours tool
*/
export declare function createFindMonoBehavioursTool(server: any, context: ToolExecutionContext): FindMonoBehavioursToolHandler;
export {};
/**
* Comparison: Before vs After
*
* BEFORE (Original implementation):
* - 68 lines of duplicated boilerplate code
* - Manual error handling
* - Inconsistent parameter validation
* - Repeated logging patterns
* - Manual response formatting
*
* AFTER (New implementation):
* - 15 lines of core business logic
* - Automatic error handling via base class
* - Consistent parameter validation
* - Standardized logging
* - Automatic response formatting
*
* REDUCTION: ~78% less code while maintaining all functionality!
*
* Benefits:
* ✅ Consistent error handling across all tools
* ✅ Standardized parameter validation
* ✅ Automatic logging and timing
* ✅ Consistent response formatting
* ✅ Easier to test and maintain
* ✅ Faster development of new tools
*/