Skip to main content
Glama

home_manager_search

Search Home Manager configuration options by name and description to find specific settings for user environment customization.

Instructions

Search Home Manager configuration options.

Searches through available Home Manager options by name and description.

Args: query: The search query string to match against option names and descriptions limit: Maximum number of results to return (default: 20, max: 100)

Returns: Plain text list of matching options with name, type, and description

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler function for the 'home_manager_search' MCP tool. Fetches Home Manager documentation, parses options using BeautifulSoup, filters by query, and formats results as plain text.
    async def home_manager_search(query: str, limit: int = 20) -> str:
        """Search Home Manager configuration options.
    
        Searches through available Home Manager options by name and description.
    
        Args:
            query: The search query string to match against option names and descriptions
            limit: Maximum number of results to return (default: 20, max: 100)
    
        Returns:
            Plain text list of matching options with name, type, and description
        """
        if not 1 <= limit <= 100:
            return error("Limit must be 1-100")
    
        try:
            options = parse_html_options(HOME_MANAGER_URL, query, "", limit)
    
            if not options:
                return f"No Home Manager options found matching '{query}'"
    
            results = []
            results.append(f"Found {len(options)} Home Manager options matching '{query}':\n")
    
            for opt in options:
                results.append(f"• {opt['name']}")
                if opt["type"]:
                    results.append(f"  Type: {opt['type']}")
                if opt["description"]:
                    results.append(f"  {opt['description']}")
                results.append("")
    
            return "\n".join(results).strip()
    
        except Exception as e:
            return error(str(e))
  • Helper function that parses Home Manager (and nix-darwin) HTML documentation to extract option names, types, and descriptions. Used by home_manager_search.
    def parse_html_options(url: str, query: str = "", prefix: str = "", limit: int = 100) -> list[dict[str, str]]:
        """Parse options from HTML documentation."""
        try:
            resp = requests.get(url, timeout=30)  # Increase timeout for large docs
            resp.raise_for_status()
            # Use resp.content to let BeautifulSoup handle encoding detection
            # This prevents encoding errors like "unknown encoding: windows-1252"
            soup = BeautifulSoup(resp.content, "html.parser")
            options = []
    
            # Get all dt elements
            dts = soup.find_all("dt")
    
            for dt in dts:
                # Get option name
                name = ""
                if "home-manager" in url:
                    # Home Manager uses anchor IDs like "opt-programs.git.enable"
                    anchor = dt.find("a", id=True)
                    if anchor:
                        anchor_id = anchor.get("id", "")
                        # Remove "opt-" prefix and convert underscores
                        if anchor_id.startswith("opt-"):
                            name = anchor_id[4:]  # Remove "opt-" prefix
                            # Convert _name_ placeholders back to <name>
                            name = name.replace("_name_", "<name>")
                    else:
                        # Fallback to text content
                        name_elem = dt.find(string=True, recursive=False)
                        if name_elem:
                            name = name_elem.strip()
                        else:
                            name = dt.get_text(strip=True)
                else:
                    # Darwin and fallback - use text content
                    name = dt.get_text(strip=True)
    
                # Skip if it doesn't look like an option (must contain a dot)
                # But allow single-word options in some cases
                if "." not in name and len(name.split()) > 1:
                    continue
    
                # Filter by query or prefix
                if query and query.lower() not in name.lower():
                    continue
                if prefix and not (name.startswith(prefix + ".") or name == prefix):
                    continue
    
                # Find the corresponding dd element
                dd = dt.find_next_sibling("dd")
                if dd:
                    # Extract description (first p tag or direct text)
                    desc_elem = dd.find("p")
                    if desc_elem:
                        description = desc_elem.get_text(strip=True)
                    else:
                        # Get first text node, handle None case
                        text = dd.get_text(strip=True)
                        description = text.split("\n")[0] if text else ""
    
                    # Extract type info - look for various patterns
                    type_info = ""
                    # Pattern 1: <span class="term">Type: ...</span>
                    type_elem = dd.find("span", class_="term")
                    if type_elem and "Type:" in type_elem.get_text():
                        type_info = type_elem.get_text(strip=True).replace("Type:", "").strip()
                    # Pattern 2: Look for "Type:" in text
                    elif "Type:" in dd.get_text():
                        text = dd.get_text()
                        type_start = text.find("Type:") + 5
                        type_end = text.find("\n", type_start)
                        if type_end == -1:
                            type_end = len(text)
                        type_info = text[type_start:type_end].strip()
    
                    options.append(
                        {
                            "name": name,
                            "description": description[:200] if len(description) > 200 else description,
                            "type": type_info,
                        }
                    )
    
                    if len(options) >= limit:
                        break
    
            return options
        except Exception as exc:
            raise DocumentParseError(f"Failed to fetch docs: {str(exc)}") from exc
  • FastMCP @mcp.tool() decorator registers the home_manager_search function as an MCP tool.
    async def home_manager_search(query: str, limit: int = 20) -> str:
  • Input schema defined by function parameters (query: str, limit: int=20) and docstring. Output is str (plain text).
    """Search Home Manager configuration options.
    
    Searches through available Home Manager options by name and description.
    
    Args:
        query: The search query string to match against option names and descriptions
        limit: Maximum number of results to return (default: 20, max: 100)
    
    Returns:
        Plain text list of matching options with name, type, and description
    """
Behavior3/5

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

No annotations are provided, so the description carries full burden. It mentions the tool searches through options and returns a plain text list, which covers basic behavior. However, it doesn't disclose important traits like whether this is a read-only operation, performance characteristics, rate limits, or authentication requirements.

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, args, returns) and uses bullet-like formatting. It's appropriately sized at 4 sentences, though the first sentence is somewhat redundant with the title.

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

Completeness4/5

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

Given the tool has an output schema (though not shown here), the description doesn't need to explain return values in detail. It provides adequate information about what the tool does and its parameters, though behavioral context could be more complete for a search tool with no annotations.

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?

With 0% schema description coverage, the description compensates well by explaining both parameters: 'query' matches against option names and descriptions, and 'limit' specifies maximum results with default and max values. This adds meaningful context beyond the bare schema.

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 tool searches Home Manager configuration options by name and description, which is a specific verb+resource combination. However, it doesn't explicitly distinguish this from sibling tools like 'home_manager_list_options' or 'home_manager_options_by_prefix', which likely serve similar but distinct purposes.

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?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools like 'home_manager_list_options', 'home_manager_options_by_prefix', and 'home_manager_stats', there's no indication of when search is preferred over listing or prefix-based lookup.

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/utensils/mcp-nixos'

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