Skip to main content
Glama
masseater
by masseater

query

Search uploaded documents using RAG to find answers with citations. Ask questions to retrieve information from your knowledge base.

Instructions

Query the FileSearchStore using RAG (Retrieval-Augmented Generation) to get answers based on uploaded documents. The AI will search through the documents and provide relevant answers with citations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe question or query to search for in the knowledge base

Implementation Reference

  • The execute method that implements the core logic of the 'query' tool: ensures the FileSearchStore exists, performs RAG query using Gemini client, and returns the result with citations.
    async execute(args: QueryArgs): Promise<MCPToolResponse<QueryResult>> {
      const { geminiClient, storeDisplayName, defaultModel } = this.context;
    
      // Ensure store exists
      const store = await geminiClient.ensureStore(storeDisplayName);
    
      // Query the store using the default model from environment variable
      const result = await geminiClient.queryStore({
        storeName: store.name,
        query: args.query,
        model: defaultModel,
      });
    
      return {
        success: true,
        message: `Query completed successfully. Found ${String(result.citations.length)} citation(s).`,
        data: {
          text: result.text,
          citations: result.citations,
          query: args.query,
          model: defaultModel,
          storeName: store.name,
        },
      };
    }
  • Type definitions for input args and output result, the tool name 'query', description, and Zod input schema for validation.
    type QueryArgs = {
      query: string;
    };
    
    type QueryResult = {
      text: string;
      citations: string[];
      query: string;
      model: string;
      storeName: string;
    };
    
    export class QueryTool extends BaseTool<QueryArgs> {
      readonly name = "query";
      readonly description =
        "Query the FileSearchStore using RAG (Retrieval-Augmented Generation) to get answers based on uploaded documents. The AI will search through the documents and provide relevant answers with citations.";
    
      getInputSchema() {
        return z.object({
          query: z
            .string()
            .min(1)
            .describe("The question or query to search for in the knowledge base"),
        });
      }
  • Initializes the ToolRegistry by instantiating the QueryTool (and others) and storing instances in a map keyed by tool name.
    initialize(context: ToolContext): void {
      // Manual tool registration for safety and explicit review
      const tools: Tool[] = [
        new UploadFileTool(context),
        new UploadContentTool(context),
        new QueryTool(context),
      ];
    
      for (const tool of tools) {
        this.toolInstances.set(tool.name, tool);
      }
    
      console.log(`✅ ToolRegistry initialized with ${String(this.toolInstances.size)} tools`);
    }
  • Registers all tools, including 'query', with the MCP server using the tool's name, description, input schema, and bound handler function.
    setupToolHandlers(): void {
      for (const tool of this.toolInstances.values()) {
        // Pass Zod schema directly to MCP SDK
        // SDK handles JSON Schema conversion internally for both stdio and HTTP transports
        this.server.registerTool(
          tool.name,
          {
            description: tool.description,
            inputSchema: tool.getInputSchema().shape,
          },
          tool.handler.bind(tool) as never,
        );
        this.registeredTools.push(tool.name);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses the tool uses RAG for searching and provides answers with citations, which adds some behavioral context beyond the input schema. However, it lacks details on permissions, rate limits, error handling, or response format (beyond 'answers with citations'), which are critical for a query tool. The description doesn't contradict annotations (none exist).

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 two sentences, front-loaded with the core purpose and followed by additional detail on how it works. It avoids redundancy and wastes no words, though it could be slightly more structured (e.g., separating usage notes). Every sentence adds value: the first defines the tool, and the second explains the mechanism and output.

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

Completeness3/5

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

Given the tool's moderate complexity (RAG-based querying), no annotations, no output schema, and a simple input schema, the description is minimally adequate. It covers the purpose and basic behavior but lacks completeness in areas like output details, error cases, or integration with sibling tools. It meets the minimum viable threshold but has clear gaps for effective agent use.

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 input schema has 100% description coverage, with the single parameter 'query' documented as 'The question or query to search for in the knowledge base.' The description adds no additional parameter semantics beyond this, such as examples or constraints on query format. With high schema coverage, the baseline is 3, as the schema already provides adequate parameter information.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Query the FileSearchStore using RAG (Retrieval-Augmented Generation) to get answers based on uploaded documents.' It specifies the verb ('query'), resource ('FileSearchStore'), and method ('RAG'), distinguishing it from sibling tools 'upload_content' and 'upload_file' which are for uploading rather than querying. However, it doesn't explicitly contrast with hypothetical alternative query methods, keeping it at 4 instead of 5.

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

Usage Guidelines3/5

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

The description implies usage context: 'to get answers based on uploaded documents,' suggesting this tool should be used after documents are uploaded via sibling tools. It doesn't provide explicit when-not-to-use guidance or name alternatives for different query types, but the implied dependency on uploaded content offers basic context. No misleading information is present.

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/masseater/gemini-rag-mcp'

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