@withpica/mcp-server
Version:
MCP Server for withPICA — enables AI assistants to interact with your withPICA music catalog
120 lines • 6.34 kB
JavaScript
// Copyright (c) 2025-2026 Withpica Ltd. All rights reserved.
/**
* Register-Set MCP Tool — ADR-259 (DAW capture thread)
*
* One tool, `pica_register_set`, that registers a captured DAW set in a single
* round-trip: it creates a work, a linked master recording, and a 100% master
* split with no holder (person_id null) server-side via POST /api/admin/register-set. It replaces the
* five sequential calls the Ableton extension used to make (works_query →
* works_create → recordings_create → splits_list → splits_create).
*
* Duplicate handling: the server's own work-dedup gate (title+artist) is the
* backstop. On a duplicate the route returns 409 + existing_work_id, surfaced
* to the caller as an error — the client then offers add-version / complete.
*
* Org-scoping + the duplicate gate are enforced at the HTTP route layer.
* Pricing: FREE (ADR-162 deprecates credit gating as a user-facing concept).
*/
import { linkTo } from "./view-url-results.js";
import { formatSuccess } from "@withpica/mcp-utils";
import { WORK_TYPE_VALUES } from "./catalog-enums.js";
export class RegisterTools {
pica;
constructor(pica) {
this.pica = pica;
}
getTools() {
return [
{
definition: {
name: "pica_register_set",
scope: "write:catalog",
audiences: ["stdio", "http", "public"],
tier: "write",
description: "Use when the user asks: 'register this set', 'register my Ableton session', " +
"'save this track as a work', 'register what I just made'. Registers a captured " +
"studio/DAW session in one step — creates a work, a linked master recording, and a " +
"100% master ownership share with no owner set (the user chooses the owner on the " +
"recording page), in a single call (the one-call equivalent of " +
"pica_works_create + pica_recordings_create + pica_recording_splits_create). " +
"title is the work + recording title; artist_name is the master's display artist " +
"(pass primary_artist_id when you already resolved the person). work_type defaults " +
"to 'song'. If a work with the same title + artist already exists the call fails " +
"with the existing work id, so you can add a version or complete it instead.",
workflows: "infrastructure",
vernacular_kind: "creator-entry",
inputSchema: {
type: "object",
properties: {
title: {
type: "string",
description: "Title of the work and its master recording.",
},
artist_name: {
type: "string",
description: "Display artist for the master recording (free text; the server resolves it to a person when unambiguous).",
},
work_type: {
type: "string",
enum: [...WORK_TYPE_VALUES],
description: "Work type. Defaults to 'song'.",
},
key: {
type: "string",
description: "Optional musical key snapshot (e.g. 'A minor').",
},
notes: {
type: "string",
description: "Optional freetext notes captured with the work.",
},
metadata: {
type: "object",
description: "Optional captured session snapshot stored on the work (e.g. tempo, plugin list).",
},
primary_artist_id: {
type: "string",
description: "Optional UUID of the resolved primary artist person, when known.",
},
},
required: ["title", "artist_name"],
},
annotations: {
title: "register a captured set",
destructiveHint: false,
idempotentHint: false,
},
},
executor: this.set.bind(this),
},
];
}
async set(args) {
const data = await this.pica.register.set({
title: args.title,
artist_name: args.artist_name,
work_type: args.work_type,
key: args.key,
notes: args.notes,
metadata: args.metadata,
primary_artist_id: args.primary_artist_id,
});
let line;
if (data.template_application === "applied") {
line = ` Your registration template was applied (definition of done met).`;
}
else if (data.template_application === "partial") {
line = ` ⚠️ Your registration template was only PARTIALLY applied — ${(data.unmet_reasons ?? []).join("; ")}. Fix in /inspect before treating this as done.`;
}
else {
line =
data.master_ownership === "created"
? // The share has no holder: recording_splits can only name a
// person, so the recording page shows its owner as "unknown"
// until the user picks one (founder's Ableton smoke, 2026-11-23).
" Who owns the master isn't set yet: choose the owner on the recording page."
: " (master ownership write was skipped — set it in /inspect.)";
}
return linkTo(formatSuccess(`Registered "${args.title}" — work + master recording created.${line}`, data), { entity: { kind: "work", id: data.work_id } });
}
}
//# sourceMappingURL=register.js.map