Providers
Providers are how Music Assistant reaches the outside world. This page helps you understand what kinds there are, what a provider folder holds, and what the server does with it from the moment it reads the manifest until it unloads it. To build one, go to Build a provider.
Provider types
Section titled “Provider types”Every provider subclasses Provider (music_assistant/models/provider.py) through one of these base classes in music_assistant/models/:
ProviderType |
Base class | What it adds |
|---|---|---|
MUSIC |
MusicProvider |
A music source: a streaming service, local files, a media server, radio |
PLAYER |
PlayerProvider |
A way to reach speakers. It registers a PlayerProtocol per device, see Players |
METADATA |
MetadataProvider |
Images, descriptions, lyrics and other metadata for library items |
PLUGIN |
PluginProvider |
Anything else, such as an audio source a player can play, or an AI, speech or image engine |
AUDIO_ANALYSIS |
AudioAnalysisProvider |
Analysis of the audio of a track, such as beats, key or loudness |
The core controllers also have a manifest, of type CORE. That is how their settings show up next to those of the providers.
What a provider folder holds
Section titled “What a provider folder holds”A provider is a folder under music_assistant/providers/, named after its domain:
manifest.json: domain, name, type, requirements, whether more than one instance is allowed (multi_instance), whether it is built in (builtin), what it depends on (depends_on), and the mDNS or SSDP services it wants to hear about.__init__.py: a module-levelsetup(mass, manifest, config)that returns the provider instance, and usually aSUPPORTED_FEATURESset it passes to the constructor.setup_flow.py(optional): an interactive, multi-step setup. Its presence alone tells the server the provider has one.strings.json: the English texts for its settings and messages.icon.svg,icon_dark.svg,icon_monochrome.svg(or.png): the icons the app shows.
Larger providers split their code over more modules and often have their own README.md. The _demo_* folders are annotated templates; they only load in dev mode.
The life of a provider
Section titled “The life of a provider”stateDiagram-v2 [*] --> Known: manifest.json read Known --> Configured: config created Configured --> Loading: load_provider Loading --> Loaded: setup and handle_async_init succeed Loading --> RetryWait: handled error RetryWait --> Loading: after a delay Loading --> Failed: login error or bug Loaded --> Loading: config changed Loaded --> [*]: unload
How to read this
Section titled “How to read this”- Known. At startup the server reads every
manifest.json, sets the tier, finds the icons and checks for asetup_flow.py. - Configured. A provider loads only when it has a config. Built-in providers get one by themselves. A few providers in
DEFAULT_PROVIDERS(constants.py) are set up by the server once, some only after their devices were seen on the network. All others are added by the user, through the settings or a setup flow. - Loading.
_load_providerinmass.pyimports the module (for a core provider it first installs the pinnedrequirements), callssetup(), loads and validates the config, and callshandle_async_init(), each with a time limit. A provider withdepends_onwaits until that provider has loaded. - Loaded. The provider is registered and the music or player controller is told. In the background
loaded_in_mass()runs, which is where a provider registers its own API commands. ThenPROVIDERS_UPDATEDis signaled and discovery runs for it. - RetryWait and Failed. The error is stored on the config as
last_error, so the app can show it. AMusicAssistantErroris retried after a growing delay. A login error, anUnsupportedSystemErroror any other exception is not. - Config changed. By default
Provider.update_configreloads the provider a second after a setting changes. - Unload.
mass.unload_providerstops its library sync, unloads providers that depend on it, removes its players and callsunload(is_removed).
Features
Section titled “Features”A provider declares what it can do as a set of ProviderFeature values, such as library sync or search for a music provider. Code checks it with provider.supports_feature() or finds providers with mass.get_providers_supporting_feature(). Pass the set to the constructor; do not override the supported_features property.
Instances
Section titled “Instances”One provider domain can run as several instances when its manifest sets multi_instance, for example two accounts of one streaming service. Each instance has its own instance_id and config. Code that works with a loaded provider uses the instance id; the domain names the provider code.
Built-in, core and community
Section titled “Built-in, core and community”- Built-in providers (
builtinin the manifest) are always configured and load also in safe mode. Theallow_disablefield says whether the user can switch one off. - The tier (
ProviderTier) says who maintains a provider.COREproviders ship in the server repository.COMMUNITYproviders live in their own repository and are installed through the community catalog. - The community catalog controller installs a community provider into the data folder, under
community_providers/<domain>/. It registers the manifest only while the catalog’s index allows that version to load. From then on the provider loads like any other. Its requirements go into a folder of their own, never into the server’s environment. - During development,
--dev-providers-dirloads providers from a folder outside the server, as community providers, in dev mode only.
Read deeper
Section titled “Read deeper”- models/provider.py: the
Providerbase class. - Build a provider and The manifest: building a music, player, metadata or plugin provider, and the manifest fields.
- community_catalog README: how community providers are installed, gated and updated.
- discovery README: how a provider hears about devices.
- Building a provider and Setup flows
- Inside the server and Players
Music Assistant is a project of the Open Home Foundation.