Skip to main content
Glama

build_index

Generate and update search indexes for documentation to enable efficient and accurate search functionality. Supports optional forced rebuilds to refresh index data.

Instructions

Build search index for docs

Input Schema

NameRequiredDescriptionDefault
forceNoWhether to force rebuild index

Input Schema (JSON Schema)

{ "properties": { "force": { "description": "Whether to force rebuild index", "type": "boolean" } }, "type": "object" }

Implementation Reference

  • src/index.ts:448-460 (registration)
    Registration of the build_index tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: "build_index", description: "Build search index for docs", inputSchema: { type: "object", properties: { force: { type: "boolean", description: "Whether to force rebuild index" } } } },
  • MCP tool handler for 'build_index' in CallToolRequestSchema: parses arguments, invokes searchEngine.buildIndex, 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` }] }; }
  • Core helper method in SearchEngine class that implements index building: scans directories for .md files, constructs Lunr index, stores documents, and persists index to JSON file.
    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(); }

Other Tools

Related 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/askme765cs/open-docs-mcp'

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