Reference

Plugins

How plugins run, the manifest and the protocol.

Documents v3.1.0 Released Edit this page Report a problem

Plugins add things DroppedNeedle does not do on its own: another place to download from, a webhook for every play, audio for tracks you do not have, events for your home automation. They work much like community plugins in Lidarr: someone publishes a plugin in a GitHub repository, you paste the URL, and DroppedNeedle installs it.

This page is the reference: how plugins run, what they can do, the manifest, and the protocol. If you want to write one, start with docs/writing-a-plugin.md.

Read this first: plugins are trusted code#

Only install plugins you trust. A plugin is a program that runs on your server. It is not sandboxed. Once you enable it, it can read and write files and reach the network just like DroppedNeedle itself can.

What DroppedNeedle does to keep a plugin in its lane:

  • Nothing runs until you say so. Installing a plugin, or copying a folder into the plugins directory, only stores files. A plugin starts when an admin enables it in Settings > Plugins.
  • Installs are pinned. DroppedNeedle installs an exact commit and records it. The install screen shows that commit, the plugin’s version, and what it asks to do, before anything is written. The install takes exactly the commit you previewed, even if the branch or release has moved on since. An update stays the kind of install you chose, and stops if the repository at that address was deleted and created again.
  • Each plugin is its own process. If it crashes, only that plugin stops; DroppedNeedle restarts it after a short wait (1 second, doubling up to 5 minutes). If it hangs, its calls time out and the rest of the server carries on; three timeouts in a row restart it.
  • It gets a clean environment. Only PATH, TZ and the proxy and certificate variables pass through from the server’s environment, plus the plugin’s own name and folders. A proxy address with a password in it reaches the plugin too. Its working directory and HOME are its own data folder. DroppedNeedle never tells it where the config and database folders are.
  • Memory is capped. Each plugin process can use at most 1 GiB of address space, and it cannot dump core or gain privileges.
  • Calls have time limits (listed per capability below).

What this does not do: it does not stop a plugin that goes looking for your files. The plugin runs as the same user as the server, so if it knows where /app/config is, it can read it. Treat a plugin like any other program you would run on your server: read the code, or trust the author.

The protocol does not depend on processes, so a sandboxed mode (WebAssembly) can be added later without changing plugins.

Installing a plugin#

From GitHub#

In Settings > Plugins, paste the repository URL and press Preview.

  • https://github.com/owner/repo installs the latest release. If the repository has no releases, it installs the default branch as it is now. If GitHub refuses the request, rate limits your server or cannot be reached, the install stops with an error and nothing is installed.
  • https://github.com/owner/repo/releases/tag/v1.2.0 installs that release.
  • https://github.com/owner/repo/tree/some-branch installs that branch (or tag) as it is now.
  • https://github.com/owner/repo/commit/<sha> installs that commit.

An install archive may be at most 32 MiB, hold at most 2000 files and unpack to at most 256 MiB.

DroppedNeedle keeps its GitHub requests under GitHub’s limit for servers without an account: a burst of 10, then about 50 an hour, shared by installs, updates and DroppedNeedle’s own update check. A preview uses 4 requests from a plain repository URL and 3 from the other kinds. An install from the preview uses 2, and an update 2 or 3, plus 1 when there is a new commit to download. So after the first preview and install, about eight installs fit in an hour. When a preview, install or update would not fit, it stops before sending anything and says how long to wait, for example “GitHub requests are paced. Try again in 3 minutes.” That wait covers the whole operation, and it is usually DroppedNeedle’s own pacing, not a limit from GitHub.

The preview lists the plugin’s name, version, author, the exact commit, and what the plugin asks to do. Press Install to write it. The plugin arrives disabled; enable it, fill in its settings, and save.

To update later, press Update on the plugin. What moves depends on how it was installed:

  • From releases (a plain repository URL): to the newest release. If the repository has no releases any more, the update stops; install it again from a /tree/ or /commit/ URL to pick a branch, tag or commit.
  • From a branch (a /tree/ URL, or the default branch of a repository with no releases): to the branch’s newest commit, only when you press Update. It stays on the branch even if the repository has releases now.
  • From a tag or a commit: nowhere. Those pins stay until you install a different version.

Nothing updates on its own. Updating keeps your settings and the plugin’s data.

By hand#

