/** * Defensive rewrite for nodes that look like `JSON.stringify(zodSchemaInstance)` * output rather than JSON Schema. MCP servers using Zod 4 sometimes ship a * serialised schema instance directly as a tool's `inputSchema`, because the * fields Zod surfaces on its instances (`type`, `enum`, `options`, `def`) shadow * (and clash with) JSON Schema keywords. The resulting payload is neither valid * Zod nor valid JSON Schema 2020-12 and Anthropic's strict validator rejects * the whole tool list. * * Symptoms we've observed (gitnexus_impact.direction): * { * def: { type: "enum", entries: { upstream: "upstream", ... } }, * type: "enum", // <- invalid `type` value * enum: { upstream: "upstream", ... }, // <- `enum` MUST be an array * options: ["upstream", "downstream"], * } * * This module recognises the shape (`def.type === node.type` and `def.type` is * a known Zod kind) and rewrites it to clean JSON Schema where deterministic. * For Zod kinds we don't fully model, we strip the toxic siblings (`def`, * `options`, object-shaped `enum`) and drop an invalid `type` so the remainder * passes meta-schema validation as a permissive node. * * Pure / identity-preserving: returns the input reference when nothing changes. */ /** * Walks a JSON value and rewrites every Zod-instance-shaped node into clean * JSON Schema 2020-12. Identity-preserving when no rewrite fires. Tolerates * self-referential graphs — a revisited node returns as-is. */ export declare function decontaminateZodInstance(value: unknown): unknown;