This server provides two core tools for managing NixOS/Home Manager configurations:
inspect_state: Read any local file and return its contents — useful for inspecting NixOS config files, flake inputs, or any other file before making changes.apply_patch_set: Write a set of file replacements to disk, automatically format any.nixfiles modified, and optionally validate and switch the system configuration. Supports two modes:nixos(default): runsnixos-rebuild dry-activatefor validation, thennixos-rebuild switch(with sudo) to activatehome-manager: runshome-manager buildthenhome-manager switch(no sudo required)Returns a
rollback_generationvalue so any bad switch can be quickly undone
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 "Install 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-agentApply 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.
nix-agent
nix-agent is a local MCP server that gives AI agents composable NixOS
operations: eval, lint, format, build, diff, switch, generations.
It works alongside mcp-nixos:
nix-agenthandles operations on your actual configuration — evaluating, linting, formatting, building, diffing, switchingmcp-nixoshandles package and option discovery
NOTE: This is experimental and a work in progress. Feedback and contributions are very welcome.
Related MCP server: github-mcp
What you get
a runnable stdio MCP server
a Nix flake package and app (wrapper bundles statix/deadnix/nixfmt/nvd)
a NixOS module at
nixosModules.defaulta companion agent skill in
skills/nix-agent/example MCP host configs in
examples/
One-shot agent install
Paste this to a coding agent (Claude Code, opencode, etc.) and it will do the install for you:
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 skill, and register nix-agent in my MCP settings for this machine.Fast install
Add this flake input and module to your NixOS config:
{
inputs.nix-agent.url = "github:JEFF7712/nix-agent";
outputs = { nixpkgs, nix-agent, ... }: {
nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nix-agent.nixosModules.default
({ ... }: {
programs.nix-agent.enable = true;
})
];
};
};
}Then rebuild:
sudo nixos-rebuild switch --flake .#my-hostThat installs the nix-agent binary.
MCP host config
Point your MCP host at:
{
"mcpServers": {
"nix-agent": {
"command": "nix-agent",
"args": []
}
}
}See examples/claude-code-mcp.json and examples/opencode-mcp.json.
Companion skill
Install or copy skills/nix-agent/ into your agent's skill directory.
Quick install:
./install-skill.sh opencodeThe MCP exposes the tools. The skill teaches the correct workflow.
Tool surface
All tools auto-resolve the target when flake_uri is omitted. Resolution
order: $NIX_AGENT_FLAKE (or $NIX_AGENT_HM_FLAKE for HM), then the first
existing flake.nix among /etc/nixos, ~/nixos, ~/.config/nixos,
~/nix-config, ~/nixos-config for NixOS (~/.config/home-manager,
~/.config/nixpkgs for Home Manager). The hostname / user@host attribute is
picked automatically. Every result echoes back resolved_target and the exact
command run. Exception: calling format with explicit paths returns
per-file results instead. Pass mode="home-manager" for HM configs.
Tool | What it does |
| Final merged value of any config attribute on this machine (after all modules/overlays). |
| Validation ladder, fast to slow: |
|
|
| Build the closure, no activation. |
| What a switch would change (package adds/removes/version bumps). Show this to the user before switching. |
| Activate. Records |
| List or roll back generations. |
Basic workflow
Discovery: query
mcp-nixosfor packages/options; useeval_configto see what the user's machine currently resolves.Edit
.nixfiles with the agent's native file tools (Read/Edit/Write).format()thencheck("lint")— fix findings worth fixing.check("dry-build")— catches eval/build errors cheaply.diff()— show the user what will change.switch()— activate; reportsrollback_generation.On regret:
generations(action="rollback").
Steps 3–5 are judgment calls, not gates — for a trivial change, going straight
to switch is fine.
On failure, the response includes a first_error field with the first
actionable error line from Nix's output, alongside the full log.
Design notes
nix-agent does no file I/O. The host agent's own file tools are better at reading and editing; nix-agent only provides the Nix operations around them.
No in-MCP approval gates. Path restrictions belong to the host's permission system; rollback safety belongs to Nix generations.
Every response echoes
resolved_targetand the exactcommandrun — nothing is silently implicit.Do not write secret payloads into configs — reference secrets via sops-nix or agenix.
Fully non-interactive switch requires privileged automation; see
docs/privileged-automation.md.
More detail
skill docs:
skills/nix-agent/SKILL.mdexamples:
examples/
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/JEFF7712/nix-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
