Listing playlist

For scripting reasons I would like to be able to get the songs in the playlist output as a list of text through some mocp command or through some script. How can I go about doing this?