#!/bin/bash # Script to pretty print the output of the github-mcp-server # log. # # It uses colored output when running on a terminal. # show script help show_help() { cat <&2 exit 1 fi input="$1" else input="/dev/stdin" fi # check if we are in a terminal for showing colors if test -t 1; then is_terminal="1" else is_terminal="0" fi # Processs each log line, print whether is stdin or stdout, using different # colors if we output to a terminal, and pretty print json data using jq sed -nE 's/^.*\[(stdin|stdout)\]:.* ([0-9]+) bytes: (.*)\\n"$/\1 \2 \3/p' $input | while read -r io bytes json; do # Unescape the JSON string safely unescaped=$(echo "$json" | awk '{ print "echo -e \"" $0 "\" | jq ." }' | bash) echo "$(color $io)($bytes bytes):$(reset)" echo "$unescaped" | jq . echo done