search_files
Find relevant documents in the RAG system using semantic search with customizable similarity thresholds and result limits.
Instructions
Search for relevant documents in the RAG system
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results to return (default: 10) | |
| query | Yes | Search query to find relevant documents | |
| threshold | No | Minimum similarity threshold (0-1, default: 0.7) |
Implementation Reference
- src/index.ts:342-360 (handler)The primary handler function for the MCP 'search_files' tool. It receives arguments from the MCP CallToolRequest, calls RAGService.searchFiles, and returns the results formatted as MCP content.private async handleSearchFiles(args: { query: string; limit?: number; threshold?: number; }) { const results = await this.ragService.searchFiles(args.query, { limit: args.limit || 10, threshold: args.threshold || 0.7, }); return { content: [ { type: 'text', text: JSON.stringify(results, null, 2), }, ], }; }
- src/index.ts:51-70 (schema)Input schema defining the parameters for the 'search_files' tool: query (required string), optional limit and threshold numbers.inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query to find relevant documents', }, limit: { type: 'number', description: 'Maximum number of results to return (default: 10)', default: 10, }, threshold: { type: 'number', description: 'Minimum similarity threshold (0-1, default: 0.7)', default: 0.7, }, }, required: ['query'], },
- src/index.ts:48-71 (registration)Tool registration in the ListToolsRequest handler, including name, description, and schema.{ name: 'search_files', description: 'Search for relevant documents in the RAG system', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query to find relevant documents', }, limit: { type: 'number', description: 'Maximum number of results to return (default: 10)', default: 10, }, threshold: { type: 'number', description: 'Minimum similarity threshold (0-1, default: 0.7)', default: 0.7, }, }, required: ['query'], }, },
- src/services/ragService.ts:70-81 (helper)RAGService method implementing file search logic by delegating to VectorDatabase.searchDocuments with logging and error handling.async searchFiles( query: string, options: SearchOptions = {} ): Promise<SearchResult[]> { try { logger.info(`Searching files with query: "${query}"`); return await this.vectorDatabase.searchDocuments(query, options); } catch (error) { logger.error(`Error searching files: ${error}`); throw new Error(`Search failed: ${error}`); } }