nix-agent
nix-agent is a local MCP server that lets AI agents build, compare, activate, roll back, inspect, and validate real NixOS/Home Manager configurations.
Build system/Home Manager closures in the background without activation and poll live status/log tails.
Diff a newly built closure against the running system with structured package, version, and closure-size changes.
Switch/activate configurations, record a rollback generation, summarize changes and systemd health, and diagnose sudo failures; optionally validate first.
List and roll back NixOS/Home Manager generations, including to a specific generation.
Evaluate merged config attributes, including batched queries, with size guards/truncation.
Locate where an option is declared or defined and see contributed values.
Run validation checks: lint via statix/deadnix, dry-build, and NixOS dry-activate.
Optionally record per-call byte usage and summarize it with
nix-agent usage.
Provides tools for inspecting local NixOS configuration files and applying patch sets to modify and rebuild NixOS or Home Manager configurations via nixos-rebuild or home-manager commands.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nix-agent Apply the patch set to switch my Home Manager configuration."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
docs/usage.md: install, MCP host config, tool surface, workflow, design notes
docs/agent-install.md: high-trust install guide for agents
docs/privileged-automation.md: default non-interactive dry-activate, switch, and rollback (opt-down for a sudo password)
skills/nix-agent/SKILL.md: companion workflow skill
skills/nix-agent-init/SKILL.md: repo onboarding skill
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 toolsbuildA
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
Scored across 7 tools
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 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.
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.
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
Related MCP Connectors
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
MCP server for Superserve sandboxes: create, exec, and manage Firecracker microVMs
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceLocal-first MCP server for repo-scoped development tasks like inspection, testing, documentation, and patching, designed to complement Cline with a structured local execution layer.-
- AlicenseNot gradedqualityDmaintenanceA production-ready MCP server for secure, session-based command execution, file manipulation, and system inspection via local terminal sessions.MIT
- AlicenseAqualityBmaintenanceA 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.8MIT
- AlicenseAqualityDmaintenanceA 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.30MIT