From 678a4762b887f3eabe5cad11254b2ab1ae859485 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Fri, 25 Sep 2026 13:26:28 -0500 Subject: [PATCH] fix(mcp): move uv/uvx known-dir table into hermes_platform resolver The #37589 uv/uvx fallback spelled its directory table (~/.local/bin, /opt/homebrew/bin, /usr/local/bin) inline in _launcher_fallback, which the managed-runtime ratchet flags as an unreviewed known_path_table outside hermes_platform/. known_dirs is the module whose contract is 'every table in Hermes lives here', so add uv_tool_dirs() there and compose it at the call site. Behavior is unchanged: same four directories probed in the same order (managed /bin first, then uv's install order), bare uv/uvx still resolves under a GUI-style PATH that lacks them. --- hermes_platform/resolver/known_dirs.py | 11 +++++++++++ tools/mcp_tool_config.py | 18 +++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/hermes_platform/resolver/known_dirs.py b/hermes_platform/resolver/known_dirs.py index d22fe0ac13..6901e19569 100644 --- a/hermes_platform/resolver/known_dirs.py +++ b/hermes_platform/resolver/known_dirs.py @@ -25,6 +25,17 @@ def rust_tool_dirs() -> tuple[str, ...]: return ("~/.cargo/bin",) if _POSIX else ("%USERPROFILE%/.cargo/bin",) +def uv_tool_dirs() -> tuple[str, ...]: + """uv's install locations outside PATH, in uv's own install order: the per-user + installer's ``~/.local/bin`` (every OS — that is where uv's docs put it), then + Homebrew (Apple Silicon ``/opt``, Intel / from-source ``/usr/local``). The tilde + form is deliberate: callers that only ``expanduser`` (the stdio launcher + fallback) get the same result as ``locate_command``'s expandvars+expanduser.""" + if _POSIX: + return ("~/.local/bin", "/opt/homebrew/bin", "/usr/local/bin") + return ("~/.local/bin",) + + def node_tool_dirs() -> tuple[str, ...]: return ("~/.npm-global/bin", "~/.bun/bin", "~/.volta/bin") if _POSIX else ("%APPDATA%/npm", "%USERPROFILE%/.bun/bin", "%LOCALAPPDATA%/Volta/bin") diff --git a/tools/mcp_tool_config.py b/tools/mcp_tool_config.py index 9fe3e11cce..fe6c821d35 100644 --- a/tools/mcp_tool_config.py +++ b/tools/mcp_tool_config.py @@ -172,18 +172,18 @@ def _launcher_fallback(command: str, *, windows: Optional[bool] = None) -> str: ``uv``/``uvx``: GUI launches (the Electron desktop app, macOS LaunchAgents) inherit the bare ``/usr/bin:/bin:/usr/sbin:/sbin`` PATH, which carries none of uv's install locations, so a bare ``command: uvx`` MCP server fails with ENOENT at ``execvp`` from Desktop even though it works - from an interactive terminal (#37589). Probed in the order uv's own docs install it: the - Hermes-managed ``/bin`` first, then the per-user installer's ``~/.local/bin``, then - Homebrew (Apple Silicon ``/opt``, Intel ``/usr/local``).""" + from an interactive terminal (#37589). The directory table lives in + ``hermes_platform.resolver.known_dirs.uv_tool_dirs`` (probed in the order uv's own docs install + it: the per-user installer first, then Homebrew); the Hermes-managed ``/bin`` is probed + before it.""" from hermes_constants import get_hermes_home + from hermes_platform.resolver.known_dirs import uv_tool_dirs home = os.path.expanduser("~") if command in {"uv", "uvx"}: - directories = [ - os.path.join(str(get_hermes_home()), "bin"), - os.path.join(home, ".local", "bin"), # uv's official installer - os.path.join(os.sep, "opt", "homebrew", "bin"), # Apple Silicon Homebrew - os.path.join(os.sep, "usr", "local", "bin"), # Intel Homebrew / from-source - ] + # expanduser: the table carries the ``~`` form so both this walk and + # locate_command's expandvars+expanduser agree on one spelling. + directories = [os.path.join(str(get_hermes_home()), "bin"), + *(os.path.expanduser(d) for d in uv_tool_dirs())] else: from hermes_constants import iter_hermes_node_dirs # /usr/local/bin: canonical Node location (from-source Linux, Hermes Docker image, Intel