⚠️ ACTIVE DEVELOPMENT: This package is under active development. Like my career choices, it's constantly evolving.
📢 RENAMED: This package was renamed from
nixmcp
tomcp-nixos
in version 0.2.0. Update your references accordingly or continue living in the past—your choice.
MCP-NixOS is a Model Context Protocol server that stops your AI assistant from making stuff up about NixOS. Because let's face it—the only thing worse than confusing NixOS documentation is an AI confidently hallucinating about it.
It provides real-time access to:
Look, we both know you're just going to skim this README and then complain when things don't work. Here's the bare minimum to get started:
{
"mcpServers": {
"nixos": {
"command": "uvx",
"args": ["mcp-nixos"]
}
}
}
There. Now your AI assistant can actually give you correct information about NixOS instead of hallucinating package names from 2019. You're welcome.
Variable | Description | Default |
---|---|---|
MCP_NIXOS_LOG_LEVEL | How much you want to know about your failures | INFO |
MCP_NIXOS_LOG_FILE | Where to document said failures | (nowhere—your secret is safe) |
MCP_NIXOS_CACHE_DIR | Where to store stuff you'll forget about | OS-specific cache locations* |
MCP_NIXOS_CACHE_TTL | How long until cache invalidation ruins your day | 86400 (24h) |
MCP_NIXOS_CLEANUP_ORPHANS | Whether to kill orphaned MCP processes on startup | false |
KEEP_TEST_CACHE | Keep test cache directory for debugging (dev-only) | false |
ELASTICSEARCH_URL | NixOS Elasticsearch API URL | https://search.nixos.org/backend |
*Default cache locations (where your gigabytes will quietly disappear to):
~/.cache/mcp_nixos/
(because ~/.cache wasn't cluttered enough)~/Library/Caches/mcp_nixos/
(buried where you'll never look)%LOCALAPPDATA%\mcp_nixos\Cache\
(lost in the void of Windows directories)Resources:
nixos://package/{name}
- Find that package you're sure existsnixos://search/packages/{query}
- Search for packages that might existnixos://search/options/{query}
- Search system options you'll misconfignixos://option/{name}
- Get option info you'll still manage to mess upnixos://search/programs/{name}
- Find packages providing programsnixos://packages/stats
- Stats to impress your nerd friendsTools:
nixos_search(query, type, channel)
- The search function you'll use mostnixos_info(name, type, channel)
- Get package or option detailsnixos_stats(channel)
- Get NixOS statistics nobody asked forChannels:
unstable
(default) - Living on the edge where nothing is stable, including your sanitystable
(24.11) - For those who prefer their breakage on a scheduleResources:
home-manager://search/options/{query}
- Search user config optionshome-manager://option/{name}
- Option details you'll screenshot for laterhome-manager://options/prefix/{prefix}
- All options under a prefixhome-manager://options/{category}
- Category options (programs, services, etc.)Tools:
home_manager_search(query)
- Search configuration optionshome_manager_info(name)
- Get option details with actual explanationhome_manager_options_by_prefix(option_prefix)
- Get options by prefixhome_manager_list_options()
- List all option categories when overwhelmedResources:
darwin://search/options/{query}
- Search macOS optionsdarwin://option/{name}
- Option details for your Apple devicesdarwin://options/prefix/{prefix}
- All options under a prefixdarwin://options/{category}
- Category options (system, services, etc.)Tools:
darwin_search(query)
- Search macOS configuration optionsdarwin_info(name)
- Get option details Apple doesn't want you to knowdarwin_options_by_prefix(option_prefix)
- Get options by prefixdarwin_list_options()
- List all option categories# NixOS examples for when you're pretending to know what you're doing
nixos_search(query="firefox", type="packages", channel="unstable")
nixos_search(query="postgresql", type="options", channel="stable")
nixos_info(name="firefox", type="package")
nixos_info(name="services.postgresql.enable", type="option")
# Home Manager examples for the domestic configuration enthusiasts
home_manager_search(query="programs.git")
home_manager_info(name="programs.firefox.enable")
home_manager_options_by_prefix(option_prefix="programs.git")
# nix-darwin examples for the masochistic Mac users
darwin_search(query="system.defaults.dock")
darwin_info(name="services.yabai.enable")
darwin_options_by_prefix(option_prefix="system.defaults")
# Option 1: Install with pip like a normie
pip install mcp-nixos
# Option 2: Install with uv because you're too cool for pip
uv pip install mcp-nixos
# Option 3: Run directly with uvx (recommended for the truly enlightened)
uvx --install-deps mcp-nixos
Add to your MCP configuration file (e.g., ~/.config/claude/config.json
):
{
"mcpServers": {
"nixos": {
"command": "uvx",
"args": ["mcp-nixos"]
}
}
}
For development with the source code (for those who enjoy punishment):
{
"mcpServers": {
"nixos": {
"command": "uv",
"args": ["run", "-m", "mcp_nixos.__main__"],
"env": {
"PYTHONPATH": "."
}
}
}
}
Cache System:
NixOS Channels:
unstable
: Latest NixOS unstable (for daredevils)stable
: Current stable release (for the risk-averse)24.11
: Specific version reference (for the historically inclined)This project uses pyproject.toml
because we're not animals.
# Install development dependencies for the brave
pip install -e ".[dev]"
# Or with uv (recommended for the enlightened)
uv pip install -e ".[dev]"
# Enter dev shell and see available commands
nix develop && menu
# Common commands for common folk
run # Start the server (and your journey into madness)
run-tests # Run tests with coverage (expose the flaws)
lint # Format and lint code (fix the mess you made)
publish # Build and publish to PyPI (share your pain)
Tests use real Elasticsearch API calls instead of mocks because we're not afraid of the real world:
# Run tests with coverage (default and recommended)
run-tests
# Run tests without coverage (for those who prefer blissful ignorance)
run-tests --no-coverage
Code coverage is tracked on Codecov (where we pretend to care about 100% coverage).
Once configured, use MCP-NixOS in your prompts with MCP-compatible models:
# NixOS resources for the confused
~nixos://package/python
~nixos://option/services.nginx
~nixos://search/packages/firefox
# Home Manager resources for the domestically challenged
~home-manager://search/options/programs.git
~home-manager://option/programs.firefox.profiles
# nix-darwin resources for the Apple addicted
~darwin://search/options/system.defaults.dock
# NixOS tools for the tool-inclined
~nixos_search(query="postgresql", type="options")
~nixos_info(name="firefox", type="package", channel="unstable")
# Home Manager tools for home improvement
~home_manager_search(query="programs.zsh")
~home_manager_info(name="programs.git.userName")
# nix-darwin tools for the Mac masochists
~darwin_search(query="services.yabai")
~darwin_info(name="system.defaults.dock.autohide")
The LLM will fetch information through the MCP server and might actually give you correct information for once.
MCP-NixOS is organized into a modular structure that somehow manages to work despite all odds:
mcp_nixos/cache/
- Caching components that save your bandwidth and sanitymcp_nixos/clients/
- API clients that talk to Elasticsearch and parse HTML docsmcp_nixos/contexts/
- Context objects that keep everything from falling apartmcp_nixos/resources/
- MCP resource definitions for all platformsmcp_nixos/tools/
- MCP tool implementations that do the actual workmcp_nixos/utils/
- Utility functions because we're not animalsmcp_nixos/server.py
- The glue that holds this house of cards togetherConnects to the NixOS Elasticsearch API with:
For Home Manager and nix-darwin options, we've committed crimes against HTML parsing:
Documentation Parsers: Extracts structured data through a combination of BeautifulSoup incantations, regex black magic, and the kind of determination that only comes from staring at malformed HTML for 72 hours straight.
Search Engines: Cobbled together with:
Caching System: Because parsing that HTML once was traumatic enough:
The Model Context Protocol (MCP) is an open protocol that connects LLMs to external data and tools using JSON messages over stdin/stdout. This project implements MCP to give AI assistants access to NixOS, Home Manager, and nix-darwin resources, so they can finally stop making things up about your operating system.
MIT (Because I'm not a monster)
The NixOS snowflake logo is used with attribution to the NixOS project. See attribution information for details.
Created by James Brink, self-proclaimed Tinkerer of Terror, who somehow manages to make things work despite himself.
{
"mcpServers": {
"nixos": {
"args": [
"mcp-nixos"
],
"command": "uvx"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.