MCP-NixOS - Model Context Protocol Server for NixOS resources
MCP-NixOS - Model Context Protocol Server for NixOS resources
** No Nix/NixOS Required!** Works on any system - Windows, macOS, Linux. You're just querying APIs.
{
"mcpServers": {
"nixos": {
"command": "uvx",
"args": ["mcp-nixos"]
}
}
}{
"mcpServers": {
"nixos": {
"command": "nix",
"args": ["run", "github:utensils/mcp-nixos", "--"]
}
}
}{
"mcpServers": {
"nixos": {
"command": "docker",
"args": ["run", "--rm", "-i", "ghcr.io/utensils/mcp-nixos"]
}
}
}Your AI now has access to real NixOS data instead of making things up. You're welcome.
FastMCP supports running this server over HTTP at a URL (the MCP endpoint defaults to /mcp).
# Run an HTTP MCP server at http://127.0.0.1:8000/mcp
MCP_NIXOS_TRANSPORT=http MCP_NIXOS_HOST=127.0.0.1 MCP_NIXOS_PORT=8000 mcp-nixosSTDIO (default):
MCP_NIXOS_TRANSPORT=stdio mcp-nixosCustom path:
MCP_NIXOS_TRANSPORT=http MCP_NIXOS_PATH=/api/mcp mcp-nixosStateless HTTP (disables per-client session state):
MCP_NIXOS_TRANSPORT=http MCP_NIXOS_STATELESS_HTTP=1 mcp-nixosPi does not speak MCP natively. Two supported paths:
A. pi-mcp-adapter (recommended — speaks MCP, single source of truth):
pi install npm:pi-mcp-adapterThen add to ~/.pi/agent/mcp.json:
{
"mcpServers": {
"nixos": {
"command": "uvx",
"args": ["mcp-nixos"],
"lifecycle": "lazy"
}
}
}B. Project-local extension (clone + run): this repo ships .pi/extensions/mcp-nixos.ts, auto-loaded when you run pi in the cloned repo. Optional: cd .pi && npm install for editor type resolution. Pi runs it either way.
An MCP server providing accurate, real-time information about:
Just two. We consolidated 17 tools into 2 because your AI's context window isn't infinite.
~1,030 tokens total. That's it. While other MCP servers are hogging your context like it's Black Friday, we're sipping minimalist tea in the corner. Your AI gets NixOS superpowers without the bloat.
nix - Unified Query ToolOne tool to rule them all:
nix(action, query, source, type, channel, limit, version, system)version and system are only used by action="cache".
| Action | What it does |
|---|---|
search |
Search packages, options, programs, or flakes |
info |
Get detailed info about a package or option |
stats |
Get counts and categories |
browse |
Browse Home Manager, Darwin, Nixvim, NVF, or Noogle by prefix (legacy alias: options) |
channels |
List available NixOS channels |
flake-inputs |
Explore local flake inputs from Nix store |
cache |
Check binary cache status for packages |
store |
Read files or list directories at an explicit /nix/store path (requires Nix) |
| Source | What it queries |
|---|---|
nixos |
Packages, options, programs |
home-manager |
Home Manager options |
darwin |
nix-darwin options |
flakes |
Community flakes (search.nixos.org) |
flakehub |
FlakeHub registry (flakehub.com) |
nixvim |
Nixvim Neovim configuration options |
nvf |
NVF Neovim configuration options (latest unstable docs) |
noogle |
Nix function signatures and docs (noogle.dev) |
wiki |
NixOS Wiki articles (wiki.nixos.org) |
nix-dev |
Official Nix documentation (nix.dev) |
nixhub |
Package metadata and store paths (nixhub.io) |
NVF results use canonical vim.* option paths. Queries may also use the shorthand
programs.nvf.vim.* or the NixOS/Home Manager module path
programs.nvf.settings.vim.*; both are normalized automatically.
Examples:
…nix_versions - Package Version HistoryFind historical versions with nixpkgs commit hashes. Output includes:
nix_versions(package, version, limit)Examples:
# List recent versions with metadata
nix_versions(package="python", limit=5)
# Find specific version
nix_versions(package="nodejs", version="20.0.0")You DON'T need Nix installed. This runs anywhere Python runs.
# Run directly (no install)
uvx mcp-nixos
# Or install
pip install mcp-nixosFor Nix users:
nix run github:utensils/mcp-nixos
nix profile install github:utensils/mcp-nixosmcp-nixos is available in nixpkgs:
# NixOS (configuration.nix)
environment.systemPackages = [ pkgs.mcp-nixos ];
# Home Manager (home.nix)
home.packages = [ pkgs.mcp-nixos ];
# nix-darwin (darwin-configuration.nix)
environment.systemPackages = [ pkgs.mcp-nixos ];Or use the flake directly with the provided overlay:
…overlays.default only adds pkgs.mcp-nixos. The package carries its own
FastMCP 4 / MCP SDK 2 stack (see nix/fastmcp4.nix), including a starlette at
or above the 1.0.1 security floor FastMCP requires, so nothing else in your
Python package set changes, even on nixpkgs channels that still ship FastMCP 3.
If you also want pkgs.python3Packages.fastmcp itself upgraded set-wide, apply
mcp-nixos.overlays.fastmcp4 in addition.
nix develop # Enter dev shell
nix build # Build package
pytest tests/ # Run tests
ruff check . # Lint
ruff format . # Format
mypy mcp_nixos/ # Type checkMIT - Because sharing is caring.
Created by James Brink. Maintained by mass̶o̶c̶h̶i̶s̶t̶s̶ enthusiasts who enjoy Nix.
No open issues yet, or sync has not completed.