pub fn classify_mcp_command(
path_var: Option<&OsStr>,
current_exe: &Path,
) -> McpCommandExpand description
Pure classifier behind detect_mcp_command: decide whether the
mushroomdb that PATH resolves to is the executable now running.
A file named mushroomdb on PATH is not enough. npx mushroomdb install
prepends ~/.npm/_npx/<hash>/node_modules/.bin to PATH, and the
mushroomdb there is npm’s Node shim (#!/usr/bin/env node), not our
native binary; npm i -g mushroomdb installs the same shim. Treating that
as “on PATH” wrote a bare mushroomdb command that resolved only inside
the npx-spawned shell, so the MCP server and recall hook died with ENOENT
everywhere else (the v0.5.0 bug).
So: take the first PATH hit — that is what a bare name would resolve to —
and canonicalize both it and current_exe. Equal paths mean the bare name
runs this very executable, including via a symlink (how cargo install and
Homebrew expose it), which is the one case where the bare name is safe and
survives upgrades. Anything else means pinning the published package.