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();
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions building a search index but doesn't clarify if this is a read-only or destructive operation, what permissions are needed, or how it interacts with other tools. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just four words, with no wasted language. It's front-loaded and gets straight to the point, making it efficient for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, and the tool's potential complexity (building an index could involve mutation or side effects), the description is insufficient. It doesn't explain what 'build' entails operationally or what the result looks like, leaving the agent with incomplete context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'force' documented in the schema. The description doesn't add any parameter-specific details beyond what the schema provides, so it meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Build') and target resource ('search index for docs'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'crawl_docs' or 'search_docs' that might involve indexing operations, so it doesn't reach the highest clarity level.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'crawl_docs' or 'search_docs', nor does it mention prerequisites or exclusions. It's a basic statement of function without context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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