Skip to main content
Glama

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)}")

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