UNPKG

@withpica/mcp-server

Version:

MCP Server for withPICA — enables AI assistants to interact with your withPICA music catalog

92 lines • 4.62 kB
/** * Write tools that need the two-step confirmation token only for SOME calls. * * A destructive tool, or one with previewMode "two_step_token", is always * gated in ToolRegistry.execute. A tool listed here is gated only when its * check returns a preview; a null preview runs the call with no extra step. * The token is the same one (generateConfirmationToken / * validateAndConsumeToken), bound to the call's arguments AND to `bind`, so * if what the call would do changes between the two calls, the token stops * matching and the caller is asked again. * * pica_credits_update (founder rulings 2026-11-20): it replaces every * composition credit on a work, so a list that leaves a writer out removes * them. Confirm only when the list removes a writer or cuts someone's share * to 0% or unknown. * * pica_catalog_health_fix (H8, 8b's MCP safety tally 2026-11-20): confirm * when the call accepts a merge or delete (a destructive plan action). A * delegated agent is also held for the owner's approval by the REST route; * this token is the step for the organisation's own key. * * pica_works_bulk_copy_credits in `replace` mode (H5, 2026-11-20): each * target's writers become exactly the source's, so a target loses whoever * the source lacks. Confirm when any target would lose a writer, or a kept * writer's role or share would change. `skip` only fills songs with no * writers, and a target with no writers loses nothing, so neither asks. * * pica_works_update, pica_people_update, pica_agreements_update (8b's review, * "saving a list replaces it whole"): confirm when the call would drop a * stored mood tag, metadata key, contact detail, tag or agreed term. * pica_recordings_bulk_reassign_artist, pica_works_bulk_link_artist: confirm * when a record would lose the artist it has now, naming each. The checks * and why each field is in or out: list-replace-confirms.ts. */ import { type PicaClient } from "@withpica/mcp-sdk"; import type { ToolResult } from "./index.js"; export interface ConditionalPreview { /** The four fields every confirm preview has, plus the check's own detail. */ preview: { action: string; target: string; warning: string; display_name: string; [detail: string]: unknown; }; /** Folded into the token's argument hash. */ bind: string[]; } export type ConditionalCheck = { kind: "ok"; confirm: ConditionalPreview | null; } | { kind: "refuse"; result: ToolResult; }; export type Check = (pica: PicaClient, args: Record<string, unknown>) => Promise<ConditionalCheck>; /** * What the call would do that needs the user's yes (founder rulings * 2026-11-20), judged per person across their composition entries: * - a REMOVAL: a person with a composition credit now and no composition * entry in the new list. A role change keeps them on the song, so it is * not a removal. * - a SHARE CUT to 0% or unknown: a person whose composition shares now * total more than 0, and whose new entries carry no share above 0. Other * share changes don't ask; the song's history can undo them. * A call with no composition entries leaves the set alone (updateCredits * only calls /collaborators when there are some), so it is not checked. */ export declare const creditsUpdateCheck: Check; /** * Ask before a fix call merges or deletes. The token is bound to the call's * arguments (planToken, accept, selections) and to what each accepted * destructive action does, so a token for {A} cannot apply {A, B}, dropping * B asks again, and a merge that changed between the two calls asks again. * Fails closed: a plan that cannot be read, or one whose builders failed * while the call names ids the plan does not hold, is refused. */ export declare const catalogHealthFixCheck: Check; /** * What a `replace` copy would take from each target, judged per row keyed on * (person, role) — the key replace_work_collaborators diffs on: * - a REMOVAL: a person with writer rows on the target and none in the * source; * - a CHANGE: a kept person whose role or share differs. A role change is * a removal of the old (person, role) row plus an insert, so it counts. * Reads fail closed: without the rows we cannot say what would go. * A song with a locked split is skipped by the route, unchanged; PICA * can't see locks from here, so the preview says so instead of naming them. */ export declare const bulkCopyCreditsCheck: Check; export declare const CONDITIONAL_CONFIRMS: Readonly<Record<string, Check>>; //# sourceMappingURL=conditional-confirm.d.ts.map