UNPKG

@withpica/mcp-server

Version:

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

64 lines • 2.4 kB
// Copyright (c) 2025-2026 Withpica Ltd. All rights reserved. /** Schema fragment every receipt-returning tool spreads into its properties. */ export const VERBOSE_PROPERTY = { verbose: { type: "boolean", description: "Return the full updated record and every open gap instead of the compact receipt (id, changed fields, new gaps only). Default false.", }, }; /** Split the receipt switch off the write payload so it never reaches the API. */ export function takeVerbose(args) { const { verbose, ...rest } = args; return { verbose: verbose === true, rest }; } /** * The hints in `after` whose gap was not already open in `before`. When the * before-state could not be read (`null`), every `after` hint counts as new — * PICA cannot claim a gap was already known if it never saw it. */ export function newHintsOnly(before, after) { if (before === null) return after; const seen = new Set(before.map((h) => h.gap)); return after.filter((h) => !seen.has(h.gap)); } /** * Each requested field with the value the API returned for it. A field the * returned record does not carry (e.g. one routed to a satellite table) is * listed in `unconfirmed` rather than echoed back as if it had been read. */ export function changedFields(requested, record) { const rec = record && typeof record === "object" ? record : {}; const changed = {}; const unconfirmed = []; for (const key of Object.keys(requested)) { if (key in rec) changed[key] = rec[key]; else unconfirmed.push(key); } return { changed, unconfirmed }; } /** * The integrity block trimmed to what an agent needs after a write: every * open gap as `{label, code, severity}` (a few bytes each, so a gap clearing * is still visible), the full detail only for gaps this write opened, and * the waived count. */ export function slimIntegrity(block, openBefore) { if (!block) return null; return { gaps: block.gaps.map((g) => ({ label: g.label, code: g.code, severity: g.severity, })), new_gaps: block.gaps.filter((g) => openBefore === null || !openBefore.has(g.code)), waived_count: block.waived_count, }; } export const RECEIPT_NOTE = "pass verbose: true for the full record"; //# sourceMappingURL=write-receipt.js.map