Skip to main content
Glama

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
NameRequiredDescriptionDefault
forceNoWhether to force rebuild index

Implementation Reference

  • 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` }] }; }
  • 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" } } } },
  • 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(); }

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