fix: map multi-valued Click params to MCP array schemas#37
fix: map multi-valued Click params to MCP array schemas#37Coding-Dev-Tools wants to merge 1 commit into
Conversation
…dapter The adapter advertised multiple=True options, variadic (nargs=-1) arguments, and fixed-tuple (nargs>1) options as a single scalar string, and the handler stringified their list/tuple value into one garbage CLI argument (e.g. --tag "['a', 'b']"), so any LLM calling such a tool passed broken args. - Map multi-valued params to JSON Schema arrays whose items carry the element type; pin length (minItems/maxItems) for fixed nargs>1 tuples. - Expand list/tuple values in the handler: repeat the flag per value for multiple=True, emit one flag + N values for nargs>1, and one arg per element for variadic positionals. Scalar behavior is unchanged. - Add tests/test_multi_valued_params.py (10 cases) covering schema shape and invocation for all three multi-valued forms plus scalar back-compat. ruff check + format clean; existing adapter/list-tools/lint tests still pass.
🤖 Automated Code Review✅ Ruff Lint — No issues✅ Ruff Format — Clean✅ Secret Detection — Clean✅ Large Files — Within limits📊 Diff Stats — 2 file(s) changedVerdict: ✅ Pass — No issues found. Automated by Coding-Dev-Tools/.github reusable workflow. |
|
Pre-PR Code Review — Verdict: APPROVE (pending release gates) Gates holding approval: PR is ~36 min old (< 6h minimum) and has a single contributor (cowork-bot). Per the review policy these must clear before a formal APPROVE; posting as a COMMENT so the verdict is on record. Scope — Fixes the bug where What's good
CI — Recommended follow-up (non-blocking)
No security, secret, or injection concerns (args passed as a list to |
Coding-Dev-Tools
left a comment
There was a problem hiding this comment.
Pre-PR Code Reviewer verdict: APPROVE-pending (cannot auto-approve: PR <6h old, single contributor, self-approval embargo).
What's good
- The multi-valued parameter fix is correct and well-structured.
_element_json_schema()+_is_multi_valued()cleanly separate scalar typing from cardinality. - Behavior is right:
multiple=Trueoptions → flag repeated per value;nargs=-1variadic positionals → one arg each; fixed-tuplenargs>1→ one flag + all values, withminItems/maxItemspinned; bool handling preserved via_append_option(). Previously such params were advertised as a single scalar string and their list/tuple value was stringified into one garbage CLI arg (e.g.--tag "['a', 'b']"). - New
tests/test_multi_valued_params.py(94 lines) coversmultiple=True,nargs=-1, andnargs>1— solid regression coverage for the previously-broken case.
Security / quality: no issues found. No regression of any prior engraphis-recorded fix detected in this code area.
CI note (informational): ensure-pr fails with the same fleet-wide createPullRequest token-scope gap — not a code defect.
Verdict: sound fix with tests; eligible for approval once the age/contributor gates clear.
Coding-Dev-Tools
left a comment
There was a problem hiding this comment.
Pre-PR Review: APPROVE (pending merge gates)
Verdict: APPROVE — correct, well-tested feature fix.
Changes: multi-valued Click parameters (multiple=True, nargs=-1, nargs>1) are now modelled as JSON-Schema arrays (with minItems/maxItems for fixed tuples) instead of a single scalar string, and the handler expands list/tuple values into proper repeated flags / multiple args. Scalar behavior is unchanged (backward compatible).
Quality: 10 new tests in tests/test_multi_valued_params.py cover schema shape + invocation for all three forms plus scalar back-compat. CI green across Python 3.10–3.14 + lint. No security or logic concerns; the flag-expansion logic correctly handles the exotic multiple=True + nargs>1 combination.
Merge gates: single bot author, <6h — formal approval withheld per policy. Substantive verdict APPROVE.
Coding-Dev-Tools
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (Pre-PR Code Analyzer)
Correctly maps multi-valued Click parameters — multiple=True, variadic nargs=-1, and fixed-tuple nargs>1 — to array JSON-Schema with proper items types and minItems/maxItems length constraints, and the handler expands lists/tuples for positionals, repeatable flags, and fixed-tuple options. New regression tests cover both the schema shape and the arg-expansion. No logic/security issues. (Prior automated pass only ran ruff lint — this is the first real review of the change.)
Coding-Dev-Tools
left a comment
There was a problem hiding this comment.
🤖 Pre-PR Code Review — APPROVE (pending 6h / 3-reviewer gate)
Multi-valued Click params → MCP array schemas — sound and well-tested.
_element_json_schema()extracts the per-value type;_is_multi_valued()detectsmultiple=True,nargs=-1, and fixed-tuplenargs>1.- Multi-valued params now map to JSON Schema
arraywithitemscarrying the element type; fixed-tuple pinsminItems/maxItems. - Handler expansion is correct:
multiple=Truerepeats the flag per value;nargs>1emits one flag + N values; variadic positional expands one-arg-per-element. Scalar behavior unchanged.
10 new tests cover schema shape + invocation for all three forms plus scalar back-compat. CI: tests 3.10–3.14 ✅, lint ✅, code-review ✅.
Recommend merge once the gate clears.
Problem
The adapter advertised
multiple=Trueoptions, variadic (nargs=-1) arguments, and fixed-tuple (nargs>1) options as a single scalar string in the generated MCP tool schema. The handler then stringified the list/tuple value into one garbage CLI argument (e.g.--tag "['a', 'b']"), so any LLM calling such a tool passed broken args and the wrapped CLI rejected them.Fix
itemscarry the element type; pinminItems/maxItemsfor fixednargs>1tuples.multiple=True→ repeat the flag once per valuenargs>1→ one flag + N valuesnargs=-1) → one arg per elementVerification
tests/test_multi_valued_params.py(10 cases) covering schema shape + invocation for all three multi-valued forms plus scalar back-compat.ruff check+ruff formatclean; full adapter/list-tools/lint suites still pass.This delivers the previously-staged commit
569535fas a PR (it was blocked from delivery by an expired fleet token).