Skip to main content
Glama

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

NameRequiredDescriptionDefault
limitNoMaximum number of results to return (default: 10)
queryYesSearch query to find relevant documents
thresholdNoMinimum similarity threshold (0-1, default: 0.7)

Input Schema (JSON Schema)

{ "properties": { "limit": { "default": 10, "description": "Maximum number of results to return (default: 10)", "type": "number" }, "query": { "description": "Search query to find relevant documents", "type": "string" }, "threshold": { "default": 0.7, "description": "Minimum similarity threshold (0-1, default: 0.7)", "type": "number" } }, "required": [ "query" ], "type": "object" }

Implementation Reference

  • 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), }, ], }; }
  • 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'], }, },
  • 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}`); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/santis84/mcp-rag'

If you have feedback or need assistance with the MCP directory API, please join our Discord server