/ 目錄 / 演練場 / mcp-nixos
● 社群 utensils ⚡ 即開即用

mcp-nixos

作者 utensils · utensils/mcp-nixos

直接在對話中查詢任何 NixOS 套件、模組選項或 Home Manager 設定 — 13 萬個套件 + 2.3 萬個選項,零設定即可使用。

mcp-nixos 透過兩個工具查詢 NixOS 套件、系統選項、Home Manager、nix-darwin、Nixvim 及相關登錄檔。無需驗證、無需本機安裝 Nix — 它會代理至公開搜尋 API。非常適合回答「X 有沒有對應的套件?」和「Y 的選項在哪裡?」,省去翻文件的麻煩。

為什麼要用

核心特性

即時演示

實際使用效果

nixos.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "nixos": {
      "command": "uvx",
      "args": [
        "mcp-nixos"
      ],
      "_inferred": true
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "nixos": {
      "command": "uvx",
      "args": [
        "mcp-nixos"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "nixos": {
      "command": "uvx",
      "args": [
        "mcp-nixos"
      ],
      "_inferred": true
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "nixos": {
      "command": "uvx",
      "args": [
        "mcp-nixos"
      ],
      "_inferred": true
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "nixos",
      "command": "uvx",
      "args": [
        "mcp-nixos"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "nixos": {
      "command": {
        "path": "uvx",
        "args": [
          "mcp-nixos"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add nixos -- uvx mcp-nixos

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: mcp-nixos

以模糊名稱或用途尋找 NixOS 套件

👤 NixOS 使用者、flake 作者 ⏱ ~5 min beginner

何時使用: 你大概記得套件的功能,但不確定其 nix 屬性名稱。

步驟
  1. 搜尋
    Find NixOS packages matching 'ocr command line tool'.✓ 已複製
    → 依相關性排列的候選清單及描述
  2. 取得最佳結果的詳細資訊
    For tesseract, show me the attribute path, version in unstable vs 24.11, and which meta.platforms are supported.✓ 已複製
    → 包含屬性、版本、平台的詳細資訊卡

結果: 取得可直接填入 configuration.nix 或 flake 的確切屬性名稱。

注意事項
  • 頻道不符 — 套件只存在於 unstable,不在你使用的穩定頻道中 — 明確指定你目前使用的頻道來查詢
搭配使用: filesystem

查詢 NixOS 模組選項的型別與預設值

👤 撰寫 NixOS 模組的開發者 ⏱ ~5 min beginner

何時使用: 你知道「某處」有啟用 zswap 的選項,但不想自己去翻 nixpkgs。

步驟
  1. 查詢選項
    Is there a NixOS option for enabling zswap? Show its type, default, and description.✓ 已複製
    → 完整的選項資訊卡
  2. 取得範例
    Give me a minimal configuration.nix snippet that enables zswap with z3fold and 20% memory.✓ 已複製
    → 可直接複製貼上的 Nix 程式碼片段

結果: 取得可直接貼入設定檔的正確選項用法。

將 nixpkgs 固定至套件的舊版本

👤 需要特定舊版本的使用者 ⏱ ~10 min intermediate

何時使用: 新版本造成問題,你想找到上一個已知可正常運作的 commit。

步驟
  1. 查詢歷史版本
    Show me past versions of nodejs_20 in nixpkgs with commit hashes.✓ 已複製
    → 版本對應 commit 的表格
  2. 產生 flake input
    Generate the flake input pinning nodejs_20 20.15.0 from that commit.✓ 已複製
    → 可直接貼入的 flake.nix 程式碼片段

結果: 取得可重現的固定 input,用於版本回退。

搭配使用: filesystem

探索某個程式的 Home Manager 選項

👤 所有使用 Home Manager 的使用者 ⏱ ~10 min beginner

何時使用: 你想以宣告式方式管理某個程式,但不確定有哪些選項可用。

步驟
  1. 列出程式選項
    List every Home Manager option under programs.neovim.✓ 已複製
    → 分類整理的選項清單
  2. 建立最小設定區塊
    Give me a minimal programs.neovim block enabling Telescope and LSP for TS/Python.✓ 已複製
    → 可正常運作的 Home Manager 程式碼片段

結果: 無需閱讀完整手冊,直接取得可運作的 Home Manager 設定。

組合

與其他 MCP 搭配,撬動十倍槓桿

nixos + filesystem

找到選項後直接寫入設定檔

Find the NixOS option to enable flatpak, then add it to ~/nixos/configuration.nix with a comment.✓ 已複製
nixos + github

當套件不存在時建立 issue 回報

Is package foo-cli in nixpkgs? If not, open a github issue on our fork requesting it.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
nix action: search|info|stats|options|channels|flake-inputs|cache, args: ... 查詢套件、選項或頻道時使用 1 upstream API call
nix_versions package: str 需要查詢舊版本或固定 nixpkgs commit 時使用 1 upstream call

成本與限制

運行它的成本

API 配額
使用公開 API;限額寬鬆但並非無限 — 請勿大量頻繁請求
每次呼叫 Token 數
含描述的選項:500-2000 tokens。清單類結果可能更多。
費用
免費
提示
優先對單一套件使用 info,而非用 search 一次回傳 50 筆結果。

安全

權限、密鑰、影響範圍

憑證儲存:
資料出站: 呼叫 search.nixos.org 及相關公開 API

故障排查

常見錯誤與修復

uvx not found

安裝 uv:curl -LsSf https://astral.sh/uv/install.sh | sh,然後重新新增 MCP。

驗證: uvx --version
No results for a package I know exists

屬性名稱的拼法可能不同 — 嘗試使用更寬鬆的查詢字詞,或改以描述關鍵字搜尋。

驗證: Retry with partial keyword
Stale version info

MCP 會短暫快取結果;請等 5 分鐘後重新查詢,或傳入 action=cache 來強制更新。

替代方案

mcp-nixos 對比其他方案

替代方案何時用它替代權衡
search.nixos.org directly你不介意開啟瀏覽器分頁查詢無 AI 輔助介入
nix-search CLI你想在本機快速搜尋,且已安裝 Nix需要本機安裝 Nix 並保持頻道為最新狀態

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills