refresh_search_tools
Manually re-detect available command-line search tools on your system to update the tool list after installing new ones.
Instructions
Manually re-detect the available command-line search tools on the system. This is useful if you have installed a new tool (like ripgrep) after starting the server.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The core handler: refresh_search_tools() on SearchService calls settings.refresh_available_strategies() to re-detect available CLI search tools, then returns the updated tool list and preferred tool.
def refresh_search_tools(self) -> str: """Refresh the available search tools.""" if not self.settings: raise ValueError("Settings not available") self.settings.refresh_available_strategies() config = self.settings.get_search_tools_config() available = config['available_tools'] preferred = config['preferred_tool'] return f"Search tools refreshed. Available: {available}. Preferred: {preferred}." - src/code_index_mcp/server.py:500-507 (registration)Registers 'refresh_search_tools' as an MCP tool via @mcp.tool() decorator. Delegates to SearchService.refresh_search_tools().
@mcp.tool() @handle_mcp_tool_errors(return_type="str") def refresh_search_tools(ctx: Context) -> str: """ Manually re-detect the available command-line search tools on the system. This is useful if you have installed a new tool (like ripgrep) after starting the server. """ return SearchService(ctx).refresh_search_tools() - ProjectSettings.refresh_available_strategies() – triggers rescanning of installed CLI tools by calling _get_available_strategies().
def refresh_available_strategies(self): """ Force a refresh of the available search tools list. """ self.available_strategies = _get_available_strategies() - _get_available_strategies() – iterates the priority-ordered SEARCH_STRATEGY_CLASSES, instantiates each, and collects those that are available on the system.
def _get_available_strategies() -> list[SearchStrategy]: """ Detect and return a list of available search strategy instances, ordered by preference. """ available = [] for strategy_class in SEARCH_STRATEGY_CLASSES: try: strategy = strategy_class() if strategy.is_available(): available.append(strategy) except Exception: pass return available - get_search_tools_config() – returns the available_tools list and preferred_tool name, used to format the output of refresh_search_tools.
def get_search_tools_config(self): """Get the configuration of available search tools. Returns: dict: A dictionary containing the list of available tool names. """ return { "available_tools": [s.name for s in self.available_strategies], "preferred_tool": self.get_preferred_search_tool().name if self.available_strategies else None, }