#music-player #cli #time #human-readable #track #stdin #format #duration

app mp-cli

A Music Player Daemon (MPD) CLI client implemented in Rust

4 releases

new 0.1.3 Sep 25, 2023
0.1.2 Sep 18, 2023
0.1.1 Sep 17, 2023
0.1.0 Sep 16, 2023

#61 in Audio

Download history 50/week @ 2023-09-11 48/week @ 2023-09-18

98 downloads per month




ci Coverage Status Crate Status

A Music Player Daemon (MPD) CLI client implemented in Rust.


I'm working towards compatibility with mpc over time. See this tracking issue for the current status.

Alternatively, see the help.


At this time it is necessary to compile and install the crate locally. The simplest way to do this is to install the Rust toolchain.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then use cargo to build and install from crates.io.

cargo install mp-cli


Mostly because I wanted to practice writing Rust. Also, for use with the wonderful macOS bar app SketchyBar. One of the plugins I've created displays the current status (playing/paused) of MPD along with the artist and title. I've used mpc for this purpose in the past but the status output is not well suited for parsing (more for human readability).

With this in mind I decided to implement a client that would provide a more consistent and parseable output.

 mp-cli status
artist=King Gizzard & The Lizard Wizard
title=Wah Wah

This format is easily and efficiently parseable in a shell script:

#! /usr/bin/env bash


while IFS='=' read -r key value; do
	case "$key" in
	'artist') artist="$value" ;;
	'state') state="$value" ;;
	'title') title="$value" ;;
	'volume') volume="$value" ;;
done <<<"$status"

echo "${artist}"
echo "${state}"
echo "${title}"
echo "${volume}"

Alternatively the status can be presented as JSON.

 mp-cli --format json status | jq
  "volume": "100",
  "state": "play",
  "artist": "King Gizzard & The Lizard Wizard",
  "title": "Road Train"


All of the heavy lifting of communicating with the daemon is handled by rust-mpd.

Obviously mpc the real CLI tool for interacting with mpd. For the commands that I have (currently) implemented I've done my best to mirror the interface of mpc. In theory this could be a drop in replacement, for the very limited use-case.


~73K SLoC