deep-roon-mcp 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,7 @@ server of its own and sends nothing anywhere else. What you ask goes to your MCP
22
22
 
23
23
  ## Status
24
24
 
25
- Version 0.4: fifty-seven tools. Qobuz, TIDAL or both — whatever is signed in on your Core.
25
+ Version 0.4: fifty-nine tools. Qobuz, TIDAL or both — whatever is signed in on your Core.
26
26
 
27
27
  **Reading** — changes nothing in Roon:
28
28
 
@@ -32,6 +32,7 @@ Version 0.4: fifty-seven tools. Qobuz, TIDAL or both — whatever is signed in o
32
32
  | `roon_new` | Qobuz's shelves (new, qobuzissimes, press awards, top, trending, ideal discography) or TIDAL's (new, recommended, top, rising, masters; albums or tracks) — by genre |
33
33
  | `roon_genres` | Qobuz's genres and their ids, or TIDAL's genres and moods |
34
34
  | `roon_album` | An album's page: tracks, release dates, label, barcode, credits |
35
+ | `roon_track_files` | Where your own files are: per track of an album, an artist or a list of tracks, the file path as the Core sees it (and duplicates) — Roon's export data |
35
36
  | `roon_review` | The review Roon shows, in full, with its author |
36
37
  | `roon_bio` | The biography Roon shows, in full, with related artists |
37
38
  | `roon_artist` | An artist's discography at Qobuz or TIDAL, oldest first |
@@ -108,7 +109,7 @@ The settings (Claude Desktop › Settings › Extensions › Deep Roon MCP):
108
109
  | Setting | What it does |
109
110
  |---|---|
110
111
  | Roon Core address | Empty: found on your network. Fill in the Core's address for another subnet or a private VPN (Tailscale) |
111
- | Essentials only | Seventeen tools instead of fifty-seven, for small models |
112
+ | Essentials only | Seventeen tools instead of fifty-nine, for small models |
112
113
  | Use Roon's internal protocol | Off: only the official API — zones, playback, volume, grouping; no search, reviews, Focus or history |
113
114
 
114
115
  ### Other clients
@@ -12358,7 +12358,7 @@ var require_websocket = __commonJS({
12358
12358
  var EventEmitter = require("events");
12359
12359
  var https = require("https");
12360
12360
  var http2 = require("http");
12361
- var net2 = require("net");
12361
+ var net3 = require("net");
12362
12362
  var tls = require("tls");
12363
12363
  var { randomBytes: randomBytes2, createHash } = require("crypto");
12364
12364
  var { Duplex, Readable: Readable2 } = require("stream");
@@ -13120,13 +13120,13 @@ var require_websocket = __commonJS({
13120
13120
  __name(emitErrorAndClose, "emitErrorAndClose");
13121
13121
  function netConnect(options) {
13122
13122
  options.path = options.socketPath;
13123
- return net2.connect(options);
13123
+ return net3.connect(options);
13124
13124
  }
13125
13125
  __name(netConnect, "netConnect");
13126
13126
  function tlsConnect(options) {
13127
13127
  options.path = void 0;
13128
13128
  if (!options.servername && options.servername !== "") {
13129
- options.servername = net2.isIP(options.host) ? "" : options.host;
13129
+ options.servername = net3.isIP(options.host) ? "" : options.host;
13130
13130
  }
13131
13131
  return tls.connect(options);
13132
13132
  }
@@ -15525,7 +15525,7 @@ var require_lib2 = __commonJS({
15525
15525
  var version2;
15526
15526
  var init_package = __esm({
15527
15527
  "package.json"() {
15528
- version2 = "0.4.5";
15528
+ version2 = "0.4.7";
15529
15529
  }
15530
15530
  });
15531
15531
 
@@ -15613,10 +15613,51 @@ function connect() {
15613
15613
  transport = null;
15614
15614
  zones.clear();
15615
15615
  zonesIn = false;
15616
- log("the extension connection closed (another copy of Deep Roon MCP may have taken it over) \u2014 it opens again when a tool needs it");
15617
- }, "onclose")
15616
+ void afterClose();
15617
+ }, "onclose"),
15618
+ // A connection that never opened gets no onclose from node-roon-api, only an error — and `open` stayed true, so neither
15619
+ // a tool nor the retry ever tried again. Before pairing, an error means: not connected.
15620
+ onerror: /* @__PURE__ */ __name(() => {
15621
+ if (transport) return;
15622
+ open2 = false;
15623
+ void afterClose();
15624
+ }, "onerror")
15625
+ });
15626
+ }
15627
+ function reachable(ms = 3e3) {
15628
+ return new Promise((resolve) => {
15629
+ if (!core) return resolve(false);
15630
+ const sock = import_net.default.connect({ host: core.host, port: core.port });
15631
+ const done = /* @__PURE__ */ __name((ok) => {
15632
+ sock.destroy();
15633
+ resolve(ok);
15634
+ }, "done");
15635
+ sock.setTimeout(ms, () => done(false));
15636
+ sock.once("connect", () => done(true));
15637
+ sock.once("error", () => done(false));
15618
15638
  });
15619
15639
  }
