TOKEN="$(tr -d '\n' < "$HOME/.config/mcp-bearer-token")"
{
echo "=== LIVE TEST 1: /mcp with CORRECT bearer (initialize) ==="
curl -s -o /tmp/lt1.out -w "HTTP %{http_code}\n" \
  -X POST http://127.0.0.1:18812/mcp \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  --data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"diag","version":"1"}}}'
echo "--- body (first 600 chars) ---"
head -c 600 /tmp/lt1.out
echo ""
echo ""
echo "=== LIVE TEST 2: /mcp with WRONG bearer (expect auth failure) ==="
curl -s -o /tmp/lt2.out -w "HTTP %{http_code}\n" \
  -X POST http://127.0.0.1:18812/mcp \
  -H "Authorization: Bearer WRONGTOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  --data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'
echo "--- body (first 300 chars) ---"
head -c 300 /tmp/lt2.out
echo ""
echo ""
echo "=== Where does Claude client get the AMD MCP url/token? ==="
echo "--- search ~/.claude.json ---"
grep -o '18812[^"]*' ~/.claude.json 2>/dev/null | head -5
grep -rIl 'advancedmd' ~/.claude.json ~/.claude 2>/dev/null | head
echo "--- search openclaw mcp-config render output / supervisors ---"
ls -la ~/repos/openclaw/tools/mcp-config/supervisors/ 2>&1
grep -rIl 'advancedmd\|18812' ~/repos/openclaw/tools/mcp-config 2>/dev/null | head
} > /tmp/d5.txt 2>&1
echo WROTE_D5
