#!/usr/bin/env bash # Rebuild and run the scrobble MCP host in the foreground. # # The other half of the pair: `dev-pds.sh` in another terminal runs the # personal data server this writes to. This terminal is the scrobble feed — # one line per scrobble, the emoji the agent chose and what it said. # # Foreground on purpose, and over HTTP rather than stdio. Under stdio the # harness spawns and owns the process, and its log goes into the harness's # debug output where nobody watching a feed will see it. set -euo pipefail cd "$(dirname "$0")/.." # This directory's profile, if it has one. See dev-profile.sh. . "$(dirname "$0")/dev-profile.sh" . "$(dirname "$0")/dev-watch.sh" . "$(dirname "$0")/dev-pidfile.sh" PORT="${VIBESCROBBLE_MCP_PORT:-3001}" PDS_PORT="${VIBESCROBBLE_PDS_PORT:-3000}" PDS_URL="${VIBESCROBBLE_PDS_URL:-http://localhost:${PDS_PORT}}" say() { printf '\033[1m%s\033[0m\n' "$*"; } # `--watch` reruns this script whenever the source moves. It never returns. watch_or_continue "$@" # By pidfile rather than by pattern: see dev-pidfile.sh. claim_port mcp "${PORT}" vibescrobble-mcp # Not installed, and it does not need to be: the harness reaches this over HTTP # at a URL in .mcp.json rather than spawning a binary by name, so running it out # of the target directory is both faster and one fewer stale copy. say "building" cargo test --quiet -p vibescrobble-mcp # Warned about rather than waited for. The MCP host runs perfectly well with # the server down — it just refuses every scrobble — and blocking here would # make the order the two terminals are started in matter, which it should not. if ! curl -sf "${PDS_URL}/health" >/dev/null 2>&1; then say "note: no personal data server answering at ${PDS_URL}" echo " scrobbles will be refused until ./scripts/dev-pds.sh is running" echo fi say "scrobble MCP host on 127.0.0.1:${PORT}, writing to ${PDS_URL}" echo " .mcp.json { \"type\": \"http\", \"url\": \"http://127.0.0.1:${PORT}/mcp\" }" echo " a session must be restarted to pick up a changed tool schema" echo exec cargo run --quiet -p vibescrobble-mcp --bin vibescrobble-mcp -- \ --listen "127.0.0.1:${PORT}" --pds "$PDS_URL" "$@"