Skip to main content
Glama

refresh_index

Manually refresh the project index after file system changes to ensure search results are complete and current.

Instructions

Manually refresh the project index when files have been added/removed/moved.

Use when:
- File watcher is disabled or unavailable
- After large-scale operations (git checkout, merge, pull) that change many files
- When you want immediate index rebuild without waiting for file watcher debounce
- When find_files results seem incomplete or outdated
- For troubleshooting suspected index synchronization issues

Important notes for LLMs:
- Always available as backup when file watcher is not working
- Performs full project re-indexing for complete accuracy
- Use when you suspect the index is stale after file system changes
- **Call this after programmatic file modifications if file watcher seems unresponsive**
- Complements the automatic file watcher system

Returns:
    Success message with total file count

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'refresh_index' MCP tool. It is decorated with @mcp.tool() which registers it as a tool named 'refresh_index'. The function delegates the actual index rebuilding to IndexManagementService.rebuild_index().
    @mcp.tool()
    @handle_mcp_tool_errors(return_type='str')
    def refresh_index(ctx: Context) -> str:
        """
        Manually refresh the project index when files have been added/removed/moved.
    
        Use when:
        - File watcher is disabled or unavailable
        - After large-scale operations (git checkout, merge, pull) that change many files
        - When you want immediate index rebuild without waiting for file watcher debounce
        - When find_files results seem incomplete or outdated
        - For troubleshooting suspected index synchronization issues
    
        Important notes for LLMs:
        - Always available as backup when file watcher is not working
        - Performs full project re-indexing for complete accuracy
        - Use when you suspect the index is stale after file system changes
        - **Call this after programmatic file modifications if file watcher seems unresponsive**
        - Complements the automatic file watcher system
    
        Returns:
            Success message with total file count
        """
        return IndexManagementService(ctx).rebuild_index()
  • Supporting method in IndexManagementService called by the refresh_index tool handler. Implements the shallow index rebuild logic.
    def rebuild_index(self) -> str:
        """
        Rebuild the project index (DEFAULT: shallow file list).
    
        For deep/symbol rebuilds, use build_deep_index() tool instead.
    
        Returns:
            Success message with rebuild information
    
        Raises:
            ValueError: If project not set up or rebuild fails
        """
        # Business validation
        self._validate_rebuild_request()
    
        # Get user-configured exclude patterns
        excludes = self._get_exclude_patterns()
    
        # Shallow rebuild only (fast path)
        if not self._shallow_manager.set_project_path(self.base_path, excludes):
            raise RuntimeError("Failed to set project path (shallow) in index manager")
        if not self._shallow_manager.build_index():
            raise RuntimeError("Failed to rebuild shallow index")
    
        try:
            count = len(self._shallow_manager.get_file_list())
        except Exception:
            count = 0
        return f"Shallow index re-built with {count} files."
Behavior4/5

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

With no annotations provided, the description carries full burden and effectively discloses behavioral traits: it performs 'full project re-indexing for complete accuracy', is 'always available as backup', and complements the automatic file watcher. It doesn't mention rate limits or auth needs, but covers key operational context.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, usage scenarios, notes, returns) and uses bullet points for readability. It's slightly verbose but each sentence adds value, such as troubleshooting guidance and backup utility.

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

Completeness5/5

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

Given 0 parameters, no annotations, and an output schema (implied by 'Returns' section), the description is complete: it explains when to use, behavioral details, and the success message output, covering all necessary context without relying on structured fields.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately focuses on usage context rather than parameters, maintaining clarity without redundancy.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('manually refresh', 're-indexing') and resource ('project index'), distinguishing it from siblings like 'configure_file_watcher' or 'find_files' by focusing on manual index rebuilding rather than configuration or search.

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

Usage Guidelines5/5

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

The description provides explicit usage scenarios in a bulleted list ('Use when:'), including when file watcher is disabled, after large-scale operations, for troubleshooting, and when find_files results are incomplete. It also mentions alternatives implicitly by referencing the file watcher system.

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/johnhuang316/code-index-mcp'

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