You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mcpx: the daemon's socket name follows the symlink-resolved config path, so a nix-managed config moves it on every content change #368
FingerprintConfig (pkgs/mcpx/internal/daemon/paths.go:198) resolves each config path through filepath.EvalSymlinks and hashes the result to name the daemon's socket. When the config is a home-manager/nix link (~/.config/mcpx/config.json -> /nix/store/<hash>-...-home-manager-files/... -> /nix/store/<hash>-hm_.configmcpxconfig.json), the resolved path is content-addressed, so every change to the config's content changes the socket name.
A daemon keyed to the old name stays on it; every CLI computes the new one, finds no daemon, and (with daemon.autostart) starts a second, detached one. When the first daemon is later restarted it computes the new name, finds it held, exits 1 "a daemon is already listening", and under a supervisor that respawns it (launchd KeepAlive) loops.
Evidence (dezren39/nix, macOS, 2026-10-19)
Socket name per system generation, recomputed from the config link: generations 290-295 3489ca4d2ea0, 296 539ba2d32a06, 297-304 541cdd605dd1.
/tmp/mcpx.err.log: the launchd daemon restarted at 20:58 and listened on daemon-539ba2d32a06.sock (nix-darwin restarts agents before home-manager re-links files, so it resolved the previous link).
04:48:10: a CLI-autostarted daemon (daemon --detached --idle-exit 4h) took daemon-541cdd605dd1.sock.
From 11:47 (next mcpx update) launchd's daemon exited 1 "a daemon is already listening on .../daemon-541cdd605dd1.sock" 841 times until the stray was stopped at 14:09.
Reproduced with real binaries on a scratch state dir: config as a symlink re-pointed to another file -> CLI cannot reach the running daemon (exit 1); config as a regular file rewritten in place -> same socket, CLI reaches it, and the daemon hot-reloads the new servers via daemon.watchConfig.
Related, same cause: stampConfig (internal/daemon/routes_settings.go:726) compares os.Stat mtime + size, which follows the link; every nix store file has mtime 1, so with a store-linked config only a change of byte length is noticed.
Workaround in dezren39/nix
The config is now written as a regular file at a fixed path by an activation step, and daemon.autostart is off (dezren39/nix, branch remove-lootbox; homeUser.nix mcpxConfig, mcpx.config.nix).
Suggested fix
Key the socket on the config path with only its directory resolved (keeps the /tmp -> /private/tmp fix the current comment was written for, paths.go:181-184), not the file's link target.
In stampConfig, include the resolved target path (or use Lstat + Readlink for links) so a re-pointed link is noticed even when the target's mtime and size match.
Correct the comments that say the socket name is stable across edits (paths.go:80-88).
Acceptance criteria
A test: config path is a symlink; re-point it to a different file with different content; a CLI started afterwards reaches the already-running daemon, and the daemon reloads the new content.
A test: same-size content change behind a re-pointed link is detected by the watch poll.
Activity
mcpx: one daemon on a socket that never moves; agents stop gracefully
fix(mcpx): keep the daemon key stable when a config symlink is re-poi…