Skip to main content
Glama
lethain

Library MCP

by lethain

rebuild

Update the search index when content changes in your local Markdown knowledge base to ensure accurate text search results.

Instructions

Rebuild text index. Useful for when contents have changed on disk

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:458-468 (handler)
    The main handler function for the 'rebuild' tool, registered via @mcp.tool() decorator. It rebuilds the content index by invoking load_content() on the global HugoContentManager instance.
    @mcp.tool()
    async def rebuild() -> bool:
        """Rebuild text index. Useful for when contents have changed on disk"""
        if content_manager is None:
            return False
        
        debug_print("Rebuilding content index...")
        content_manager.load_content()
        debug_print("Content index rebuilt successfully")
        return True
  • The HugoContentManager.load_content() method that performs the actual rebuilding of the content index by scanning Hugo content directories, parsing markdown files with frontmatter, and populating the path_to_content dictionary.
    def load_content(self) -> None:
        """Load all content from the specified directories"""
        self.dir_to_files = {}
        self.path_to_content = {}
        
        for content_dir in self.content_dirs:
            if not os.path.isdir(content_dir):
                debug_print(f"Warning: {content_dir} is not a valid directory, skipping")
                continue
                
            md_files = []
            for root, _, files in os.walk(content_dir):
                for file in files:
                    if file.endswith('.md'):
                        full_path = os.path.join(root, file)
                        md_files.append(full_path)
            
            self.dir_to_files[content_dir] = md_files
            debug_print(f"Found {len(md_files)} markdown files in {content_dir}")
            
            for file_path in md_files:
                try:
                    with open(file_path, 'r', encoding='utf-8') as f:
                        content = f.read()
                    
                    meta, data = self._parse_markdown(content)
                    self.path_to_content[file_path] = ContentFile(
                        path=file_path,
                        meta=meta,
                        data=data
                    )
                except Exception as e:
                    debug_print(f"Error processing {file_path}: {e}")
        
        debug_print(f"Total files processed: {len(self.path_to_content)}")
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 the tool's purpose but doesn't describe what 'rebuild' entails operationally - whether it's destructive, how long it takes, whether it requires specific permissions, or what side effects occur. The phrase 'contents have changed on disk' hints at a maintenance operation but lacks crucial behavioral details like whether existing data is preserved or overwritten during the rebuild.

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 perfectly concise - two short sentences that each earn their place. The first sentence states the core action, the second provides essential usage context. No wasted words, no redundancy, and the most important information (what the tool does) comes first. This is an excellent example of efficient documentation.

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

Completeness3/5

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

Given that this is a maintenance/rebuild operation with no annotations and no output schema, the description should provide more complete context about what happens during execution. While it states the purpose and when to use it, it doesn't describe what 'rebuild' means operationally, what the expected outcome is, or any performance/behavioral characteristics. For a tool that likely modifies system state, this leaves significant gaps in understanding.

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

Parameters4/5

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

The tool has zero parameters with 100% schema description coverage, so the schema already fully documents the parameter situation (none). The description appropriately doesn't discuss parameters since none exist. It focuses instead on the tool's purpose and usage context, which is the right approach for a parameterless tool. A baseline of 4 is appropriate when the schema handles all parameter documentation needs.

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 ('Rebuild text index') and the resource affected ('text index'), making the purpose immediately understandable. It distinguishes this tool from its siblings (which are all query/search tools) by being a maintenance/update operation rather than a data retrieval function. However, it doesn't specify what exactly gets rebuilt or where the index is located, keeping it from a perfect score.

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

Usage Guidelines4/5

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

The description provides explicit guidance on when to use this tool: 'Useful for when contents have changed on disk.' This gives clear context about the triggering condition. However, it doesn't specify when NOT to use it or mention alternatives (though none are obvious among the sibling tools, which are all query operations). The guidance is helpful but could be more comprehensive.

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/lethain/library-mcp'

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