feat(ai-agents): package mcp tools into store derivations and eliminate runtime network fetching (#272) #280
No reviewers
Labels
No labels
area:authentication
area:flake-utilities
area:performance
area:tbd
host:chaos
host:cosmos
host:electra
host:fleet
host:lena
host:lyra
host:mass-storage
host:media1
host:nimmog-de
host:nova
host:pangolin
host:pangolin-vps
host:phone
host:router
host:vega
investigation
phase:cutover
phase:deploy
phase:mcp
phase:module
phase:packaging
phase:prep
phase:validation
priority:high
priority:medium
project:attic-postgres-lyra-rollout
project:auto-update-reliability
project:auto-update-remediation
project:declarative-purity-cleanup
project:external-review
project:fleet-boundary-cleanup
project:host-facts-refactor
project:lyra-nixos-deploy
project:lyra-service-stack-migration
project:nebula-mesh-network
project:nix-idioms-hygiene
project:nixos-build-deployment-pipeline
project:security-hardening
project:service-stack-migration
project:vega-sillytavern-cutover
project:wiki-rebuild
repo:numtide/flake-utils
repo:numtide/nix-auth
repo:numtide/nixos-passthru-cache
repo:numtide/nix-relay
service:auto-update
service:gitlab
service:hermes
service:mem0
service:nix
service:sillytavern
service:slskd
service:synthseek
service:tdarr
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
nimmo/nixos-config!280
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/issue-272-package-mcp-tools"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Packages local MCP servers into deterministic store derivations and eliminates impure runtime downloads via
uvxand unpinnednix run.Resolves #272
Key Changes
nimmo/beszel-mcp.nixon Forgejo with automated upstream daily check workflow. Pinned as a flake inputbeszel-mcpinflake.nixand classified inlib/auto-update-policy.nix.pkgs.mcp-nixosfrom nixpkgs (with a targetedsyrupytest override for Python 3.14 compatibility).agy) configurations inmodules/profiles/ai-agents.nixandmodules/profiles/ai-runtime.nixto execute store binaries directly.AGENTS.mdBeszel MCP section.Validation
output=$(nix flake check 2>&1); rc=$?; filtered=$(echo "$output" | grep -v "warning: Git tree .* is dirty"); [ -n "$filtered" ] && echo "$filtered"; [ $rc -eq 0 ] && echo "flake check OK" || exit $rcpassed cleanly across all registered hosts.nix build --no-link .#nixosConfigurations.electra.config.system.build.toplevelsucceeded across base, iGPU, and dGPU tiers.Automated code review
Reviewed commit:
031ed94aad7cf4dcddb97094ea19ab42e016b99dVerdict: Requires further work
Resolve the blocking or important findings and investigate failed deterministic checks before merging.
Overall assessment
The PR refactors the Model Context Protocol (MCP) configuration by extracting individual server definitions into dedicated modules under
modules/mcp/, aggregating them inmodules/mcp/default.nix, and consuming this aggregation in profile modules. It replaces runtime fetching mechanisms (uvx, nix run) with deterministic store derivations, specifically introducing a new flake input for the Beszel MCP server and switching topkgs.mcp-nixosfrom nixpkgs. The changes improve reproducibility and reduce impure network calls during execution.Blocking findings
None.
Important findings
export BESZEL_EMAIL="$(cat ${lib.escapeShellArg config.sops.secrets."beszel-mcp-email".path})"
export BESZEL_PASSWORD="$(cat ${lib.escapeShellArg config.sops.secrets."beszel-mcp-password".path})"
Impact: The launcher script explicitly uses
catto read secrets, which requirescoreutilsin the PATH. Whilecoreutilsis added, this is less efficient and potentially less secure than using a dedicated secret-reading utility or passing secrets via environment variables if supported by the binary. More importantly, it relies on the shell's command substitution which can be prone to quoting issues if not handled carefully, thoughescapeShellArgis used for paths.Suggested fix: Consider if the Beszel MCP binary supports reading secrets from environment variables directly or a config file. If
catis necessary, ensurecoreutilsis always available in the launcher's PATH (which it is). Verify that the secret content does not contain characters that could break the shell command substitution.Suggestions
Hardcoded timeout for Trilium MCP server (modules/mcp/trilium.nix:24; medium confidence)
timeout = 300000;
Impact: The timeout is hardcoded to 300 seconds (5 minutes). This might be too short for some operations or unnecessarily long for others. It would be better to make this configurable via
nixosConfig.triliumif possible.Suggested fix: Add a configuration option in
nixosConfig.triliumfor the MCP timeout, defaulting to 300000 if not set.Missing documentation for new modules/mcp structure in AGENTS.md (AGENTS.md:122; high confidence)
modules/mcp/- Model Context Protocol (MCP) server modules and client registry (individual servers live inmodules/mcp/<server>.nixand aggregate inmodules/mcp/default.nixfor Codex, OpenCode, Pi, and Antigravity CLI)Impact: The documentation is updated to mention the new structure, which is good. However, ensure that any agent or developer guidelines regarding how to add a new MCP server are also updated if they exist elsewhere.
Suggested fix: Check if there are other places in the documentation (e.g., wiki) that need updating to reflect the new module structure for adding MCP servers.
Beszel MCP flake input uses a private Git URL (flake.nix:78; high confidence)
beszel-mcp.url = "git+ssh://git@git.nimmog.uk:2222/nimmo/beszel-mcp.nix.git";
Impact: The URL uses SSH and a non-standard port. This requires proper SSH configuration (keys, known hosts) on the build machine. If this is not handled correctly, builds may fail.
Suggested fix: Ensure that the CI/CD environment and any developer machines have the necessary SSH keys and host keys configured to access
git.nimmog.ukon port 2222.Tests and validation
Questions
Review limitations
nix flake checkor build the configuration to verify the changes.Diff coverage
AGENTS.md: reviewed — included in a context-limited batchREADME.md: reviewed — included in a context-limited batchflake.lock: reviewed — included in a context-limited batchflake.nix: reviewed — included in a context-limited batchlib/auto-update-policy.nix: reviewed — included in a context-limited batchmodules/mcp/beszel.nix: reviewed — included in a context-limited batchmodules/mcp/bookstack.nix: reviewed — included in a context-limited batchmodules/mcp/default.nix: reviewed — included in a context-limited batchmodules/mcp/forgejo.nix: reviewed — included in a context-limited batchmodules/mcp/karakeep.nix: reviewed — included in a context-limited batchmodules/mcp/kiwifs.nix: reviewed — included in a context-limited batchmodules/mcp/navidrome.nix: reviewed — included in a context-limited batchmodules/mcp/nixos.nix: reviewed — included in a context-limited batchmodules/mcp/pangolin.nix: reviewed — included in a context-limited batchmodules/mcp/synthseek.nix: reviewed — included in a context-limited batchmodules/mcp/trilium.nix: reviewed — included in a context-limited batchmodules/profiles/ai-agents.nix: reviewed — included in a context-limited batchmodules/profiles/ai-runtime.nix: reviewed — included in a context-limited batchmodules/profiles/pi-pangolin.nix: reviewed — included in a context-limited batchReview metadata