mirror of
https://github.com/mvanhorn/cli-printing-press.git
synced 2026-09-14 15:38:08 +08:00
4a6d1fc0ac
* fix(cli): carry spec-declared query-param defaults into typed MCP bindings Typed MCP endpoint tools emitted mcpParamBinding literals without the query param's spec default:, so an agent omitting a defaulted param hit an upstream 4xx while the cobra flag (which carries the default) succeeded — CLI and MCP diverged for the same endpoint. Carry the default onto the binding (query params only) and apply it when the MCP arg is absent; an explicit value (incl. "") still overrides. Emission is gated on a new file-level hasMCPParamDefault flag so default-less CLIs stay byte-identical. Fixes #2679. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(generator): treat empty-string query default as no-default for MCP (#2689 review) endpointHasMCPParamDefault counted any param with p.Default != nil — including a spec default of "" — so it emitted the binding Default field + runtime fallback block. But emission ({{if .Default}}) and the runtime gate (binding.Default != "") both treat "" as absent, so the field/block were dead for an empty-only-default endpoint, and such a CLI was no longer byte-identical to a default-less one. Skipping an empty-string default on the wire is the PARITY-correct behavior, not a bug: the CLI sends a query param only `if flag != zeroValForParamRequired(...)`, which is `if flag != ""` for a string — so the cobra flag at its empty default is never put on the wire either. Applying the empty default in MCP would *break* CLI/MCP parity. Fix: add mcpParamDefaultValue(p) (effective iff the default stringifies non-empty) and use it in both endpointHasMCPParamDefault and mcpParamBindings so all three layers (count / emit / apply) agree. Non-empty defaults are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>