@withpica/mcp-server
Version:
MCP Server for withPICA — enables AI assistants to interact with your withPICA music catalog
58 lines • 3.03 kB
TypeScript
/**
* Shared WRAPPED_ARGS_MISSING envelope builder (D1 fix round 1, 2026-09-03).
*
* `pica_execute`'s dispatcher (`discovery.ts`, `buildExecuteTool`) has TWO
* guards that can reject a call with WRAPPED_ARGS_MISSING before dispatch:
* 1. the JSON-Schema `required` guard — a plain list of required fields.
* 2. the `requiredOneOf` guard — one-of-N alias groups that `required`
* can't express (`pica_works_inspect` and most other `*_inspect` /
* `pica_search` / bookings / licensing / shows / royalties tools,
* which accept `id` OR a domain-specific alias and so declare
* `required: []`).
*
* The first guard was fixed to name `unrecognised_fields` / `aliases_applied`
* and drop the "client-side transport loss" claim for a non-empty args
* object (36 wrong diagnoses since July — see arg-aliases.ts). The second
* guard was a near-identical copy of the ORIGINAL (pre-fix) envelope and was
* left saying "client-side strip … transport loss" with no
* `structuredContent` at all — which meant most `*_inspect` tools, the ones
* agents call constantly, still got the wrong diagnosis. Both guards now
* build their envelope through this one function so there is exactly one
* place that decides what WRAPPED_ARGS_MISSING says.
*
* Mode is inferred from `requiredOneOf`: pass it (non-empty) for the
* one-of-N guard, omit it (or pass an empty array) for the plain
* `required`-list guard. `args` must be the ALIASED args (post
* `applyArgAliases`) so `unrecognised_fields` and the empty-args check see
* what the caller actually sent, after this dispatch's own renames.
*/
export interface WrappedArgsMissingParams {
toolName: string;
/** The wrapped tool's JSON-Schema `required` list (possibly empty — a
* `requiredOneOf`-only tool declares `required: []`). */
required: string[];
/** Members of `required` absent from `args` (empty when firing on
* `requiredOneOf` alone). */
missingRequired: string[];
/** One-of-N alias groups (feedback 6d516171). Present + non-empty ⇒ the
* one-of-N guard is firing; the FIRST group with none of its members
* present in `args` is named in the message and example call shape. */
requiredOneOf?: string[][];
/** The resolved, ALIASED args pica_execute is about to reject. */
args: Record<string, unknown>;
/** Keys of the wrapped tool's `inputSchema.properties`. */
knownProps: string[];
/** Renames `applyArgAliases` made before this guard ran. */
aliasesApplied: Array<{
from: string;
to: string;
}>;
}
export interface WrappedArgsMissingEnvelope {
/** Pretty-printed JSON — the `content[0].text` body. */
text: string;
/** Same facts, machine-shaped — mirrored verbatim into `structuredContent`. */
structuredContent: Record<string, unknown>;
}
export declare function buildWrappedArgsMissingEnvelope(params: WrappedArgsMissingParams): WrappedArgsMissingEnvelope;
//# sourceMappingURL=wrapped-args-envelope.d.ts.map