Skip to main content
Glama

search_documentation

Find relevant documentation information using natural language queries. Search across stored documentation sources to locate specific details, code examples, or related content with ranked results.

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 that executes the tool logic: validates input, generates query embeddings, performs vector search in Qdrant, formats results with titles, URLs, scores, and content.
    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 for the 'search_documentation' tool in the HandlerRegistry.
    this.handlers.set('search_documentation', new SearchDocumentationHandler(this.server, this.apiClient));
  • Tool definition including name, description, and input schema provided in the ListTools MCP 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,

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