MCP-NixOS is a Model Context Protocol server that provides AI assistants with accurate information about NixOS packages, system options, Home Manager settings, and nix-darwin configurations. This tool prevents AI models from hallucinating about NixOS-related information by giving them access to real-time, accurate data from official sources.
Add the following to your MCP configuration file (e.g., ~/.config/claude/config.json
):
{
"mcpServers": {
"nixos": {
"command": "uvx",
"args": ["mcp-nixos"]
}
}
}
Choose one of these methods to install MCP-NixOS:
# Option 1: Install with pip
pip install mcp-nixos
# Option 2: Install with uv
uv pip install mcp-nixos
# Option 3: Run directly with uvx (recommended)
uvx --install-deps mcp-nixos
You can customize the behavior of MCP-NixOS with these environment variables:
Variable | Description | Default |
---|---|---|
MCP_NIXOS_LOG_LEVEL |
Controls logging verbosity | INFO |
MCP_NIXOS_LOG_FILE |
Path for log output | (none) |
MCP_NIXOS_CACHE_DIR |
Directory for cached data | OS-specific cache locations |
MCP_NIXOS_CACHE_TTL |
Cache time-to-live in seconds | 86400 (24h) |
MCP_NIXOS_CLEANUP_ORPHANS |
Kill orphaned MCP processes on startup | false |
ELASTICSEARCH_URL |
NixOS Elasticsearch API URL | https://search.nixos.org/backend |
Default cache locations:
~/.cache/mcp_nixos/
~/Library/Caches/mcp_nixos/
%LOCALAPPDATA%\mcp_nixos\Cache\
Once configured, you can use MCP-NixOS in your prompts with MCP-compatible models:
~nixos://package/python
~nixos://option/services.nginx
~nixos://search/packages/firefox
~home-manager://search/options/programs.git
~home-manager://option/programs.firefox.profiles
~darwin://search/options/system.defaults.dock
~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_search(query="programs.git")
~home_manager_info(name="programs.firefox.enable")
~home_manager_options_by_prefix(option_prefix="programs.git")
~darwin_search(query="system.defaults.dock")
~darwin_info(name="services.yabai.enable")
~darwin_options_by_prefix(option_prefix="system.defaults")
nixos://package/{name}
- Information about a specific packagenixos://search/packages/{query}
- Search for packagesnixos://search/options/{query}
- Search system optionsnixos://option/{name}
- Get option informationnixos://search/programs/{name}
- Find packages providing programsnixos://packages/stats
- View package statisticshome-manager://search/options/{query}
- Search user config optionshome-manager://option/{name}
- Get option detailshome-manager://options/prefix/{prefix}
- All options under a prefixhome-manager://options/{category}
- Category options (programs, services, etc.)darwin://search/options/{query}
- Search macOS optionsdarwin://option/{name}
- Option details for Apple devicesdarwin://options/prefix/{prefix}
- All options under a prefixdarwin://options/{category}
- Category options (system, services, etc.)MCP-NixOS supports multiple NixOS channels:
unstable
(default): Latest NixOS unstablestable
(24.11): Current stable release24.11
for exact release referencesThere are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.