Skip to main content
Glama
nix-agent

nix-agent

by JEFF7712

A local MCP server that gives AI agents composable NixOS / Home Manager operations: build, diff, switch, and generations for the operational core, plus eval, locate, and check for config introspection.

It pairs with mcp-nixos. nix-agent operates on your actual configuration, mcp-nixos handles package and option discovery. Optional local usage logging (NIX_AGENT_USAGE_LOG=1) records per-call byte accounting; run nix-agent usage to summarize.

The documented default is high trust: unprompted switch / generations and passwordless sudo narrowed to this machine's flake. Lower trust (host prompts, a sudo password) is an opt-down.

Install

Paste this to a coding agent (Codex, Claude Code, opencode, ...) and it does the install:

Read https://raw.githubusercontent.com/JEFF7712/nix-agent/main/docs/agent-install.md and follow every step to install nix-agent on this NixOS system, install the companion skills, and register nix-agent in my MCP settings for this machine.

Or do it by hand, see docs/usage.md.

Related MCP server: Terminal MCP Server

Docs

The published documentation pages are generated directly from these Markdown files.


The nix-agent logo adapts the Nix snowflake from NixOS/nixos-artwork, licensed CC-BY 4.0.

Available Tools

7 tools
buildA

Start a persistent background build of the system/HM closure, without activation. Returns job_id promptly. Poll build(job_id=...) for bounded live log tails and status: running, ok, failed, or interrupted. Pass the previous poll's log_offset to receive only new stderr. Jobs survive MCP disconnects and server restarts; repeated starts for the same running target reuse its job. On success returns store_path; successful output is a short tail with log_truncated and full local log_paths. on build failure includes failed_derivation{drv, log_tail} when available.

Inputs: mode, job_id, flake_uri, log_offset. Returns: object

checkA

Validation ladder for the configuration, fast to slow: level='lint' (statix+deadnix; returns a structured findings list), 'dry-build' (evaluate and plan the closure build), 'dry-activate' (NixOS only, shows what activation would change). Successful output is a short tail with log_truncated and full local log_paths; failures retain their capped diagnostics.

Inputs: level (required), mode, flake_uri. Returns: object

diffA

Build the new closure (or reuse an existing store_path from build()) and diff it against the running system or an explicit against closure (nvd, falling back to nix store diff-closures): package additions, removals, version changes as structured packages plus closure_size; the raw diff text only when it does not parse. Include the changeset in the reply and switch unless the user asked only to preview or check. For hosts requiring coordinated fleet deployment, use the repository's deployment orchestrator.

Inputs: mode, against, flake_uri, store_path. Returns: object

eval_configA

Evaluate the final merged value of an attribute in the user's actual NixOS/Home Manager configuration via nix eval (e.g. attr='services.openssh.enable'). flake_uri and mode auto-resolve when omitted. Pass a list of attrs to batch several evals into one call, returning per-attr results and failed_count / succeeded_count. Mixed results have status='partial', all failed have status='failed'. Values above the size guard degrade to attr names / length / a head slice (truncated: true). Text fallback and truncation include a hint to request narrower leaf attributes.

Inputs: attr (required), mode, flake_uri. Returns: object

generationsA

action='list': enumerate recent system/HM generations (default limit=20, always keeping current; pass limit=None for all) with dates and current marker. NixOS entries include path when the profile link exists. action='rollback': revert to the previous generation, or pass generation= to activate that generation. Bare rollback is previous-only. Pass mode='home-manager' for HM generations.

Inputs: mode, limit, action, generation. Returns: object

locate_optionA

Where does this configuration set an option: files declaring it and every file defining it, with each contributed value (e.g. attr='services.openssh.enable'). The bridge from mcp-nixos discovery to editing the right file. For integrated Home Manager, query the NixOS config with attr='home-manager.users..'.

Inputs: attr (required), mode, flake_uri. Returns: object

switchA

Activate the configuration (sudo -n nixos-rebuild switch / home-manager switch). Records rollback_generation first. Returns a structured 'summary' (units changed, derivations built, package delta, systemd health, and a bounded warnings list from the captured switch log) plus gen before/after; on success the raw log is trimmed to a tail (pass full_log=True for all of it). Status is 'degraded' when activation succeeded but units newly failed. No implicit validation by default; pass validate=True to gate on check('dry-build') first. On a sudo auth failure returns a 'privilege' diagnosis. Local activation only; hosts requiring cluster cordon/drain and readiness gating must use their fleet orchestrator.

Inputs: mode, full_log, validate, flake_uri. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 7 tools

    Disambiguation4/5

    The tools mostly have distinct roles: build/check/diff/switch/generations/eval_config/locate_option target different workflow stages. There is some overlap because build, check's dry-build, diff, and switch can all involve planning or evaluating a closure, but the descriptions make the intended primary action reasonably clear.

    Naming Consistency3/5

    Naming is readable but mixed: eval_config and locate_option follow a snake_case verb_noun pattern, while diff, generations, build, check, and switch are bare verbs or nouns. The inconsistency is not chaotic, but it lacks a predictable single convention.

    Tool Count5/5

    Seven tools is well-scoped for a NixOS/Home Manager configuration agent. Each tool covers a meaningful part of the build, validate, diff, inspect, and activate lifecycle without obvious redundancy.

    Completeness4/5

    The surface covers the core lifecycle well: build, validation, diff, activation, rollback/list generations, config evaluation, and option location. Minor gaps remain around direct file editing or broader Nix package/option discovery, but those may belong to a companion MCP server.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Local-first MCP server for repo-scoped development tasks like inspection, testing, documentation, and patching, designed to complement Cline with a structured local execution layer.
      -
    • A
      license
      A
      quality
      B
      maintenance
      A secure, local-first MCP server for read-only inspection and troubleshooting of development environments, exposing narrow, typed, auditable capabilities for repository inspection, log summarization, Docker review, and security scanning without granting unrestricted machine access.
      8
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A security-first MCP server for managing Whatbox slots with structured read-only inspection and approval-gated mutations, including storage, services, website deployment, and torrent control.
      30
      MIT