Skip to content

Warn at session start when uv is missing - #5

Merged
jasiek merged 1 commit into
masterfrom
uv-check-hook
Jun 12, 2026
Merged

Warn at session start when uv is missing#5
jasiek merged 1 commit into
masterfrom
uv-check-hook

Conversation

@jasiek

@jasiek jasiek commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Problem

The genealogy MCP server is launched via uv run (see .mcp.json). If uv isn't on the user's PATH, the server fails to start and all its tools silently never loaduv: command not found with no actionable guidance.

Change

Add a SessionStart hook that checks for uv and, when it's missing, surfaces a clear install message to the user and injects context telling Claude the tools are unavailable (so it explains rather than blindly calling them). Stays completely silent on the happy path.

To work regardless of the shell Claude Code selects, the check ships in two shell-pinned flavours:

File Shell Covers
hooks/check-uv.sh bash macOS, Linux, Windows + Git Bash
hooks/check-uv.ps1 powershell Windows without Git Bash
hooks/hooks.json registers both on SessionStart (startup + resume), each pinned via the shell field

The PowerShell command sets a process-scoped Bypass execution policy so the .ps1 can run on default Windows hosts. Both scripts emit the same SessionStart JSON (systemMessage + hookSpecificOutput.additionalContext).

Docs updated: README gains a Requirements section (uv install for macOS/Linux and Windows); CLAUDE.md documents the hook.

Testing

  • hooks/check-uv.sh: verified silent (exit 0, 0 bytes) when uv is present; emits valid single-line JSON (validated with jq) when uv is absent.
  • hooks/hooks.json: structure validated (2 matchers × {bash, powershell}, correct shell pins).
  • Executable bit (100755) is committed so Git Bash on Windows treats the .sh as runnable.
  • ⚠️ hooks/check-uv.ps1 has not been exercised on a real Windows hostpwsh isn't available in the dev environment, and cross-platform shell-field behaviour is undocumented. Needs a Windows smoke test before fully relying on it.

🤖 Generated with Claude Code

The genealogy MCP server is launched via `uv run` (.mcp.json). If uv is
not on PATH the server fails to start and its tools silently never load —
a confusing failure mode with no actionable message.

Add a SessionStart hook that checks for uv and, when missing, shows the
user install instructions and tells Claude the tools are unavailable
(stays silent on the happy path). Ships in two shell-pinned flavours so
it runs whichever shell Claude Code selects:

- hooks/check-uv.sh  — bash (macOS, Linux, Windows + Git Bash)
- hooks/check-uv.ps1 — PowerShell (Windows without Git Bash); the command
  sets a process-scoped Bypass execution policy so the .ps1 can run
- hooks/hooks.json   — registers both on SessionStart (startup + resume),
  each pinned via the `shell` field

Document the uv requirement (macOS/Linux + Windows install) in README and
note the hook in CLAUDE.md. The .ps1 path is not yet verified on a real
Windows host — cross-platform `shell`-field behaviour is undocumented.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jasiek
jasiek merged commit d3dc283 into master Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant