/** * search_docs Tool * * Documentation-specific semantic search MCP tool. Takes a natural language query, * converts it to an embedding vector, and searches the docs LanceDB table for * similar documentation chunks. Optimized for prose content like README files, * guides, and technical documentation. * * Features: * - Natural language documentation search * - Configurable result count (top_k) * - Normalized similarity scores (0.0 - 1.0) * - Search timing information * - Only returns doc files (.md, .txt) */ import { z } from 'zod'; import { MCPError } from '../errors/index.js'; import { type CompactSearchOutput } from '../utils/searchResultProcessing.js'; import type { StrategyOrchestrator } from '../engines/strategyOrchestrator.js'; import { type SearchMode } from '../engines/hybridSearch.js'; /** * Input schema for search_docs tool * * Validates the query string and optional top_k parameter. * SMCP-061: Added mode and alpha parameters for hybrid search. */ export declare const SearchDocsInputSchema: z.ZodObject<{ query: z.ZodString; top_k: z.ZodDefault; compact: z.ZodDefault; mode: z.ZodOptional>; alpha: z.ZodOptional; }, z.core.$strip>; /** * Inferred input type from schema */ export type SearchDocsInput = z.infer; /** * Single search result in the output */ export interface SearchDocsResult { /** Relative file path (forward-slash separated) */ path: string; /** Chunk content text */ text: string; /** Similarity score (0.0 - 1.0, higher is more similar) */ score: number; /** Start line in source file (1-indexed) */ startLine: number; /** End line in source file (1-indexed) */ endLine: number; } /** * Output structure for search_docs tool */ export interface SearchDocsOutput { /** Array of search results sorted by relevance */ results: SearchDocsResult[]; /** Total number of results returned */ totalResults: number; /** Time taken for search in milliseconds */ searchTimeMs: number; /** Warning message if index is in an incomplete state (MCP-15) */ warning?: string; /** Search mode used (SMCP-061) */ searchMode?: SearchMode; } /** * Tool context containing the project path */ export interface DocsToolContext { /** Absolute path to the project root */ projectPath: string; /** Optional strategy orchestrator for flushing pending changes before search */ orchestrator?: StrategyOrchestrator; } /** * Execute semantic search on the documentation index * * Searches the DocsLanceDB index for documentation chunks that are semantically * similar to the provided query. The query is converted to an embedding vector * using the same model used for indexing. * * @param input - The search input containing query and optional top_k * @param context - Tool context containing the project path * @returns Search results with timing information * @throws MCPError with INDEX_NOT_FOUND if no docs index exists for the project * * @example * ```typescript * const results = await searchDocs( * { query: 'how to configure the server', top_k: 10 }, * { projectPath: '/path/to/project' } * ); * * console.log(results.results[0].path); // 'docs/configuration.md' * console.log(results.searchTimeMs); // 45 * ``` */ export declare function searchDocs(input: SearchDocsInput, context: DocsToolContext): Promise; /** * Create a DOCS_INDEX_NOT_FOUND error * * Used when no documentation index exists for a project path. * * @param indexPath - The path where the index was expected */ export declare function docsIndexNotFound(indexPath: string): MCPError; /** * MCP tool definition for search_docs * * This tool provides semantic search over the documentation index. * It does NOT require confirmation as it's a read-only operation. * SMCP-061: Added mode and alpha parameters for hybrid search (currently vector-only for docs). * * @param enhanced - Whether to include enhanced AI guidance hints in the description */ export declare function createSearchDocsTool(enhanced?: boolean): { name: string; description: string; inputSchema: { type: "object"; properties: { query: { type: string; description: string; }; top_k: { type: string; description: string; default: number; minimum: number; maximum: number; }; compact: { type: string; description: string; default: boolean; }; mode: { type: string; enum: string[]; description: string; }; alpha: { type: string; description: string; minimum: number; maximum: number; }; }; required: string[]; }; requiresConfirmation: boolean; }; /** * Default search_docs tool definition (without enhanced hints) * * For backward compatibility. Use createSearchDocsTool(enhanced) for * dynamic description generation. */ export declare const searchDocsTool: { name: string; description: string; inputSchema: { type: "object"; properties: { query: { type: string; description: string; }; top_k: { type: string; description: string; default: number; minimum: number; maximum: number; }; compact: { type: string; description: string; default: boolean; }; mode: { type: string; enum: string[]; description: string; }; alpha: { type: string; description: string; minimum: number; maximum: number; }; }; required: string[]; }; requiresConfirmation: boolean; }; //# sourceMappingURL=searchDocs.d.ts.map