Copy the plugin folder into the plugins directory and reload Settings > Plugins:

bash
cp -r examples/plugins/webhook-scrobbler /path/to/app/plugins/

If you edit a running plugin’s files in place, it starts again with the new code the next time plugins reload: a settings save, an install, an update or a server restart.

Under Docker the plugins directory is /app/plugins. Mount it as a volume, or installed plugins disappear when the container is recreated.

Removing#

Remove deletes the plugin’s code. Its settings stay in the config and its data folder stays on disk, so reinstalling picks up where you left off.

What a plugin needs#

The Docker image includes python3, so plugins written in Python work out of the box. If you build the image with --build-arg PLUGIN_PYTHON=0, Python is left out and only plugins that ship their own program (see command below) will run. Outside Docker, python3 (3.9 or newer for the helper; the example plugins need 3.11, which the image ships) must be on the server’s PATH.

Python plugins need nothing else installed. DroppedNeedle ships a small helper module, droppedneedle_plugin, and puts it on the plugin’s import path.

Where things live#

plugins/
  my-plugin/          the plugin's code (plugin.toml at the root)
  .data/my-plugin/    the plugin's own folder: working directory and HOME
  .sdk/python/        the Python helper, written by the server at start

Folders starting with . or _ are never treated as plugins.

The manifest: plugin.toml#

Every plugin has a plugin.toml at the root of its folder. DroppedNeedle checks it before running anything; a typo in a key is an error, never silently ignored.

toml
[plugin]
name = "acme-music"                 # lowercase letters, digits and dashes, up to 32
display_name = "Acme Music"
version = "1.0.0"
api_version = 2                     # the plugin API this host reads
entrypoint = "plugin:AcmeMusic"     # <python module>:<class>
capabilities = ["download_client", "indexer", "scheduler"]
description = "One line about what it does."
author = "you"
homepage = "https://acme-music.test"
# command = ["./bin/acme-plugin"]   # instead of entrypoint, for non-Python plugins

[[settings]]                        # one per setting the admin fills in
key = "api_key"
label = "API key"
help = "Shown under the field."
secret = true                       # encrypted at rest, masked on screen

[[capability]]                      # extra detail for some capabilities
id = "download_client"
display_name = "Acme Music"

[[capability]]
id = "indexer"
target_source = "plugin:acme-music" # or "usenet", or another plugin's key

[schedule]                          # required with "scheduler"
interval_minutes = 60               # 5 to 1440
run_on_load = false

[[route]]                           # needs the "publisher" capability
path = "lookup"                     # served at /api/v3/plugins/ext/acme-music/lookup;
                                    # up to 64 lowercase letters, digits, /, _ and -,
                                    # starting with a letter or digit
method = "GET"                      # GET, POST or DELETE
auth = "user"                       # "admin" (default) or "user"
rate_limit_per_minute = 60          # 1 to 600

[plugin_ui]                         # optional settings panel
entry = "ui/dist/panel.js"          # a script inside the plugin folder
pages = ["panel"]                   # one page at most
# external_url = "https://acme-music.test/setup"   # or a link instead: https, or
                                                   # http to a loopback address only

plugin.toml is ordinary TOML: arrays may span lines, and strings may use single quotes. A capability not in the table below is an error, and so is a homepage that is not an http or https address.

This DroppedNeedle reads plugin API version 2 only. A manifest with any other api_version, including 0 and 1 from DroppedNeedle v2, is refused before its code runs:

acme-music: written for api_version 1; this DroppedNeedle reads api_version 2; see Porting a v2 plugin in PLUGINS.md

Settings#

Settings are what the admin types into the plugin’s card. The plugin gets the current values when it starts and again whenever a save changes them, secrets decrypted. Secret values are encrypted in the settings database and shown as ********; saving the mask back keeps the stored value.

Running something other than Python#

