NixOS MCP server

Provides a server for accessing NixOS packages, system options, Home Manager, and nix-darwin configurations with multi-level caching and advanced search capabilities
Back to servers
Provider
Utensils Union
Release date
Mar 29, 2025
Language
Python
Package
Stats
3.1K downloads
79 stars

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.

Quick Start

Add the following to your MCP configuration file (e.g., ~/.config/claude/config.json):

{
  "mcpServers": {
    "nixos": {
      "command": "uvx",
      "args": ["mcp-nixos"]
    }
  }
}

Installation

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

Configuration

Environment Variables

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:

  • Linux: ~/.cache/mcp_nixos/
  • macOS: ~/Library/Caches/mcp_nixos/
  • Windows: %LOCALAPPDATA%\mcp_nixos\Cache\

Using with LLMs

Once configured, you can use MCP-NixOS in your prompts with MCP-compatible models:

NixOS Resources

~nixos://package/python
~nixos://option/services.nginx
~nixos://search/packages/firefox

Home Manager Resources

~home-manager://search/options/programs.git
~home-manager://option/programs.firefox.profiles

nix-darwin Resources

~darwin://search/options/system.defaults.dock

Tool Usage Examples

NixOS Tools

~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 Tools

~home_manager_search(query="programs.git")
~home_manager_info(name="programs.firefox.enable")
~home_manager_options_by_prefix(option_prefix="programs.git")

nix-darwin Tools

~darwin_search(query="system.defaults.dock")
~darwin_info(name="services.yabai.enable")
~darwin_options_by_prefix(option_prefix="system.defaults")

Available Resources

NixOS Resources

  • nixos://package/{name} - Information about a specific package
  • nixos://search/packages/{query} - Search for packages
  • nixos://search/options/{query} - Search system options
  • nixos://option/{name} - Get option information
  • nixos://search/programs/{name} - Find packages providing programs
  • nixos://packages/stats - View package statistics

Home Manager Resources

  • home-manager://search/options/{query} - Search user config options
  • home-manager://option/{name} - Get option details
  • home-manager://options/prefix/{prefix} - All options under a prefix
  • home-manager://options/{category} - Category options (programs, services, etc.)

nix-darwin Resources

  • darwin://search/options/{query} - Search macOS options
  • darwin://option/{name} - Option details for Apple devices
  • darwin://options/prefix/{prefix} - All options under a prefix
  • darwin://options/{category} - Category options (system, services, etc.)

NixOS Channels

MCP-NixOS supports multiple NixOS channels:

  • unstable (default): Latest NixOS unstable
  • stable (24.11): Current stable release
  • Specific versions like 24.11 for exact release references

How to add this MCP server to Cursor

There 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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later