Deluan cab656dbe5 refactor: host function wrappers to use structured request and response types
- Updated the host function signatures in `nd_host_artwork.go`, `nd_host_scheduler.go`, `nd_host_subsonicapi.go`, and `nd_host_websocket.go` to accept a single parameter for JSON requests.
- Introduced structured request and response types for various cache operations in `nd_host_cache.go`.
- Modified cache functions to marshal requests to JSON and unmarshal responses, improving error handling and code clarity.
- Removed redundant memory allocation for string parameters in favor of JSON marshaling.
- Enhanced error handling in WebSocket and cache operations to return structured error responses.
2025-12-31 17:06:29 -05:00
..

Navidrome Plugin Examples

This folder contains example plugins for Navidrome that demonstrate how to build metadata agents using the plugin system.

Building

Prerequisites

Build all plugins

make

This will compile all example plugins and place the .wasm files in this directory.

Build a specific plugin

make minimal.wasm
make wikimedia.wasm

Clean build artifacts

make clean

Available Examples

Plugin Description
minimal A minimal example showing the basic plugin structure
wikimedia Fetches artist metadata from Wikidata, DBpedia, and Wikipedia
crypto-ticker Real-time cryptocurrency prices from Coinbase using WebSocket
discord-rich-presence Discord Rich Presence integration using Scrobbler, WebSocket, Scheduler

Testing with Extism CLI

You can test any plugin using the Extism CLI:

# Test the manifest
extism call minimal.wasm nd_manifest --wasi

# Test with input
extism call minimal.wasm nd_get_artist_biography --wasi \
  --input '{"id":"1","name":"The Beatles"}'

For plugins that make HTTP requests, use --allow-host to permit access:

extism call wikimedia.wasm nd_get_artist_biography --wasi \                                                                                      3s   ▼ 
  --input '{"id":"1","name":"Yussef Dayes"}' \
  --allow-host "query.wikidata.org" --allow-host "en.wikipedia.org"

Installation

Copy any .wasm file to your Navidrome plugins folder:

cp wikimedia.wasm /path/to/navidrome/plugins/

Then enable plugins in your navidrome.toml:

[Plugins]
Enabled = true
Folder = "/path/to/navidrome/plugins"

And add the plugin to your agents list:

Agents = "lastfm,spotify,wikimedia"

Creating Your Own Plugin

See the minimal example for the simplest starting point, or wikimedia for a more complete example with HTTP requests, created with the [XTP CLI]((https://docs.xtp.dylibso.com/docs/cli).

Bootstrapping a New Plugin

Use the XTP CLI to bootstrap a new plugin from a schema:

xtp plugin init \
  --schema-file plugins/schemas/metadata_agent.yaml \
  --template go \
  --path ./my-plugin \
  --name my-plugin

See the schemas README for more information about available schemas and supported languages.

For the simplest starting point, look at minimal. For a more complete example with HTTP requests, see wikimedia.

For full documentation, see the Plugin System README.