build_index
Create a search index for documentation to enable quick information retrieval and improve document accessibility.
Instructions
Build search index for docs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Whether to force rebuild index |
Implementation Reference
- src/index.ts:574-583 (handler)Handler for the 'build_index' tool call. Extracts 'force' parameter (unused), calls searchEngine.buildIndex(docDir), and returns success message with document count.case "build_index": { const force = Boolean(request.params.arguments?.force); await searchEngine.buildIndex(docDir); return { content: [{ type: "text", text: `Index built with ${Object.keys(searchEngine['docStore']).length} documents` }] }; }
- src/index.ts:451-459 (schema)Input schema definition for the 'build_index' tool, specifying optional 'force' boolean parameter.inputSchema: { type: "object", properties: { force: { type: "boolean", description: "Whether to force rebuild index" } } }
- src/index.ts:448-460 (registration)Registration of the 'build_index' tool in the ListToolsRequestSchema handler (note: duplicate registration exists at lines 489-501).{ name: "build_index", description: "Build search index for docs", inputSchema: { type: "object", properties: { force: { type: "boolean", description: "Whether to force rebuild index" } } } },
- src/search.ts:32-50 (helper)Core implementation of index building in SearchEngine class: collects .md docs from subdirectories, builds Lunr index, stores docs, and saves index to JSON.async buildIndex(docsDir: string) { const docs = await this.collectDocs(docsDir); this.index = lunr(function() { this.ref('path'); this.field('title'); this.field('content'); docs.forEach(doc => { this.add(doc); }); }); // Store documents separately docs.forEach(doc => { this.docStore[doc.path] = doc; }); await this.saveIndex(); }