Reference

Environment variables

mpdaio.MPDClient honors the following environment variables:

MPD_HOST

MPD host (FQDN, IP, socket path or abstract socket) and password.

To define a password set MPD_HOST to “password@host” (password only “password@”)
For abstract socket use “@” as prefix : “@socket” and then with a password “pass@@socket
Regular unix socket are set with an absolute path: “/run/mpd/socket
MPD_PORT

MPD port, relevant for TCP socket only

MPD_TIMEOUT

socket timeout when connecting to MPD and waiting for MPD’s response (in seconds)

XDG_RUNTIME_DIR

path to look for potential socket

Default settings

Default host:
  • use MPD_HOST environment variable if set, extract password if present,

  • else looks for an existing file in ${XDG_RUNTIME_DIR:-/run/}/mpd/socket

  • else set host to localhost

Default port:
  • use MPD_PORT environment variable if set

  • else use 6600

Default timeout:

Supported commands

Status Commands

  • clearerror

  • currentsong

  • idle

  • noidle

  • status

  • stats

Playback Option Commands

  • consume

  • crossfade

  • mixrampdb

  • mixrampdelay

  • random

  • repeat

  • setvol

  • getvol

  • single

  • replay_gain_mode

  • replay_gain_status

  • volume

Playback Control Commands

  • next

  • pause

  • play

  • playid

  • previous

  • seek

  • seekid

  • seekcur

  • stop

Queue Commands

  • add

  • addid

  • clear

  • delete

  • deleteid

  • move

  • moveid

  • playlist

  • playlistfind

  • playlistid

  • playlistinfo

  • playlistsearch

  • plchanges

  • plchangesposid

  • prio

  • prioid

  • rangeid

  • shuffle

  • swap

  • swapid

  • addtagid

  • cleartagid

Stored Playlist Commands

  • listplaylist

  • listplaylistinfo

  • listplaylists

  • load

  • playlistadd

  • playlistclear

  • playlistdelete

  • playlistlength

  • playlistmove

  • rename

  • rm

  • save

Database Commands

  • albumart

  • count

  • getfingerprint

  • find

  • findadd

  • list

  • listall

  • listallinfo

  • listfiles

  • lsinfo

  • readcomments

  • readpicture

  • search

  • searchadd

  • searchaddpl

  • searchcount

  • update

  • rescan

Mounts and neighbors

  • mount

  • unmount

  • listmounts

  • listneighbors

Sticker Commands

  • sticker get

  • sticker set

  • sticker delete

  • sticker list

  • sticker find

  • stickernames

Connection Commands

  • close

  • kill

  • password

  • ping

  • binarylimit

  • tagtypes

  • tagtypes disable

  • tagtypes enable

  • tagtypes clear

  • tagtypes all

Partition Commands

  • partition

  • listpartitions

  • newpartition

  • delpartition

  • moveoutput

Audio Output Commands

  • disableoutput

  • enableoutput

  • toggleoutput

  • outputs

  • outputset

Reflection Commands

  • config

  • commands

  • notcommands

  • urlhandlers

  • decoders

Client to Client

  • subscribe

  • unsubscribe

  • channels

  • readmessages

  • sendmessage

Module documentation

MPDClient class

class mpdaio.client.MPDClient(host=None, port=None, password=None)[source]
Synopsis:

Main class to instanciate building an MPD client.

Parameters:
  • host (str | None) – MPD server IP|FQDN to connect to

  • port (str | int | None) – MPD port to connect to

  • password (str | None) – MPD password

musicpdaio tries to come with sane defaults, then running mpdaio.MPDClient with no explicit argument will try default values to connect to MPD. Cf. Reference for more about defaults.

The class is also exposed in mpdaio namespace.

>>> import mpdaio
>>> cli = mpdaio.MPDClient(host='example.org')
>>> print(await cli.currentsong())
>>> await cli.close()
mpd_timeout

connection timeout

host

Host used to make connections (str)

pwd

password used to connect (str)

port

port used with the current connection (int, str)

property version: str

MPD protocol version

property connections: list[mpdaio.connection.Connection]

connections in the pool

async close()[source]
Synopsis:

Close connections in the pool

Return type:

None

Constants

mpdaio.const.CONNECTION_TIMEOUT = 30

Seconds before a connection attempt times out (overriden by MPD_TIMEOUT env. var.)

mpdaio.const.SOCKET_TIMEOUT = None

Socket timeout in second > 0 (Default is None for no timeout)

mpdaio.const.CONNECTION_MAX = 100

Maximum concurrent connections