Skip to main content
Glama
jumasheff

RAG Documentation MCP Server

by jumasheff

search_documentation

Find relevant information across stored documentation using natural language queries. Returns ranked excerpts with context for specific details, code examples, or related documentation.

Instructions

Search through stored documentation using natural language queries. Use this tool to find relevant information across all stored documentation sources. Returns matching excerpts with context, ranked by relevance. Useful for finding specific information, code examples, or related documentation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe text to search for in the documentation. Can be a natural language query, specific terms, or code snippets.
limitNoMaximum number of results to return (1-20). Higher limits provide more comprehensive results but may take longer to process. Default is 5.

Implementation Reference

  • The SearchDocumentationHandler class contains the handle() method that executes the core tool logic: generates embeddings for the query, performs vector search in Qdrant, formats results with titles, URLs, scores, and content excerpts.
    export class SearchDocumentationHandler extends BaseHandler {
      async handle(args: any): Promise<McpToolResponse> {
        if (!args.query || typeof args.query !== 'string') {
          throw new McpError(ErrorCode.InvalidParams, 'Query is required');
        }
    
        const limit = args.limit || 5;
    
        try {
          const queryEmbedding = await this.apiClient.getEmbeddings(args.query);
          
          const searchResults = await this.apiClient.qdrantClient.search(COLLECTION_NAME, {
            vector: queryEmbedding,
            limit,
            with_payload: true,
            with_vector: false, // Optimize network transfer by not retrieving vectors
            score_threshold: 0.7, // Only return relevant results
          });
    
          const formattedResults = searchResults.map(result => {
            if (!isDocumentPayload(result.payload)) {
              throw new Error('Invalid payload type');
            }
            return `[${result.payload.title}](${result.payload.url})\nScore: ${result.score.toFixed(3)}\nContent: ${result.payload.text}\n`;
          }).join('\n---\n');
    
          return {
            content: [
              {
                type: 'text',
                text: formattedResults || 'No results found matching the query.',
              },
            ],
          };
        } catch (error) {
          if (error instanceof Error) {
            if (error.message.includes('unauthorized')) {
              throw new McpError(
                ErrorCode.InvalidRequest,
                'Failed to authenticate with Qdrant cloud while searching'
              );
            } else if (error.message.includes('ECONNREFUSED') || error.message.includes('ETIMEDOUT')) {
              throw new McpError(
                ErrorCode.InternalError,
                'Connection to Qdrant cloud failed while searching'
              );
            }
          }
          return {
            content: [
              {
                type: 'text',
                text: `Search failed: ${error}`,
              },
            ],
            isError: true,
          };
        }
      }
    }
  • Registers the SearchDocumentationHandler instance in the handlers map with the key 'search_documentation' for tool dispatch.
    this.handlers.set('search_documentation', new SearchDocumentationHandler(this.server, this.apiClient));
  • Defines the tool metadata including name, description, and inputSchema for 'search_documentation' in the ListTools response.
    {
      name: 'search_documentation',
      description: 'Search through stored documentation using natural language queries. Use this tool to find relevant information across all stored documentation sources. Returns matching excerpts with context, ranked by relevance. Useful for finding specific information, code examples, or related documentation.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'The text to search for in the documentation. Can be a natural language query, specific terms, or code snippets.',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results to return (1-20). Higher limits provide more comprehensive results but may take longer to process. Default is 5.',
            default: 5,
          },
        },
        required: ['query'],
      },
    } as ToolDefinition,
  • Alternative tool definition and schema in the client-side or base tool class.
    get definition(): ToolDefinition {
      return {
        name: 'search_documentation',
        description: 'Search through stored documentation',
        inputSchema: {
          type: 'object',
          properties: {
            query: {
              type: 'string',
              description: 'Search query',
            },
            limit: {
              type: 'number',
              description: 'Maximum number of results to return',
              default: 5,
            },
          },
          required: ['query'],
        },
      };
    }
Behavior3/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 describes key behaviors like returning 'matching excerpts with context, ranked by relevance' and mentions performance implications ('higher limits may take longer'), but lacks details on permissions, rate limits, or error handling that would be important for a search tool.

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

Conciseness5/5

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

The description is efficiently structured in three sentences: purpose statement, usage guidance, and behavioral details. Every sentence adds value without redundancy, and it's appropriately front-loaded with the core functionality.

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?

For a search tool with 2 parameters, 100% schema coverage, and no output schema, the description provides adequate context about what the tool does and returns, but could be more complete by explaining the format of returned excerpts or clarifying what 'stored documentation sources' encompasses relative to sibling tools.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds marginal value by reinforcing that queries can be 'natural language' and mentioning the relevance ranking, but doesn't provide additional semantic context beyond what's in the parameter descriptions.

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

Purpose5/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 with specific verbs ('search through stored documentation') and resources ('documentation sources'), distinguishing it from siblings like 'remove_documentation' or 'list_sources' by focusing on search functionality rather than management operations.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('to find relevant information across all stored documentation sources') and mentions specific use cases ('finding specific information, code examples, or related documentation'), but does not explicitly state when not to use it or name alternatives among sibling tools.

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/jumasheff/mcp-ragdoc-fork'

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