#!/usr/bin/env bash
# note-mcp-failure.sh  -  PostToolUseFailure hook on MCP tools (mcp__.*).
#
# Appends the server, the tool, the time and a closed error class to the local
# MCP failure log. The logic is in note-mcp-failure.mjs; this wrapper exists
# because every hook the pipeline registers is a
# `bash "$HOME/.<host>/scripts/<name>"` command.
#
# Exits 0 on every path with no output: bookkeeping never holds a tool call.

set -u

HERE="$(cd "$(dirname "$0")" 2>/dev/null && pwd || true)"
CORE="$HERE/note-mcp-failure.mjs"
[ -f "$CORE" ] || exit 0
command -v node >/dev/null 2>&1 || exit 0

node "$CORE" >/dev/null 2>&1 || true
exit 0