15640
+ async function afterClose() {
15641
+ if (retrying) return;
15642
+ if (await reachable()) {
15643
+ log("the extension connection closed while the Core answers \u2014 probably another copy of Deep Roon MCP took it over; it opens again when a tool needs it");
15644
+ return;
15645
+ }
15646
+ retrying = true;
15647
+ log("the extension connection closed and the Core doesn't answer (network or Core restart) \u2014 reconnecting when it's back");
15648
+ let pause = 5e3;
15649
+ while (!open2) {
15650
+ await new Promise((r) => setTimeout(r, pause).unref());
15651
+ if (open2) break;
15652
+ if (await reachable()) {
15653
+ log("the Core answers again \u2014 reconnecting");
15654
+ connect();
15655
+ break;
15656
+ }
15657
+ pause = Math.min(pause * 2, 3e5);
15658
+ }
15659
+ retrying = false;
15660
+ }
15620
15661
  async function paired(ms = 8e3) {
15621
15662
  if (transport) return transport;
15622
15663
  connect();
@@ -15658,11 +15699,12 @@ async function setVolume(name, change) {
15658
15699
  }
15659
15700
  return { zone: z2.display_name, outputs: outs.map((o) => ({ output: o.display_name, scale: `${o.volume.min}\u2013${o.volume.max}` })), volume: change.value, muted: change.mute };
15660
15701
  }
