deep-roon-mcp 0.5.6 → 0.5.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 +18 -3
- package/dist/deep-roon-mcp.js +250 -9
- package/package.json +3 -2
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.5:
|
|
25
|
+
Version 0.5: sixty-one tools (fifty-five with a read-only library; sixty-five with playlist editing on). Qobuz, TIDAL or both — whatever is signed in on your Core.
|
|
26
26
|
|
|
27
27
|
**Reading** — changes nothing in Roon:
|
|
28
28
|
|
|
@@ -52,6 +52,7 @@ Version 0.5: fifty-nine tools (fifty-three with a read-only library). Qobuz, TID
|
|
|
52
52
|
| `roon_new_for_you` | New releases Roon picked for you |
|
|
53
53
|
| `roon_mixes` | Today's Daily Mixes |
|
|
54
54
|
| `roon_playlists`, `roon_playlist` | Your playlists, and one playlist's tracks |
|
|
55
|
+
| `roon_playlist_snapshot` | One of your playlists complete, with an id for every track in it (also a track that's in it twice) — what the playlist edits below work from |
|
|
55
56
|
| `roon_tidal_playlists` | TIDAL's playlists: its editorial shelves, by genre or mood, and your own TIDAL mixes |
|
|
56
57
|
| `roon_favorites` | Albums with a heart in Roon, or your Qobuz or TIDAL favourites |
|
|
57
58
|
| `roon_listen_later` | Your Listen Later list |
|
|
@@ -99,6 +100,19 @@ Version 0.5: fifty-nine tools (fifty-three with a read-only library). Qobuz, TID
|
|
|
99
100
|
| `roon_dsp_set` | MUSE on or off, one part on or off, or a preset |
|
|
100
101
|
| `roon_radio_favorite` | A station into My Live Radio, or out of it |
|
|
101
102
|
|
|
103
|
+
**Editing your own playlists** — experimental, and off until you switch on **Edit existing playlists** below
|
|
104
|
+
(`DEEP_ROON_PLAYLIST_EDIT=1`). Only your own Roon playlists; imported, smart, Qobuz and TIDAL playlists are refused. Each
|
|
105
|
+
edit starts from a fresh `roon_playlist_snapshot`, is checked once more right before it's written, and is read back in
|
|
106
|
+
full afterwards; if that read doesn't match, it says so and doesn't try again. With **Read-only library** on they aren't
|
|
107
|
+
there. Contributed by kvarnelis on GitHub.
|
|
108
|
+
|
|
109
|
+
| Tool | What it does |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `roon_playlist_add_tracks` | Tracks into a playlist, at the end or before a given track |
|
|
112
|
+
| `roon_playlist_remove_tracks` | Tracks out of a playlist — only the ones you point at, not other copies of the same track |
|
|
113
|
+
| `roon_playlist_reorder_tracks` | Tracks to another place in a playlist |
|
|
114
|
+
| `roon_playlist_rename` | A playlist under a new name (never onto a name another playlist already has) |
|
|
115
|
+
|
|
102
116
|
## Install
|
|
103
117
|
|
|
104
118
|
Deep Roon MCP runs on a computer on the same network as your Roon Core (Mac, Windows or Linux), next to your MCP client.
|
|
@@ -117,9 +131,10 @@ The settings (Claude Desktop › Settings › Extensions › Deep Roon MCP):
|
|
|
117
131
|
| Setting | What it does |
|
|
118
132
|
|---|---|
|
|
119
133
|
| Roon Core address | Empty: found on your network. Fill in the Core's address for another subnet or a private VPN (Tailscale) |
|
|
120
|
-
| Essentials only | Seventeen tools instead of
|
|
134
|
+
| Essentials only | Seventeen tools instead of sixty-one, for small models |
|
|
121
135
|
| Use Roon's internal protocol | Off: only the official API — zones, playback, volume, grouping; no search, reviews, Focus or history |
|
|
122
136
|
| Read-only library | On: Deep Roon never changes your library — no playlists, hearts, Listen Later, library additions or DSP. Playing still works |
|
|
137
|
+
| Edit existing playlists | Experimental, off by default. On: the four playlist edits above |
|
|
123
138
|
|
|
124
139
|
### Other clients
|
|
125
140
|
|
|
@@ -166,7 +181,7 @@ ChatGPT on the web can't run a server on your computer — use the desktop app.
|
|
|
166
181
|
|
|
167
182
|
The same settings as environment variables: `ROON_HOST` (the Core's address, empty = find it), `DEEP_ROON_TOOLS=essentials`,
|
|
168
183
|
`DEEP_ROON_INTERNAL=off`, `DEEP_ROON_READ_ONLY=library` (nothing changes the library; playing works) or `DEEP_ROON_READ_ONLY=all`
|
|
169
|
-
(Deep Roon only looks: no playing, queueing or zone changes either). Leave out what you don't need. VS Code calls the block `"servers"` instead of `"mcpServers"`.
|
|
184
|
+
(Deep Roon only looks: no playing, queueing or zone changes either), `DEEP_ROON_PLAYLIST_EDIT=1` (the playlist edits). Leave out what you don't need. VS Code calls the block `"servers"` instead of `"mcpServers"`.
|
|
170
185
|
|
|
171
186
|
Then, once, in Roon: Settings › Extensions › **Enable** next to "Deep Roon MCP". Until then the tools say so.
|
|
172
187
|
|
package/dist/deep-roon-mcp.js
CHANGED
|
@@ -5407,8 +5407,8 @@ var require_multipleOf = __commonJS({
|
|
|
5407
5407
|
const { gen, data, schemaCode, it } = cxt;
|
|
5408
5408
|
const prec = it.opts.multipleOfPrecision;
|
|
5409
5409
|
const res = gen.let("res");
|
|
5410
|
-
const
|
|
5411
|
-
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${
|
|
5410
|
+
const invalid2 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
|
|
5411
|
+
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid2}))`);
|
|
5412
5412
|
}
|
|
5413
5413
|
};
|
|
5414
5414
|
exports2.default = def;
|
|
@@ -12292,7 +12292,7 @@ var require_websocket = __commonJS({
|
|
|
12292
12292
|
var http2 = require("http");
|
|
12293
12293
|
var net3 = require("net");
|
|
12294
12294
|
var tls = require("tls");
|
|
12295
|
-
var { randomBytes: randomBytes2, createHash } = require("crypto");
|
|
12295
|
+
var { randomBytes: randomBytes2, createHash: createHash2 } = require("crypto");
|
|
12296
12296
|
var { Duplex, Readable: Readable2 } = require("stream");
|
|
12297
12297
|
var { URL: URL2 } = require("url");
|
|
12298
12298
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -12976,7 +12976,7 @@ var require_websocket = __commonJS({
|
|
|
12976
12976
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
12977
12977
|
return;
|
|
12978
12978
|
}
|
|
12979
|
-
const digest =
|
|
12979
|
+
const digest = createHash2("sha1").update(key + GUID).digest("base64");
|
|
12980
12980
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
12981
12981
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
12982
12982
|
return;
|
|
@@ -13370,7 +13370,7 @@ var require_websocket_server = __commonJS({
|
|
|
13370
13370
|
var EventEmitter = require("events");
|
|
13371
13371
|
var http2 = require("http");
|
|
13372
13372
|
var { Duplex } = require("stream");
|
|
13373
|
-
var { createHash } = require("crypto");
|
|
13373
|
+
var { createHash: createHash2 } = require("crypto");
|
|
13374
13374
|
var extension2 = require_extension();
|
|
13375
13375
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
13376
13376
|
var subprotocol2 = require_subprotocol();
|
|
@@ -13680,7 +13680,7 @@ var require_websocket_server = __commonJS({
|
|
|
13680
13680
|
);
|
|
13681
13681
|
}
|
|
13682
13682
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
13683
|
-
const digest =
|
|
13683
|
+
const digest = createHash2("sha1").update(key + GUID).digest("base64");
|
|
13684
13684
|
const headers = [
|
|
13685
13685
|
"HTTP/1.1 101 Switching Protocols",
|
|
13686
13686
|
"Upgrade: websocket",
|
|
@@ -15457,7 +15457,7 @@ var require_lib2 = __commonJS({
|
|
|
15457
15457
|
var version2;
|
|
15458
15458
|
var init_package = __esm({
|
|
15459
15459
|
"package.json"() {
|
|
15460
|
-
version2 = "0.5.
|
|
15460
|
+
version2 = "0.5.7";
|
|
15461
15461
|
}
|
|
15462
15462
|
});
|
|
15463
15463
|
|
|
@@ -51602,6 +51602,246 @@ async function dspSet(zoneName, s) {
|
|
|
51602
51602
|
}
|
|
51603
51603
|
__name(dspSet, "dspSet");
|
|
51604
51604
|
|
|
51605
|
+
// src/roon/playlist-edit.ts
|
|
51606
|
+
var import_node_crypto = require("node:crypto");
|
|
51607
|
+
init_intern();
|
|
51608
|
+
init_serializer();
|
|
51609
|
+
init_signature();
|
|
51610
|
+
init_session();
|
|
51611
|
+
init_graph();
|
|
51612
|
+
init_library();
|
|
51613
|
+
function writablePlaylist(c, p) {
|
|
51614
|
+
const ro = field2(p, "IsReadOnly");
|
|
51615
|
+
const declaredBool = c.graph.types.get(p.typeId)?.members.some((m) => m.name.endsWith("::IsReadOnly") && m.propType === 2) === true;
|
|
51616
|
+
return field2(p, "Type") === 5 && (ro === false || ro === void 0 && declaredBool);
|
|
51617
|
+
}
|
|
51618
|
+
__name(writablePlaylist, "writablePlaylist");
|
|
51619
|
+
var invalid = /* @__PURE__ */ __name((s) => {
|
|
51620
|
+
throw new RoonError(s, "invalid");
|
|
51621
|
+
}, "invalid");
|
|
51622
|
+
var trackKeyValid = /* @__PURE__ */ __name((key) => /^(0|[1-9]\d{0,19})$/.test(key) && BigInt(key) <= 0xffffffffffffffffn, "trackKeyValid");
|
|
51623
|
+
var stable = /* @__PURE__ */ __name((v) => Buffer.isBuffer(v) ? v.toString("hex") : typeof v === "bigint" ? v.toString() : typeof v === "string" ? v : "", "stable");
|
|
51624
|
+
function revisionOf(key, name, entries) {
|
|
51625
|
+
return (0, import_node_crypto.createHash)("sha256").update(JSON.stringify([key, name, entries.map((e) => [e.id, e.key])])).digest("hex");
|
|
51626
|
+
}
|
|
51627
|
+
__name(revisionOf, "revisionOf");
|
|
51628
|
+
var playlistEditOn = /* @__PURE__ */ __name(() => ["1", "true", "on", "yes"].includes((process.env.DEEP_ROON_PLAYLIST_EDIT ?? "").trim().toLowerCase()), "playlistEditOn");
|
|
51629
|
+
function enabled() {
|
|
51630
|
+
const ro = (process.env.DEEP_ROON_READ_ONLY ?? "").trim().toLowerCase();
|
|
51631
|
+
if (ro && !["off", "0", "false", "no"].includes(ro)) invalid("Playlist editing is disabled by DEEP_ROON_READ_ONLY.");
|
|
51632
|
+
if (!playlistEditOn()) invalid("Playlist editing is experimental and disabled; see docs/playlist-editing.md.");
|
|
51633
|
+
}
|
|
51634
|
+
__name(enabled, "enabled");
|
|
51635
|
+
async function snapshotOn(c, key, timeoutMs = 3e3) {
|
|
51636
|
+
if (!/^(?:[0-9a-f]{2})+$/i.test(key)) invalid("Use the exact playlist key from roon_playlists.");
|
|
51637
|
+
const service2 = c.graph.findByType("Playlists")[0];
|
|
51638
|
+
if (!service2) throw new RoonError("No playlists service", "unavailable");
|
|
51639
|
+
const got = await c.call("Playlists", "GetPlaylist", [{ type: "Sooid", name: "id" }, { type: "ResultCallback<Playlist>", name: "cb" }], buildArgs([Arg.sooid(Buffer.from(key, "hex"))]), service2.oid);
|
|
51640
|
+
if (!got.success) throw new RoonError(`Cannot read playlist (${got.status})`);
|
|
51641
|
+
const ref = c.graph.decodeReturnValue(Uint8Array.from(got.payload));
|
|
51642
|
+
if (!isRef2(ref)) throw new RoonError("Playlist read returned no object");
|
|
51643
|
+
const end = Date.now() + timeoutMs;
|
|
51644
|
+
let p;
|
|
51645
|
+
for (; ; ) {
|
|
51646
|
+
p = obj(c, ref);
|
|
51647
|
+
if (p && field2(p, "Name") !== void 0 && playlistKey(p).toLowerCase() === key.toLowerCase()) break;
|
|
51648
|
+
if (Date.now() >= end) break;
|
|
51649
|
+
await wait(40);
|
|
51650
|
+
}
|
|
51651
|
+
if (!p || playlistKey(p).toLowerCase() !== key.toLowerCase() || typeof field2(p, "Name") !== "string") throw new RoonError("Incomplete playlist identity");
|
|
51652
|
+
const result = await c.call("Playlist", "GetItems", [{ type: "ResultCallback<Query<PlaylistItem>>", name: "cb" }], Buffer.alloc(0), p.oid);
|
|
51653
|
+
if (!result.success) throw new RoonError(`Cannot read playlist items (${result.status})`);
|
|
51654
|
+
const query = c.graph.decodeReturnValue(Uint8Array.from(result.payload));
|
|
51655
|
+
for (; ; ) {
|
|
51656
|
+
const q = obj(c, query);
|
|
51657
|
+
const f = q?.fields;
|
|
51658
|
+
if (f && Number.isInteger(f.$count) && f.$count >= 0 && Array.isArray(f.$items) && f.$items.length === f.$count) {
|
|
51659
|
+
const entries = [];
|
|
51660
|
+
for (const ref2 of f.$items) {
|
|
51661
|
+
const item = obj(c, ref2);
|
|
51662
|
+
const track = obj(c, field2(item, "Track"));
|
|
51663
|
+
const id = stable(field2(item, "PlaylistItemId"));
|
|
51664
|
+
const trackKey = stable(field2(track, "TrackId"));
|
|
51665
|
+
if (!item || typeof item.oid !== "bigint" || !id || !trackKeyValid(trackKey)) break;
|
|
51666
|
+
entries.push({ id, key: trackKey, oid: item.oid });
|
|
51667
|
+
}
|
|
51668
|
+
const count = field2(p, "ItemCount");
|
|
51669
|
+
if (entries.length === f.$count && count === entries.length && new Set(entries.map((e) => e.id)).size === entries.length) {
|
|
51670
|
+
const name = field2(p, "Name");
|
|
51671
|
+
const canonicalKey2 = playlistKey(p);
|
|
51672
|
+
return {
|
|
51673
|
+
key: canonicalKey2,
|
|
51674
|
+
name,
|
|
51675
|
+
entries,
|
|
51676
|
+
oid: p.oid,
|
|
51677
|
+
service: service2.oid,
|
|
51678
|
+
writable: writablePlaylist(c, p),
|
|
51679
|
+
revision: revisionOf(canonicalKey2, name, entries)
|
|
51680
|
+
};
|
|
51681
|
+
}
|
|
51682
|
+
}
|
|
51683
|
+
if (Date.now() >= end) break;
|
|
51684
|
+
await wait(40);
|
|
51685
|
+
}
|
|
51686
|
+
throw new RoonError("Playlist membership is incomplete; no edit was attempted.");
|
|
51687
|
+
}
|
|
51688
|
+
__name(snapshotOn, "snapshotOn");
|
|
51689
|
+
var publicSnapshot = /* @__PURE__ */ __name((s) => ({
|
|
51690
|
+
key: s.key,
|
|
51691
|
+
name: s.name,
|
|
51692
|
+
revision: s.revision,
|
|
51693
|
+
writable: s.writable,
|
|
51694
|
+
total: s.entries.length,
|
|
51695
|
+
items: s.entries.map(({ id, key }, i) => ({ n: i + 1, id, key }))
|
|
51696
|
+
}), "publicSnapshot");
|
|
51697
|
+
var playlistSnapshot = /* @__PURE__ */ __name((key) => withCore(async (c) => publicSnapshot(await snapshotOn(c, key))), "playlistSnapshot");
|
|
51698
|
+
function planEdit(s, edit) {
|
|
51699
|
+
if (edit.confirm !== true) invalid("Explicit confirmation is required.");
|
|
51700
|
+
if (!s.writable) invalid("Only writable native Roon playlists can be edited.");
|
|
51701
|
+
if (s.key !== edit.key || s.revision !== edit.revision) invalid("Playlist changed since the snapshot; read a fresh snapshot and review the edit.");
|
|
51702
|
+
let name = s.name;
|
|
51703
|
+
let entries = s.entries.slice();
|
|
51704
|
+
let selected = [];
|
|
51705
|
+
if (edit.action === "rename") {
|
|
51706
|
+
if (!edit.name.trim() || edit.name.length > 500) invalid("Choose a nonempty name of at most 500 characters.");
|
|
51707
|
+
name = edit.name;
|
|
51708
|
+
} else if (edit.action === "add") {
|
|
51709
|
+
if (!edit.keys.length || edit.keys.length > 200 || edit.keys.some((k) => !trackKeyValid(k))) invalid("Provide 1\u2013200 valid track keys.");
|
|
51710
|
+
const at2 = edit.before === void 0 ? entries.length : entries.findIndex((e) => e.id === edit.before);
|
|
51711
|
+
if (at2 < 0) invalid("Insertion anchor is no longer in the playlist.");
|
|
51712
|
+
entries.splice(at2, 0, ...edit.keys.map((key) => ({ id: "", key })));
|
|
51713
|
+
} else {
|
|
51714
|
+
if (!edit.items.length || edit.items.length > 200 || new Set(edit.items).size !== edit.items.length) invalid("Provide 1\u2013200 distinct playlist item ids.");
|
|
51715
|
+
selected = s.entries.filter((e) => edit.items.includes(e.id));
|
|
51716
|
+
if (selected.length !== edit.items.length) invalid("A selected item is no longer in the playlist.");
|
|
51717
|
+
entries = entries.filter((e) => !edit.items.includes(e.id));
|
|
51718
|
+
if (edit.action === "reorder") {
|
|
51719
|
+
if (edit.before !== void 0 && edit.items.includes(edit.before)) invalid("The anchor cannot be one of the moved items.");
|
|
51720
|
+
const at2 = edit.before === void 0 ? entries.length : entries.findIndex((e) => e.id === edit.before);
|
|
51721
|
+
if (at2 < 0) invalid("Move anchor is no longer in the playlist.");
|
|
51722
|
+
entries.splice(at2, 0, ...selected);
|
|
51723
|
+
}
|
|
51724
|
+
}
|
|
51725
|
+
const anchor2 = "before" in edit && edit.before !== void 0 ? s.entries.find((e) => e.id === edit.before) : void 0;
|
|
51726
|
+
const noop = name === s.name && JSON.stringify(entries.map((e) => [e.id, e.key])) === JSON.stringify(s.entries.map((e) => [e.id, e.key]));
|
|
51727
|
+
return { name, entries, selected, anchor: anchor2, noop };
|
|
51728
|
+
}
|
|
51729
|
+
__name(planEdit, "planEdit");
|
|
51730
|
+
function matchesPlan(after, before, plan) {
|
|
51731
|
+
if (after.key !== before.key || after.name !== plan.name || after.entries.length !== plan.entries.length) return false;
|
|
51732
|
+
const oldIds = new Set(before.entries.map((e) => e.id));
|
|
51733
|
+
return after.entries.every((e, i) => e.key === plan.entries[i].key && (plan.entries[i].id ? e.id === plan.entries[i].id : !oldIds.has(e.id)));
|
|
51734
|
+
}
|
|
51735
|
+
__name(matchesPlan, "matchesPlan");
|
|
51736
|
+
async function executeEdit(io, edit, attempts = 12) {
|
|
51737
|
+
const before = await io.read();
|
|
51738
|
+
const plan = planEdit(before, edit);
|
|
51739
|
+
if (plan.noop) return { ok: true, verified: true, unchanged: true, ...publicSnapshot(before) };
|
|
51740
|
+
if (edit.action === "add") await io.validateTracks(edit.keys);
|
|
51741
|
+
if (edit.action === "rename" && io.nameTaken && await io.nameTaken(plan.name, before.key)) invalid(`Another playlist is already called "${plan.name}"; choose another name.`);
|
|
51742
|
+
const checked = await io.read();
|
|
51743
|
+
if (checked.revision !== before.revision || !checked.writable) invalid("Playlist changed before the write; read a fresh snapshot.");
|
|
51744
|
+
const finalPlan = planEdit(checked, edit);
|
|
51745
|
+
let uncertain;
|
|
51746
|
+
try {
|
|
51747
|
+
await io.write(checked, finalPlan, edit);
|
|
51748
|
+
} catch (e) {
|
|
51749
|
+
uncertain = e;
|
|
51750
|
+
}
|
|
51751
|
+
let after;
|
|
51752
|
+
for (let i = 0; i < attempts; i++) {
|
|
51753
|
+
try {
|
|
51754
|
+
after = await io.read();
|
|
51755
|
+
if (matchesPlan(after, checked, finalPlan)) return {
|
|
51756
|
+
ok: true,
|
|
51757
|
+
verified: true,
|
|
51758
|
+
...publicSnapshot(after),
|
|
51759
|
+
note: uncertain ? "The write response was uncertain; a fresh read verified the exact requested result." : void 0
|
|
51760
|
+
};
|
|
51761
|
+
} catch {
|
|
51762
|
+
}
|
|
51763
|
+
if (i + 1 < attempts) await io.pause();
|
|
51764
|
+
}
|
|
51765
|
+
return {
|
|
51766
|
+
ok: false,
|
|
51767
|
+
verified: false,
|
|
51768
|
+
outcome: "uncertain",
|
|
51769
|
+
key: edit.key,
|
|
51770
|
+
note: "The requested result could not be verified. Do not retry automatically. Read a fresh snapshot and inspect Roon before another edit.",
|
|
51771
|
+
observed: after ? publicSnapshot(after) : void 0
|
|
51772
|
+
};
|
|
51773
|
+
}
|
|
51774
|
+
__name(executeEdit, "executeEdit");
|
|
51775
|
+
async function writeOn(c, s, p, edit) {
|
|
51776
|
+
const selected = Arg.collection(p.selected.map((e) => buildArgs([Arg.ref(e.oid)])));
|
|
51777
|
+
const at2 = [Arg.enum_(p.anchor ? 3 : 1), Arg.ref(p.anchor?.oid ?? 0n)];
|
|
51778
|
+
const playlist2 = { type: "Playlist", name: "playlist" };
|
|
51779
|
+
const collection = { type: "IEnumerable<PlaylistItem>", name: "items" };
|
|
51780
|
+
const where = [{ type: "InsertionPoint", name: "insertionpoint" }, { type: "PlaylistItem", name: "relative_to_item" }];
|
|
51781
|
+
if (edit.action === "remove") {
|
|
51782
|
+
c.remoting.callMethodNoReply(s.service, formatMethodSignature("Playlists", "RemoveItems", [playlist2, collection]), buildArgs([Arg.ref(s.oid), selected]));
|
|
51783
|
+
return;
|
|
51784
|
+
}
|
|
51785
|
+
const method = edit.action === "add" ? "InsertMedia" : edit.action === "reorder" ? "MoveItems" : "Rename";
|
|
51786
|
+
const params = edit.action === "add" ? [playlist2, { type: "IEnumerable<long>", name: "mediaids" }, ...where, { type: "ResultCallback<PlaylistInsertionResult>", name: "cb" }] : edit.action === "reorder" ? [playlist2, collection, ...where, { type: "ResultCallback", name: "cb" }] : [playlist2, { type: "string", name: "name" }, { type: "bool", name: "overwrite_on_duplicate_name" }, { type: "ResultCallback", name: "cb" }];
|
|
51787
|
+
const args = edit.action === "add" ? [Arg.ref(s.oid), Arg.collection(edit.keys.map((k) => buildArgs([Arg.long(BigInt(k))]))), ...at2] : edit.action === "reorder" ? [Arg.ref(s.oid), selected, ...at2] : [Arg.ref(s.oid), Arg.str(edit.name), Arg.bool(false)];
|
|
51788
|
+
const result = await c.call("Playlists", method, params, buildArgs(args), s.service);
|
|
51789
|
+
if (!result.success) throw new RoonError(`Roon refused playlist edit (${result.status}); checking the saved result.`);
|
|
51790
|
+
}
|
|
51791
|
+
__name(writeOn, "writeOn");
|
|
51792
|
+
var playlistEdit = /* @__PURE__ */ __name((edit) => {
|
|
51793
|
+
enabled();
|
|
51794
|
+
return withCore((c) => executeEdit({
|
|
51795
|
+
read: /* @__PURE__ */ __name(() => snapshotOn(c, edit.key), "read"),
|
|
51796
|
+
validateTracks: /* @__PURE__ */ __name((keys) => findTracks(c, keys), "validateTracks"),
|
|
51797
|
+
write: /* @__PURE__ */ __name((s, p, e) => writeOn(c, s, p, e), "write"),
|
|
51798
|
+
pause: /* @__PURE__ */ __name(() => wait(150), "pause"),
|
|
51799
|
+
nameTaken: /* @__PURE__ */ __name(async (name, key) => allPlaylists(c).list.some((p) => playlistKey(p).toLowerCase() !== key.toLowerCase() && String(field2(p, "Name") ?? "").trim().toLowerCase() === name.trim().toLowerCase()), "nameTaken")
|
|
51800
|
+
}, edit));
|
|
51801
|
+
}, "playlistEdit");
|
|
51802
|
+
|
|
51803
|
+
// src/tools/playlist-edit.ts
|
|
51804
|
+
var PLAYLIST_WRITES = ["roon_playlist_add_tracks", "roon_playlist_remove_tracks", "roon_playlist_reorder_tracks", "roon_playlist_rename"];
|
|
51805
|
+
function registerPlaylistEditTools(server) {
|
|
51806
|
+
server.registerTool("roon_playlist_snapshot", {
|
|
51807
|
+
title: "Complete playlist snapshot",
|
|
51808
|
+
description: "Read a complete playlist by exact key from roon_playlists. Returns a revision and an id for each track occurrence, including duplicates. Use these for edits; display row numbers and track keys do not identify occurrences.",
|
|
51809
|
+
inputSchema: { key: external_exports.string().min(1) },
|
|
51810
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
51811
|
+
}, ({ key }) => run(() => playlistSnapshot(key)));
|
|
51812
|
+
if (!playlistEditOn()) return;
|
|
51813
|
+
const common = { key: external_exports.string().min(1), revision: external_exports.string().regex(/^[a-f0-9]{64}$/), confirm: external_exports.literal(true) };
|
|
51814
|
+
const items2 = external_exports.array(external_exports.string().min(1)).min(1).max(200);
|
|
51815
|
+
const before = external_exports.string().min(1).optional().describe("Insert before this occurrence id; omit to place at the end.");
|
|
51816
|
+
const annotations = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
|
|
51817
|
+
const safety = " Experimental: only on an explicit user request. Requires a fresh roon_playlist_snapshot revision and confirm:true. Native writable Roon playlists only. Verifies the entire saved result. If uncertain, inspect Roon and read a fresh snapshot; never retry automatically.";
|
|
51818
|
+
server.registerTool("roon_playlist_add_tracks", {
|
|
51819
|
+
title: "Add playlist tracks",
|
|
51820
|
+
description: "Add track keys in the given order, retaining duplicates." + safety,
|
|
51821
|
+
inputSchema: { ...common, keys: external_exports.array(external_exports.string().regex(/^-?\d+$/)).min(1).max(200), before },
|
|
51822
|
+
annotations
|
|
51823
|
+
}, (args) => run(() => playlistEdit({ ...args, action: "add" })));
|
|
51824
|
+
server.registerTool("roon_playlist_remove_tracks", {
|
|
51825
|
+
title: "Remove playlist occurrences",
|
|
51826
|
+
description: "Remove only the selected occurrence ids. Other copies of the same track remain." + safety,
|
|
51827
|
+
inputSchema: { ...common, items: items2 },
|
|
51828
|
+
annotations
|
|
51829
|
+
}, (args) => run(() => playlistEdit({ ...args, action: "remove" })));
|
|
51830
|
+
server.registerTool("roon_playlist_reorder_tracks", {
|
|
51831
|
+
title: "Move playlist occurrences",
|
|
51832
|
+
description: "Move selected occurrence ids before an anchor or to the end, preserving their original relative order." + safety,
|
|
51833
|
+
inputSchema: { ...common, items: items2, before },
|
|
51834
|
+
annotations
|
|
51835
|
+
}, (args) => run(() => playlistEdit({ ...args, action: "reorder" })));
|
|
51836
|
+
server.registerTool("roon_playlist_rename", {
|
|
51837
|
+
title: "Rename a playlist",
|
|
51838
|
+
description: "Rename without overwriting another playlist with the same name." + safety,
|
|
51839
|
+
inputSchema: { ...common, name: external_exports.string().min(1).max(500) },
|
|
51840
|
+
annotations
|
|
51841
|
+
}, (args) => run(() => playlistEdit({ ...args, action: "rename" })));
|
|
51842
|
+
}
|
|
51843
|
+
__name(registerPlaylistEditTools, "registerPlaylistEditTools");
|
|
51844
|
+
|
|
51605
51845
|
// src/tools/library.ts
|
|
51606
51846
|
var READ2 = { readOnlyHint: true, openWorldHint: false };
|
|
51607
51847
|
var PLAYS2 = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
|
|
@@ -51745,6 +51985,7 @@ function registerLibraryTools(server) {
|
|
|
51745
51985
|
inputSchema: { key: external_exports.string(), zone: zone2, mode: mode2 },
|
|
51746
51986
|
annotations: PLAYS2
|
|
51747
51987
|
}, ({ key, zone: zn, mode: m }) => run(() => playMix(key, zn, m ?? "now")));
|
|
51988
|
+
registerPlaylistEditTools(server);
|
|
51748
51989
|
server.registerTool("roon_playlists", {
|
|
51749
51990
|
title: "Playlists",
|
|
51750
51991
|
description: "The playlists in the user's Roon: their own Roon playlists, Qobuz and TIDAL playlists they added, and editorial ones \u2014 each with a `key` for roon_playlist and roon_play_playlist, the number of tracks, and whether it is read-only.",
|
|
@@ -51846,7 +52087,7 @@ function registerLibraryTools(server) {
|
|
|
51846
52087
|
description: "Switch MUSE (Roon's DSP) on a zone: `enabled` turns the whole DSP on or off; `part` + `enabled` turns one part on or off (names from roon_dsp); `preset` loads a saved preset by name. This changes how the zone SOUNDS: only on an explicit request, one change at a time, after reading roon_dsp. It doesn't edit EQ bands or other values. Reads it back.",
|
|
51847
52088
|
inputSchema: { zone: zone2, enabled: external_exports.boolean().optional(), part: external_exports.string().optional(), preset: external_exports.string().optional() },
|
|
51848
52089
|
annotations: CHANGES
|
|
51849
|
-
}, ({ zone: zn, enabled, part, preset }) => run(() => dspSet(zn, { enabled, part, preset })));
|
|
52090
|
+
}, ({ zone: zn, enabled: enabled2, part, preset }) => run(() => dspSet(zn, { enabled: enabled2, part, preset })));
|
|
51850
52091
|
}
|
|
51851
52092
|
__name(registerLibraryTools, "registerLibraryTools");
|
|
51852
52093
|
|
|
@@ -51964,7 +52205,7 @@ var INSTRUCTIONS = `Deep Roon MCP connects to the user's own Roon Core (music pl
|
|
|
51964
52205
|
- What plays changes all the time: read roon_now_playing afresh before describing it.
|
|
51965
52206
|
- "Daily Mixes" are Roon's own (roon_mixes); the user's TIDAL mixes (My Mix 1 \u2026, My Daily Discovery) are roon_tidal_playlists with shelf my_mixes, and their tracks can be read with roon_playlist.
|
|
51966
52207
|
- Unofficial: this uses Roon's internal protocol, which a Roon update can change; if a tool says so, tell the user to check for an update.`;
|
|
51967
|
-
var LIBRARY_WRITES = /* @__PURE__ */ new Set(["roon_playlist_create", "roon_favorite", "roon_radio_favorite", "roon_listen_later_set", "roon_library_add", "roon_dsp_set"]);
|
|
52208
|
+
var LIBRARY_WRITES = /* @__PURE__ */ new Set([...PLAYLIST_WRITES, "roon_playlist_create", "roon_favorite", "roon_radio_favorite", "roon_listen_later_set", "roon_library_add", "roon_dsp_set"]);
|
|
51968
52209
|
var PLAYBACK = /* @__PURE__ */ new Set([
|
|
51969
52210
|
"roon_play",
|
|
51970
52211
|
"roon_play_tracks",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deep-roon-mcp",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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>",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"build": "node scripts/build.mjs",
|
|
38
38
|
"start": "node dist/deep-roon-mcp.js",
|
|
39
39
|
"bundle": "node scripts/bundle.mjs",
|
|
40
|
-
"prepublishOnly": "node scripts/build.mjs"
|
|
40
|
+
"prepublishOnly": "node scripts/build.mjs",
|
|
41
|
+
"test": "node scripts/test.mjs"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@anthropic-ai/mcpb": "^2.1.2",
|