home_manager_stats
Retrieve statistics about Home Manager configuration options, including total count, categories, and top categories for system management.
Instructions
Get statistics about Home Manager options.
Retrieves overall statistics including total options, categories, and top categories.
Returns: Plain text summary with total options, category count, and top 5 categories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_nixos/server.py:741-788 (handler)The @mcp.tool() decorated handler function implementing the 'home_manager_stats' MCP tool. It parses Home Manager HTML documentation to extract options and computes statistics on total count, categories, and types, returning a formatted plain-text summary.@mcp.tool() async def home_manager_stats() -> str: """Get statistics about Home Manager options. Retrieves overall statistics including total options, categories, and top categories. Returns: Plain text summary with total options, category count, and top 5 categories """ try: # Parse all options to get statistics options = parse_html_options(HOME_MANAGER_URL, limit=5000) if not options: return error("Failed to fetch Home Manager statistics") # Count categories categories: dict[str, int] = {} for opt in options: cat = opt["name"].split(".")[0] categories[cat] = categories.get(cat, 0) + 1 # Count types types: dict[str, int] = {} for opt in options: opt_type = opt.get("type", "unknown") if opt_type: # Simplify complex types if "null or" in opt_type: opt_type = "nullable" elif "list of" in opt_type: opt_type = "list" elif "attribute set" in opt_type: opt_type = "attribute set" types[opt_type] = types.get(opt_type, 0) + 1 # Build statistics return f"""Home Manager Statistics: • Total options: {len(options):,} • Categories: {len(categories)} • Top categories: - programs: {categories.get("programs", 0):,} options - services: {categories.get("services", 0):,} options - home: {categories.get("home", 0):,} options - wayland: {categories.get("wayland", 0):,} options - xsession: {categories.get("xsession", 0):,} options""" except Exception as e: return error(str(e))