15661
- var import_fs, import_os, import_path, import_node_roon_api, import_node_roon_api_transport, STATE_FILE, readState, writeState, transport, zones, started, waiting, zonesIn, zoneWaiting, roon, core, open2, officialZones, isPaired;
15702
+ var import_fs, import_net, import_os, import_path, import_node_roon_api, import_node_roon_api_transport, STATE_FILE, readState, writeState, transport, zones, started, waiting, zonesIn, zoneWaiting, roon, core, open2, retrying, officialZones, isPaired;
15662
15703
  var init_official = __esm({
15663
15704
  "src/core/official.ts"() {
15664
15705
  "use strict";
15665
15706
  import_fs = __toESM(require("fs"));
15707
+ import_net = __toESM(require("net"));
15666
15708
  import_os = __toESM(require("os"));
15667
15709
  import_path = __toESM(require("path"));
15668
15710
  import_node_roon_api = __toESM(require_lib());
@@ -15694,6 +15736,9 @@ var init_official = __esm({
15694
15736
  open2 = false;
15695
15737
  __name(startOfficial, "startOfficial");
15696
15738
  __name(connect, "connect");
15739
+ __name(reachable, "reachable");
15740
+ retrying = false;
15741
+ __name(afterClose, "afterClose");
15697
15742
  __name(paired, "paired");
15698
15743
  officialZones = /* @__PURE__ */ __name(() => [...zones.values()], "officialZones");
15699
15744
  isPaired = /* @__PURE__ */ __name(() => !!transport, "isPaired");
@@ -16426,6 +16471,71 @@ async function discography(key, wanted) {
16426
16471
  return { service: SERVICE_NAME[service2], artist, albums };
16427
16472
  });
16428
16473
  }
16474
+ async function trackFiles(a) {
16475
+ return withCore(async (c) => {
16476
+ const cb = { type: "ResultCallback<IList<TrackExportInfo>>", name: "cb_result" };
16477
+ let res;
16478
+ if (a.tracks?.length) {
16479
+ if (a.tracks.some((k) => !/^\d+$/.test(k))) throw new RoonError("A track key is a number", "invalid");
16480
+ res = await short(c.call(
16481
+ "Library",
16482
+ "GetTrackExportInfo",
16483
+ [{ type: "IEnumerable<long>", name: "ids" }, cb],
16484
+ buildArgs([Arg.collection(a.tracks.map((k) => buildArgs([Arg.long(BigInt(k))])))]),
16485
+ library(c)
16486
+ ), 2e4);
16487
+ } else if (a.album) {
16488
+ const al = await findAlbum(c, a.album);
16489
+ res = await short(c.call(
16490
+ "Library",
16491
+ "GetTrackExportInfoForAlbums",
16492
+ [{ type: "IEnumerable<AlbumBase>", name: "albums" }, cb],
16493
+ buildArgs([Arg.collection([buildArgs([Arg.ref(al.oid)])])]),
16494
+ library(c)
16495
+ ), 2e4);
16496
+ } else if (a.artist) {
16497
+ const p = await performer(c, a.artist);
16498
+ res = await short(c.call(
16499
+ "Library",
16500
+ "GetTrackExportInfoForPerformers",
16501
+ [{ type: "IEnumerable<PerformerBase>", name: "performers" }, cb],
16502
+ buildArgs([Arg.collection([buildArgs([Arg.ref(p.$ref)])])]),
16503
+ library(c)
16504
+ ), 3e4);
16505
+ } else throw new RoonError("Give an album key, an artist key or track keys", "invalid");
16506
+ if (!res?.success) throw new RoonError(`Roon refused the file list (${res?.status ?? "no answer"})`);
16507
+ if (res.payload.length < 2) return { tracks: [] };
16508
+ const r = new BinaryReader(Uint8Array.from(res.payload));
16509
+ r.integer();
16510
+ const n = r.flexInt();
16511
+ const graph = c.graph;
16512
+ const infos = [];
16513
+ for (let i = 0; i < n && r.remaining > 0; i++) infos.push(graph.readValue(r, 23));
16514
+ await untilLoaded(c, infos.map((x) => field2(x, "Track")).filter(isRef2), 3e3);
16515
+ const paden = /* @__PURE__ */ __name((x) => items(c, field2(x, "DuplicateTracks")).map((d) => field2(d, "FilePath")).filter((p) => typeof p === "string" && !!p), "paden");
16516
+ const tracks2 = infos.map((x) => {
16517
+ const t = obj(c, field2(x, "Track"));
16518
+ const row = { key: String(field2(t, "TrackId") ?? "") };
16519
+ const title = field2(t, "Title");
16520
+ if (title) row.title = title;
16521
+ const al = field2(obj(c, field2(t, "Album")), "Title");
16522
+ if (al) row.album = al;
16523
+ const n2 = field2(t, "TrackNumber");
16524
+ if (n2 != null) row.n = n2;
16525
+ const path2 = field2(x, "FilePath");
16526
+ if (typeof path2 === "string" && path2) row.path = path2;
16527
+ const format = field2(t, "Format");
16528
+ if (format) row.format = format;
16529
+ const dup = paden(x);
16530
+ if (dup.length) row.duplicates = dup;
16531
+ return row;
16532
+ });
16533
+ const gevraagd = a.tracks?.length ?? 0, ontbreekt = gevraagd ? gevraagd - tracks2.length : 0;
16534
+ const zonder = tracks2.filter((t) => !t.path).length + Math.max(0, ontbreekt);
16535
+ const of = gevraagd || tracks2.length;
16536
+ return { tracks: tracks2, ...zonder ? { note: `${zonder} of ${of} ${of === 1 ? "track" : "tracks"} ${zonder === 1 ? "has" : "have"} no file (streaming tracks, or not on this Core's storage)` } : {} };
16537
+ });
16538
+ }
16429
16539
  var SERVICE_NAME, SERVICE_TYPE, NONE2, SECTIONS, library, CREDIT_KIND, cut, choose;
16430
16540
  var init_library = __esm({
16431
16541
  "src/roon/library.ts"() {
@@ -16482,6 +16592,7 @@ var init_library = __esm({
16482
16592
  __name(performer, "performer");
16483
16593
  __name(bio, "bio");
16484
16594
  __name(discography, "discography");
16595
+ __name(trackFiles, "trackFiles");
16485
16596
  }
16486
16597
  });
16487
16598
 
@@ -50376,6 +50487,16 @@ function registerReadTools(server, internal = true) {
50376
50487
  inputSchema: { key: external_exports.string().describe("An album key."), credits: external_exports.boolean().optional() },
50377
50488
  annotations: READ
50378
50489
  }, ({ key, credits }) => run(() => album(key, credits === true)));
50490
+ reg("roon_track_files", {
50491
+ title: "File paths",
50492
+ description: "Where the user's own music files are: for an album (`album` key), an artist (`artist` key, all their tracks in the library) or a list of `tracks` keys, each track with its `key`, title, album, track number, format and `path` \u2014 the file as the Roon Core sees it (on the Core's storage), plus `duplicates` when Roon has the same track twice. The data behind Roon's own Export. Use it to link Roon's tracks to files, e.g. to join with data the user keeps per file. Streaming tracks (Qobuz, TIDAL) have no path.",
50493
+ inputSchema: {
50494
+ album: external_exports.string().optional().describe("An album key."),
50495
+ artist: external_exports.string().optional().describe("An artist key."),
50496
+ tracks: external_exports.array(external_exports.string()).max(500).optional().describe("Track keys.")
50497
+ },
50498
+ annotations: READ
50499
+ }, ({ album: album2, artist, tracks: tracks2 }) => run(() => trackFiles({ album: album2, artist, tracks: tracks2 })));
50379
50500
  reg("roon_review", {
50380
50501
  title: "Album review",
50381
50502
  description: "The review Roon shows on an album's page, in full, with its author \u2014 by album `key`. When the user asks for the review (\"what does Roon say about this album\", \"show me the review\"), they want to read the review itself: show the text complete and exactly as returned, as a quote with the author's name \u2014 no paraphrase or shortening unless they ask for a summary, and don't go to the web for it. `wikipedia: true` adds the album's Wikipedia text; it also comes by itself when Roon has no review of its own. `max_chars` only when a shorter excerpt is asked for.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deep-roon-mcp",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "An MCP server for Roon that reaches the parts the official API doesn't: reviews, biographies, Qobuz's and TIDAL's shelves, TIDAL's playlists, your history, search across your library and the streaming services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "René Bouwmeester <21277119+renebouwmeester@users.noreply.github.com>",