Save it as a script, perhaps even as an alias:
mpc play `shuf -e $(mpc playlist -f "[(%position%) %artist% %title% %file%]" |egrep $1 | grep -Eo "\(.*\)"| sed 's:).*::g' | sed 's:(::g') -n 1`
Then type at some terminal:
(or however you chose to name/alias it)
And mpc will play a random song from the pool resulting from the keyword filter.
I guess the whole...