il2cpp-dump-analyzer-mcp
Version:
Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games
92 lines (91 loc) • 3.07 kB
TypeScript
/**
* Search Code Tool Implementation
* Demonstrates the new base handler pattern for eliminating code duplication
*/
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';
/**
* Search code tool parameters interface
*/
interface SearchCodeParams {
query: string | string[];
filter_type?: string;
filter_namespace?: string;
filter_monobehaviour?: boolean;
top_k?: number;
}
/**
* Search Code Tool Handler
* Provides semantic search through IL2CPP code with filtering capabilities
*/
export declare class SearchCodeToolHandler extends BaseSearchToolHandler<SearchCodeParams> {
constructor(context: ToolExecutionContext);
/**
* Validate search code specific parameters
*/
protected validateParameters(params: SearchCodeParams): Promise<ValidationResult>;
/**
* Execute the core search logic
*/
protected executeCore(params: SearchCodeParams): Promise<Document[]>;
/**
* Format the search results with enhanced metadata
*/
protected formatResponse(results: Document[], warnings?: string[]): MCPResponse;
/**
* Create search filter from parameters
*/
protected createSearchFilter(params: SearchCodeParams): Record<string, any>;
/**
* Extract query from parameters
*/
protected extractQuery(params: SearchCodeParams): string;
}
/**
* Zod schema for search code tool parameters
*/
export declare const searchCodeSchema: z.ZodObject<{
query: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
filter_type: z.ZodOptional<z.ZodString>;
filter_namespace: z.ZodOptional<z.ZodString>;
filter_monobehaviour: z.ZodOptional<z.ZodBoolean>;
top_k: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
top_k: number;
query: string | string[];
filter_type?: string | undefined;
filter_namespace?: string | undefined;
filter_monobehaviour?: boolean | undefined;
}, {
query: string | string[];
top_k?: number | undefined;
filter_type?: string | undefined;
filter_namespace?: string | undefined;
filter_monobehaviour?: boolean | undefined;
}>;
/**
* Factory function to create and register the search code tool
*/
export declare function createSearchCodeTool(server: any, context: ToolExecutionContext): SearchCodeToolHandler;
export {};
/**
* Example of how to use the new tool handler pattern:
*
* // In mcp-sdk-server.ts:
* import { createSearchCodeTool } from './tools/search-code-tool.js';
*
* // Create tool execution context
* const context: ToolExecutionContext = {
* vectorStore: vectorStore!,
* logger: Logger,
* isInitialized: () => isInitialized
* };
*
* // Register the tool
* createSearchCodeTool(server, context);
*
* This eliminates ~80% of the duplicated code while maintaining all functionality!
*/