Set command to the program and its arguments. A first entry starting with ./ points inside the plugin folder (files under bin/ and files starting with #! are made executable on install). The program must speak the protocol below on stdin and stdout, and exit when stdin closes.

Capabilities#

A plugin declares what it does in capabilities. With the Python helper, each capability is one or more methods on the plugin class, with the same names and arguments as in DroppedNeedle v2. Methods may be async or plain functions. Anything a method raises is logged against the plugin and the server carries on as if the plugin had said nothing.

CapabilityMethodsTime limitWhen a plugin fails
scrobbleron_scrobble(event)10 sthe play is still recorded
purchase_linkspurchase_links(artist, album, release_group_mbid)10 sno links from it, and the album asks again next time
subscriberon_event(event)5 sthat event is skipped
publisherhandle_route(method, subpath, query, body) for [[route]]s; await ctx.publish(kind, payload)5 sthe route answers 502
metadata_providerenrich_artist(...), enrich_album(...)15 snothing is filled in, and the page asks again next time
scheduleron_tick()the intervalthe next tick runs as normal
library_writernone; allows await ctx.write_library_file(rel_path, data)8 s per writethe call fails with the reason
streaming_sourceresolve_stream(recording_mbid, user_id)5 sthe next plugin is asked
indexersearch_album(...), search_track(...)35 sno results from it
download_clientenqueue, get_status, inspect_materialization, discard_client_artifacts, abort120 s enqueue, 30 s othersthe download fails over

Every plugin may also have is_configured() and health_check(). The server asks for them once the plugin is running, after a save that changes its settings, and again when Settings or a source list is opened and the last answer is over a minute old. The answer (status, message, and whether it is configured) shows on the plugin’s card in Settings > Plugins and in the source lists. A plugin without them counts as healthy and configured; one that fails or does not answer within 10 seconds shows as an error.

scrobbler#

on_scrobble(event) runs once per accepted play, after duplicates, very short tracks and Navidrome-handled plays are filtered out. event has artist, track, album, timestamp, duration_ms and recording_mbid. It runs in the background; the player never waits for it.

Example: examples/plugins/webhook-scrobbler.

The album page’s “Where to buy” list asks every purchase_links plugin after the links MusicBrainz knows, and adds theirs to it.

purchase_links(artist, album, release_group_mbid) returns a list of PluginPurchaseLink(label, url, kind), where kind is digital, physical or free. Links must be http or https. A link with an empty label is dropped, and so are duplicates (same URL), and the album page orders links by its own rules: a plugin cannot put itself first. At most 20 links per plugin.

Example: examples/plugins/metadata-joke-toy.

subscriber#

on_event(event) receives event.kind and event.payload (a dict you can also read with dots, like event.payload.task_id):

KindPayload
scrobbleartist, track, album, timestamp, duration_ms, recording_mbid
playback_startedartist, track, album, user_id
download_started, download_completed, download_failedtask_id, user_id, release_group_mbid, source, outcome
request_created, request_fulfilledrequest_id, user_id, release_group_mbid, status
import_finishedrelease_group_mbid, track_count, source (drop_import for an upload, import_folder for the import folder)
plugin_noticesource_plugin, title, body

Each plugin handles one event at a time. An event that arrives while the plugin is still busy with the last one is skipped and counted in the plugin’s health as a dropped event. Events never wait on plugins.

request_fulfilled fires once per request, when its download, a drop import or a library check brings its album into the library. A track request, or a failed request whose download still exists, is not settled when its files arrive some other way, and an event is lost if the server stops between saving the change and sending it.

scrobble and playback_started fire together and reach each plugin one after the other, so neither is skipped for the other. They fire where scrobbling happens, so very short tracks and Navidrome-handled plays raise neither.

publisher#

Two things come with publisher:

Routes. Each [[route]] is served at /api/v3/plugins/ext/<plugin>/<path> and calls handle_route(method, subpath, query, body), which returns PluginRouteResponse(status, body). DroppedNeedle checks the session and role first (auth = "admin" refuses other users with 403), applies the per-user rate limit (429 with Retry-After), and refuses request bodies over 1 MiB (413). Statuses 200-299 and 400 pass through with the plugin’s body. A 404 answers the server’s own not-found error, 500-599 become 502, and anything else becomes 200, so a plugin cannot redirect people through your server. Answers over 1 MiB, and any failure, become a plain 502; the plugin’s error text never reaches the browser. An undeclared path or a disabled plugin is 404.

Publishing. await ctx.publish(kind, payload) sends one of three hints:

KindFieldsWhat happens
plugin_noticetitle, bodysent to every subscriber as a plugin_notice event
download_notetask_id, note (up to 1 KiB)written to the server log against that download
indexer_invalidatetarget_sourcewritten to the server log; the next search asks the plugin again anyway

The result has ok, status, retry_after and error. Limits: 30 publishes a minute per plugin (429 after that), unknown fields are refused (422), and a plugin that is handling a plugin_notice cannot publish again (409), so two plugins cannot bounce notices between them forever. The same event never reaches the same plugin twice.

Example: examples/plugins/events-echo-toy.

metadata_provider#

The artist page asks enrich_artist when it loads the biography, and the album page asks enrich_album for a small “From plugins” card under the Last.fm notes.

enrich_artist(*, artist_name, mbid=None, timeout=...) and enrich_album(*, artist_name, album_title, mbid=None, timeout=...) return a PluginArtistEnrichment / PluginAlbumEnrichment (biography, links, tags, image_urls) or None for “not mine”. Plugins only fill gaps, and not every field shows:

PageWhat shows from a plugin
Artistthe first plugin biography and the first image (https only), each only when Wikipedia and Wikidata have none; links and tags are not shown
Albumthe notes, only when Last.fm has none; tags Last.fm did not already list; links (http and https); no image

All plugin text is shown as plain text.

Example: examples/plugins/metadata-joke-toy.

scheduler#

on_tick() runs every interval_minutes (at least 5). One tick at a time per plugin; a tick still running when the next is due is cancelled; a failed or cancelled tick is logged, and the next one comes a little later: one extra second, doubling while ticks keep failing, up to five minutes. Missed ticks are not made up. With run_on_load = true the first tick runs right after the plugin starts.

For state that should survive restarts, use await ctx.state_set(key, value) and await ctx.state_get(key): small strings (up to 1 MiB each) that the server keeps in its database for you (at most 1000 keys and 64 MiB per plugin). Files in ctx.data_dir also survive.

To put a file into the music library itself, declare the library_writer capability and use await ctx.write_library_file(rel_path, data). It adds one new file under your first library folder and answers the full path. The path is relative, at most 200 characters, in lowercase letters, digits, _, -, . and /, without hidden or .. parts. A file that already exists is never replaced, nor is a file whose name differs only in letter case or Unicode form (Straße for strasse): the call fails instead. A first library folder set to Excluded, one that isn’t there (a share not mounted), one reached through a link into another library folder, or one on a disk that can only add a file by checking first and then renaming, takes no plugin files: the call fails. Neither does a path under a path rule set to Excluded. While the library is switched off, the call fails with the library is switched off; try again once it is on. Each plugin may write 100 MiB and 1000 files a day; past either the call fails until older writes are a day old. The allowance is kept in the database, so a restart does not reset it, and a write that failed or was undone by itself does not count. One file may be at most 6,288,384 bytes (just under 6 MiB, so its base64 text fits one 8 MiB message); the helper raises ValueError for a larger one before sending anything, and the host refuses one sent anyway. The write has 8 seconds: it waits for the library to be free (no move or other change running) and then fails, and a file not in place by then, or that the server stopped waiting for, is never put there. In rare cases a host request timed out answer means the file did land; a retry then answers that it already exists. Why the last write was refused shows on the plugin’s card in Settings > Plugins, beside its health, until a write lands, the plugin is switched off or removed, or the server restarts. After each write the library folder is scanned again, so the file, audio included, shows up like any other.

Each write is a recorded library change, made the way the server makes its own: the file is written beside its destination under a hidden name and put in place only if the name is still free, so after a crash it is either in place whole or not there at all. The server log line plugin added a library file names the plugin, the path and the change’s bundle_id (the low-level answer carries the same id). An administrator sees every file a plugin added under Library files on the plugin’s card in Settings > Plugins (path, when, size, and whether it was undone) and can undo one there, or with POST /api/v3/library/manage/undo and {"bundle_id": "..."}. The list is GET /api/v3/library/manage/plugin-files?plugin=<name>. Undo removes the file only while it still holds the bytes the plugin wrote; when it was changed since, or its folder takes no changes now, the undo says so and leaves the file. Each write can be undone once, and the folder is scanned again afterwards, so a track made from the file goes missing.

Example: examples/plugins/http-catalog (its tick). No example writes state or library files.

streaming_source#

resolve_stream(recording_mbid, user_id) returns PluginStreamRef(path=..., url=..., content_type=..., duration_seconds=...) with exactly one of path or url, or None for “not mine”. The plugin gets the signed-in user’s id, never their password or token.

Your own library always wins: plugins are only asked when the library does not have the track. They are asked in name order and the first answer wins. Before anything is served, DroppedNeedle checks the answer:

  • A path (relative paths are inside the plugin folder) must resolve, after symlinks, to a file inside the plugin folder, its data folder, the folder in the plugin’s downloads_dir setting if it has one, or a library folder. It is then served like a library file, with seeking and transcoding.
  • A url must be http or https, with no user name or password in it, and the host must resolve to public internet addresses only: no localhost, private networks, link-local, or IPv6 addresses outside global unicast (IPv4 hidden inside IPv6 is checked as IPv4). The server connects directly, without any proxy, checks the address it actually connected to, and follows up to three redirects, each checked again. The server must answer within 10 seconds and keep sending at least every 30 seconds; a stream stops at 500 MiB. The audio is passed through as-is, without seeking or transcoding.

Plugin streams are reachable through Subsonic and Jellyfin clients (when the library misses) and at /api/v3/stream/plugin/<recording mbid>.

Example: examples/plugins/stream-toy.

indexer and download_client#

A plugin with download_client is a download source with the key plugin:<name>. It shows up in the source list and in the source priority setting; sources not listed there are tried after the listed ones.

An indexer searches for releases. Its results go to the source named in target_source: its own client (the default when it also has download_client), another plugin’s client (plugin:other-name), or usenet, where results that carry an nzb_url join the SABnzbd pipeline next to your Newznab or Prowlarr results. The first 200 results of a search are kept.

Search methods return a list of IndexerResult(source, plugin=PluginSearchResult(...)) (or bare PluginSearchResults):

python
PluginSearchResult(
    title="Artist - Album",
    size_bytes=0,
    score=0.9,            # your confidence, 0 to 1
    quality_tier="",      # lossless, mp3_320, mp3_256, mp3_192, low, or ""
    files=[],             # exact files (files mode), or empty (folder mode)
    payload="",           # anything; handed back to your client at enqueue
    nzb_url="",           # for indexers that feed "usenet"
)

Automatic downloads skip a result whose quality_tier is outside the user’s quality settings, or whose files include audio in a format those settings don’t list. They can still pick it by hand. A result that says neither is judged when its files land.

You rank your source; DroppedNeedle applies its rules on top, the same as for every other source. Quarantined releases are dropped. A score of preflight_score_auto_accept (0.70 by default) or more downloads automatically. A score from preflight_score_manual_min (0.50 by default) up to that is kept back for a person to pick. Both cut-offs are download policy settings. A result with a lower score, an ignored term, a missing required term, a size over the limit or a quality outside the range never downloads by itself: a person searching by hand sees it last, with the reason, and can still pick it after confirming. When a download fails, the next result is tried.

The client then gets enqueue(request) with task_id, source, files, payload, job_name and download_type, and returns a TaskHandle. Every later call (get_status, inspect_materialization, discard_client_artifacts, abort) gets that handle back, with plugin_token set to the result’s payload. get_status returns a DownloadTaskStatus (status is queued, downloading, completed or failed); inspect_materialization returns a DownloadMaterialization with the finished files in file_paths.

When enqueue or get_status fails, say whose fault it was by raising DownloadFailure(message, fault=...):

faultMeansFailed enqueueFailed get_status
localthis machine: a full disk, a folder it cannot write, a lost mounttried again laterthe download moves to the next result; this release is not blamed
sourcethe release, the peer or the service it came fromthe next source is tried; with none left, the download ends with nothing foundthe release is blamed: the next result is tried and this one is skipped for 7 days
unknownyou can’t tellthe same as sourcethe same as source

Any other exception counts as unknown. Don’t guess local: a release that really is broken would be tried again and again. For a local problem in get_status, raise DownloadFailure(..., fault="local"); don’t return status: "failed", which always blames the release. A failed inspect_materialization is handled the same way whatever the fault: the import waits a few passes for the files to be listed, then fails with the files kept.

Finished files must be inside the plugin’s data folder (ctx.data_dir) or the folder in the plugin’s downloads_dir setting, if its manifest declares one. Report absolute paths. If any reported path is outside those folders, or is a link or sits under one, the whole download is refused and nothing is read. workspace_path does not widen this: it is only used as the folder to import when file_paths is empty.

Files mode (non-empty files) means the client fetches exactly those files. Folder mode (empty files) means the client works out the files itself and reports them when done.

Examples: examples/plugins/http-catalog (files mode), examples/plugins/local-folder-client with local-folder-indexer (folder mode, two plugins paired).

Settings panel#

With [plugin_ui] entry, the admin’s plugin card shows the plugin’s own script in a locked-down frame: no access to the page or its cookies, and no requests of its own. It can talk to the page only through postMessage, with four read-only requests: sources.list (every plugin download source), search.preview, get_settings (its own, secrets masked) and health.get (whether it is on, its load error and its active capabilities). search.preview with {query} calls the plugin’s own search route (GET /api/v3/plugins/ext/<plugin>/search?query=...), so a panel that uses it needs the publisher capability and a [[route]] path = "search". external_url shows a link instead. The panel is served only while the plugin is enabled.

The server reads the script from inside the plugin folder and serves it to admins only, inlined into a small page of its own with an empty <div id="panel-root"> to draw into. The script is not served as a file: there is no address to load it from. Inline script and style run, pictures load from data: and blob: addresses only, and nothing else loads or connects. Because the script is inlined, every </script in the file is sent as <\/script, which reads the same inside a JavaScript string. One pair is not handled: a file holding <!-- and, anywhere after it, <script gives a panel that never runs. If your bundle has both, write one of them another way, for example '<' + '!--' or '<' + 'script'.

One thing the panel page cannot stop by itself: its script sending its own frame to another address, with whatever it writes into that address. The web UI’s content-security policy holds the frame to DroppedNeedle’s own address and YouTube’s player, so this is closed while that policy is enforced or only reporting (Settings > Security), not while it is off.

The Python helper#

droppedneedle_plugin gives the plugin class one argument, the context:

  • ctx.settings: the saved settings, a dict updated in place when they change.
  • ctx.http: an async HTTP client with get, post, put, delete, head (taking params, headers, json, data, content, timeout), returning a response with status_code, headers, content, text and json().
  • ctx.logger: a logger; its lines land in the server log under the plugin’s name.
  • ctx.publish(kind, payload), ctx.state_get(key), ctx.state_set(key, value).
  • ctx.write_library_file(rel_path, data): add one new file to the library (see the scheduler section).
  • ctx.scoring.album_match(artist, album, title) and track_match(...): optional 0-1 word-overlap scores for indexers.
  • ctx.name, ctx.plugin_dir, ctx.data_dir.

Do not print to stdout: it carries the protocol. The helper sends print output to the log instead, and anything a plugin writes to stderr is logged too, one entry per line.

Porting a v2 plugin#

  1. Set api_version = 2 in plugin.toml. The rest of a v2 manifest reads as it is, as long as name uses only lowercase letters, digits and dashes, homepage, if set, is an http or https address, and each value has its proper type (text quoted, secret true or false).

  2. Change the imports. Everything v2 plugins imported from infrastructure.plugins.protocols, models.common and repositories.protocols.* now comes from droppedneedle_plugin:

    python
    from droppedneedle_plugin import PluginRouteResponse, ServiceStatus, TaskHandle
  3. If you used ctx.http like httpx, it keeps working for the common calls above. Streaming responses and client options are not there.

  4. Anything that reached into the server’s own Python code no longer exists; use ctx instead. plugin_write_library_file(plugin_name=..., rel_path=..., data=...) becomes await ctx.write_library_file(rel_path, data). Paths may now contain dots, and an existing file is never replaced (v2 replaced it).

  5. State you kept in memory is lost when the plugin restarts (it is a separate process now). Keep anything important in ctx.state_set or in files under ctx.data_dir.

A v2 plugin’s settings come across in an upgrade, switched off. Once the ported plugin is installed, switch it on in Settings > Plugins.

The protocol#

Plugins and the server talk JSON-RPC 2.0 over the plugin’s stdin and stdout, one JSON message per line (UTF-8, ending in \n, at most 8 MiB). Either side may send requests. stderr is free-form log output. The Python helper does all of this; you need it only for a plugin in another language.

Starting and stopping#

  1. The server starts the plugin with its data folder as the working directory and sends initialize:

    json
    {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {
      "protocol_version": 1,
      "host": {"name": "droppedneedle", "version": "3.0.0"},
      "plugin": {"name": "acme-music", "version": "1.0.0", "api_version": 2,
                 "entrypoint": "plugin:AcmeMusic", "capabilities": ["indexer"]},
      "settings": {"api_key": "..."},
      "plugin_dir": "/app/plugins/acme-music",
      "data_dir": "/app/plugins/.data/acme-music"}}
  2. The plugin answers within 15 seconds with the protocol version it speaks and the capabilities it implements:

    json
    {"jsonrpc": "2.0", "id": 1, "result": {"protocol_version": 1, "capabilities": ["indexer"]}}

    A different protocol_version, an answer that does not read, or an error answer stops the plugin until plugins next reload (a settings save, an install, an update or a restart).

  3. To stop, the server sends shutdown and waits 2 seconds before killing the plugin’s process group. A plugin must also exit when stdin closes.

Server to plugin#

MethodParamsResult
initializesee above{protocol_version, capabilities}
shutdownnoneanything
plugin.healthnone{status: "ok"\|"error", message, configured}
scrobbler.on_scrobblescrobble fieldsnull
purchase_links.get{artist, album, release_group_mbid}[{label, url, kind}]
subscriber.on_event{kind, payload, causation_id}null
scheduler.on_ticknonenull
routes.handle{method, subpath, query, body}{status, body}
metadata.enrich_artist{artist_name, mbid}enrichment or null
metadata.enrich_album{artist_name, album_title, mbid}enrichment or null
stream.resolve{recording_mbid, user_id}{path, url, content_type, duration_seconds} or null
indexer.search_album{artist_name, album_title, year, track_count, timeout}[search result]
indexer.search_track{artist_name, track_title, album_title, duration_seconds, timeout}[search result]
download_client.enqueue{task_id, source, files, payload, job_name, download_type}task handle
download_client.status{handle}task status
download_client.inspect{handle}{state, workspace_path, file_paths, mount_healthy}
download_client.discard{handle}true/false
download_client.abort{handle}true/false

Notifications (no answer): settings.update with {settings} when the admin saves, and $/cancel with {id} when the server stops waiting for a request.

Answer an unknown method with error code -32601; the server treats that as “not implemented”. Use -32000 for your own failures. Any error except -32601 may say whose fault it was in its data: {"fault": "local" | "source" | "unknown"}. Only download_client.enqueue and download_client.status act on it. A missing data, or a value the server does not know, reads as unknown.

Plugin to server#

MethodParamsResult
host.publish{kind, payload, causation_id?}{ok, status, retry_after, error}
host.state.get{key}{value} (null when unset)
host.state.set{key, value}{}
host.library.write{rel_path, data_base64}{path, bundle_id}; refused (-32001) for a bad path, a file over 6,288,384 bytes, an existing file, a library that is switched off or stays busy for 8 s, or over the daily allowance

State keys are 1-64 lowercase letters, digits, _, - or /, starting with a letter or digit; values are strings up to 1 MiB. One plugin may keep at most 1000 keys and 64 MiB in total. host.log is a notification with {level, message} (error, warning, info, debug) for plugins that prefer it to stderr.

A plugin may have 32 requests to the host in flight; more are refused (-32001). The host answers each within 10 seconds or fails it, and the helper waits 15 seconds for an answer.

Examples#

All in examples/plugins/, all using fictional hosts:

  • webhook-scrobbler: scrobbler, the smallest plugin.
  • metadata-joke-toy: metadata_provider and purchase_links.
  • events-echo-toy: subscriber, publisher and routes.
  • stream-toy: streaming_source with a file in its own folder.
  • http-catalog: download_client, indexer (files mode), scheduler and a settings panel. Read this one first for sources.
  • local-folder-client and local-folder-indexer: folder mode, one plugin feeding another.

They double as the plugin tests: the server’s test suite runs each one as a real process.

Publishing a plugin#

Put plugin.toml and your code at the root of a public GitHub repository and make a release. People install it by pasting the repository URL. Bump version in plugin.toml with each release so admins can see what they have.

Respect the services your plugin talks to: their terms and their rate limits. Ask for credentials as secret settings; never put them in the code. DroppedNeedle ships no sources and endorses no plugins beyond the examples.

Docs