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

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

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}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic action ('Search for relevant documents') without detailing what 'relevant' means, how results are ranked, whether there are rate limits, authentication needs, or what happens on failure. This is inadequate for a search tool with potential complexity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized for a basic search function, though it could be more informative without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the search returns (e.g., document metadata, snippets, scores), how results are formatted, or any error conditions. For a search tool with three parameters and no structured output info, this leaves significant gaps for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter semantics beyond what the input schema provides. Since schema description coverage is 100%, the baseline score is 3. The description doesn't explain how 'query' relates to document content, what 'threshold' implies for relevance, or how 'limit' affects performance, offering no additional value over the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as 'Search for relevant documents in the RAG system', which is clear but vague. It specifies the verb ('Search') and resource ('documents in the RAG system'), but doesn't distinguish it from sibling tools like 'search_memory' or 'list_files', leaving ambiguity about what makes this search unique.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'search_files' over 'search_memory' or 'list_files', nor does it specify any prerequisites or exclusions, leaving the agent to infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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