Skip to main content
Glama

index_build

Builds search indexes for local documents to enable efficient information retrieval and content analysis within the TOOL4LM environment.

Instructions

Alias of index.build

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rootNo

Implementation Reference

  • The core handler function for building the MiniSearch index. It collects files from the sandbox directory (or provided root), extracts text from txt/md/html/pdf files, indexes them, and saves the index to .cache/index.json.
    export async function indexBuild(root?: string) {
      const base = root ? path.resolve(root) : CONFIG.sandboxDir;
      const files = await collectFiles(base);
      const docs: DocRecord[] = [];
      for (const p of files) {
        const { title, text } = await fileToText(p);
        docs.push({ id: p, path: p, title, text });
      }
      const mini = new MiniSearch({
        fields: ['title','text'],
        storeFields: ['path','title'],
        searchOptions: { boost: { title: 2 } }
      });
      mini.addAll(docs);
      const payload = { docs, index: mini.toJSON() };
      await fs.mkdir(path.dirname(INDEX_PATH), { recursive: true }).catch(()=>{});
      await fs.writeFile(INDEX_PATH, JSON.stringify(payload));
      return { ok: true, indexed: docs.length };
    }
  • src/server.ts:150-156 (registration)
    Registers the 'index_build' tool on the MCP server, which is an alias calling the indexBuild handler with the provided root parameter.
    server.tool('index_build', 'Alias of index.build',
      indexBuildShape, OPEN,
      async ({ root }) => {
        const res = await indexBuild(root);
        return { content: [{ type: 'text', text: JSON.stringify(res) }] };
      }
    );
  • src/server.ts:143-149 (registration)
    Primary registration of the 'index.build' tool on the MCP server, calling the indexBuild handler.
    server.tool('index.build', 'Build MiniSearch index for documents in sandbox directory.',
      indexBuildShape, OPEN,
      async ({ root }) => {
        const res = await indexBuild(root);
        return { content: [{ type: 'text', text: JSON.stringify(res) }] };
      }
    );
  • Zod schema definition for the index_build / index.build tool input: optional root directory string.
    const indexBuildShape = { root: z.string().optional() };
  • Helper function to recursively collect supported document files (txt, md, html, pdf) from the directory.
    async function collectFiles(root: string): Promise<string[]> {
      const out: string[] = [];
      async function walk(dir: string) {
        const ents = await fs.readdir(dir, { withFileTypes: true });
        for (const e of ents) {
          const p = path.join(dir, e.name);
          if (e.isDirectory()) await walk(p);
          else if (/(\.txt|\.md|\.html?|\.pdf)$/i.test(e.name)) out.push(p);
        }
      }
      await walk(root);
      return out;
    }
Behavior3/5

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

The description adds no behavioral context beyond the openWorldHint annotation (which suggests the tool can handle diverse inputs). It doesn't disclose traits like whether it's read-only, destructive, or has rate limits. However, it doesn't contradict the annotation, so it meets the lower bar with annotations present but adds minimal value.

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—a single phrase—with zero wasted words. It's front-loaded and efficiently conveys the alias relationship, though this comes at the cost of clarity. Every sentence (here, the only one) earns its place by establishing the tool's identity.

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 tool's complexity (implied by indexing operations), lack of output schema, and minimal annotations, the description is incomplete. It doesn't explain what the tool does, how to use it, or what it returns, making it inadequate for an agent to understand and invoke the tool effectively.

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

Parameters2/5

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

With 0% schema description coverage and one parameter (root), the description provides no information about the parameter's meaning, format, or usage. It fails to compensate for the lack of schema documentation, leaving the parameter's purpose and semantics unexplained.

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

Purpose2/5

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

The description 'Alias of index.build' is tautological—it restates the tool name without explaining what the tool actually does. It doesn't specify the verb (e.g., 'builds an index') or the resource (e.g., 'from a root directory'), leaving the purpose vague. While it distinguishes from siblings by referencing another tool, it fails to state the core functionality.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't explain why one would choose index_build over index.build or other indexing/search tools in the sibling list. There's no mention of context, prerequisites, or exclusions, leaving usage unclear.

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/khanhs-234/tool4lm'

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