You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type --tool-arg values by the tool's inputSchema (#3075) - #3087
--tool-arg used to JSON-parse every value as soon as it came off the command line, before the CLI had connected. So zip=10001 was sent as the number 10001, and a tool whose schema declares zip a string rejected it. That applied to the one-shot CLI, to mcpdo's --tool-arg, and to mcpdo's key:=value positionals. Values now stay as raw text until tools/call (or --load) has looked the tool up, which both paths already do for tool_not_found. Each value is then typed from the tool's inputSchema, so there is no extra round trip.
The shared helper is core/cli/utils/tool-arg-types.ts:
Declared property type
Result
"string"
The text exactly as typed. It never reaches the JSON parser, so 1.10, 9007199254740993 and 1e400 stay verbatim.
number / integer / boolean / object / array
The client's existing JSON parse. A result of the wrong type is a usage error (exit 1, code: "usage") that names the key and never the value.
Undeclared key, type array, anyOf/oneOf, no type
The current behaviour: JSON-parse when the value parses, otherwise send the text.
--tool-args-json and an inline JSON positional are still sent verbatim.
Design notes
The JSON path is still each client's own parser.runMethod and the load engine take a parseToolArgValue hook (RunMethodOptions / LoadRunExtras). The CLI passes a wrapper around its existing parseKeyValuePair, and the mcpdo daemon passes its existing key:=value parse. Edits to those functions, such as CLI and mcpdo silently round integers beyond 2^53 in --tool-arg, --tool-args-json, --metadata, --tool-metadata #3068's rejection of integers beyond 2^53, therefore apply wherever JSON parsing still happens. The string path never calls them.
A whole JSON string literal is still unquoted on the string path.zip='"10001"' sends "10001" and message="" sends "". The issue's literal spec says "verbatim", but key='"…"' was the documented way to force a string, and existing tests cover it (message="null", message=""). Sending the quotes literally would break every script that used the workaround. Only text that is one complete JSON string is unquoted. Everything else is kept as typed.
mcpdo :=. It gets the same schema typing as --tool-arg. It is mcpdo's only positional key/value syntax, and it has never meant "this is JSON" in the httpie sense: message:=hello has always sent a string, and nothing like httpie's = exists beside it. So it is the general-purpose syntax, and the general-purpose rule applies. Explicit JSON is still available as an inline object, '{"zip":10001}'. events/poll / events/stream positionals have no schema and are unchanged.
--load types the flag arguments the same way after its own tool lookup. One exception: a value that contains a load placeholder (page={{rand:1-50}}) skips the type check, because the template engine makes the number per call.
Timing of value errors. A bad value (count=abc, n=1e400) is now reported after the connection and the tool lookup rather than at argument parsing, because the type isn't known before then. A malformed pair (novalue, =x, k=) still fails before connecting.
Tests
clients/cli/__tests__/tool-arg-types.test.ts: unit coverage of the helper (each type, unions, mismatches, unquoting, parser hand-off, the placeholder skip, __proto__).
clients/cli/__tests__/tools.test.ts: end to end against a typed tool. zip=10001 and version=1.10 arrive as strings, count=3 as an integer and a union-typed key as a number, and count=many exits 1 naming the key.
clients/mcpdo/__tests__/daemon-connections.test.ts: the daemon types toolArgText (a string stays a string, numbers are parsed, a mismatch is refused). parse-tool-args.test.ts is updated for the raw-text split.
npm run local:gate is green.
Docs: the CLI README, the mcpdo README, skills/mcpdo/SKILL.md and docs/cli-smoke-testing.md.
`--tool-arg` (CLI and mcpdo) and mcpdo's `key:=value` positionals used to
JSON-parse every value at parse time, so `zip=10001` reached a string-typed
property as a number and was rejected. The values now stay raw text until
`tools/call` / `--load` has looked the tool up, and a shared core helper
(core/cli/utils/tool-arg-types.ts) types them by the declared property type:
string keeps the text (a whole JSON string literal is still unquoted),
number/integer/boolean/object/array go through the client's existing JSON
parse and must match, and undeclared or union-typed keys keep the old parse.
--tool-args-json and inline JSON stay verbatim.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The compatibility exception mishandles whitespace-padded JSON string literals, causing existing scripts to pass spaces and literal quotes instead of the intended string value.
…3068)
`JSON.parse` turns every number into a float64, so an integer past
±2^53 in --tool-arg, --tool-args-json, --metadata, --tool-metadata or
mcpdo's key:=value / inline-JSON positionals reached the server rounded,
with exit 0. A shared `parseJsonExact` (core/cli/utils/exact-json.ts)
uses the reviver's `context.source` to detect an integer literal that
does not survive the conversion, and both clients reject it as a usage
error naming the key but never the value, as they already do for 1e400.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
JSON-decoded tool arguments can bypass raw-text validation, allowing a reversed load-placeholder range to be evaluated instead of rejected with a usage error.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Validate decoded load-argument templates before evaluation
core/cli/handlers/load-test.ts:2237
JSON decoding here can reveal an invalid load placeholder that both frontends' raw-text validation misses: --tool-arg 'message="call-{{rand:9\u002d1}}"' becomes call-{{rand:9-1}} after coercion. The load template then evaluates the reversed range instead of rejecting it with a usage error. Import and call assertLoadArgsTemplate(flagArgs, "--tool-arg") before loadArgsTemplate, and cover a JSON-escaped placeholder in a regression test.
`JSON.stringify` writes a double's shortest round-trip form, so an
exactly representable literal like 1000000000000000128 still reached
the wire as 1000000000000000100. Compare the source digits against the
integer the serialized token denotes, exponent notation included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
Copilot round 2. This finding had no inline thread (it was a "previously missed issue"), so I'm answering it here.
Validate decoded load-argument templates before evaluation (core/cli/handlers/load-test.ts): fixed in 94be728. This PR introduced the regression. The clients' pre-connect placeholder check now sees raw text, and a JSON escape such as message="call-{{rand:9\\u002d1}}" only spells a reversed range once it is decoded. runToolLoad now runs assertLoadArgsTemplate on the typed flag arguments before compiling them. The regression test in load-test.test.ts asserts exit 1, load_args_invalid, and that no tools/call was sent.
Round 1 recap: the whitespace-padded JSON string literal was fixed in c74517c, and the reply is in its thread.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Placeholder detection checks only raw input, causing valid escaped numeric templates to be rejected before template expansion.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Accept escaped numeric placeholders in integer arguments
core/cli/utils/tool-arg-types.ts:165
For an integer property, --load --tool-arg 'page="{{rand:1\u002d50}}"' now fails with a usage error even though it is a valid numeric template. The parser decodes the value to {{rand:1-50}}, but the placeholder exemption checks only the raw text, misses the escaped hyphen, and rejects the string before loadArgsTemplate can expand it. Check the decoded string for placeholders too, and add a regression case for a valid escaped numeric placeholder.
The reviver walk recurses where a plain JSON.parse does not, so very
deep but valid JSON now throws RangeError, and the key=value parsers'
catch-all fallback would have sent it as a string. A shared
`parseJsonOrString` takes the fallback on SyntaxError only, turns an
inexact integer into the usage error, and propagates anything else.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
Copilot round 3. This one was also a "previously missed issue" with no thread, so I'm answering it here.
Accept escaped numeric placeholders in integer arguments (core/cli/utils/tool-arg-types.ts): fixed in 6dcee64. Like round 2, this came from deferring the parse. The placeholder exemption for --load is now checked against the decoded string as well as the raw text, so page="{{rand:1\\u002d50}}" for an integer property reaches the template engine again. A non-placeholder string is still refused. Unit cases for both are in tool-arg-types.test.ts.
Copilot review loop closed. Round 4 came back clean (no inline comments, no suppressed or previously missed findings), so per the pr-flow exit rule I'm stopping on the first clean round. Over the four rounds, three findings were raised and all three were fixed (c74517c, 94be728, 6dcee64). None were declined.
…3080 rollup)
Both PRs edit the --tool-arg row; the resolution keeps #3069's `key=` sends `""` and #3068's integer-precision sentence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
Rollup for tracker #3080: #3075 conflicted textually with every sibling in
clients/cli/src/cli.ts and with #3068 in mcpdo's parsers, so this branch
carries the resolution and merges last.
- Imports: keep #3075's tool-arg-types imports beside #3068's exact-json
ones and #3074's suggest-flag import.
- mcpdo: #3075 moved --tool-arg / key:=value parsing into autoParseValue;
it now passes the key so #3068's integer-precision guard applies on that
path (parseToolArgValue included), with a regression test.
- collectToolArgText accepted no empty value, which would have undone
#3069 for --tool-arg once both merged; k= is now the empty string, which
a string or undeclared property receives as "" and a typed non-string
property refuses as a usage error (tests for both).
- CLI README --tool-arg row: #3075's schema typing plus #3069's k= and
#3068's integer-precision sentences.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3075
What changed
--tool-argused to JSON-parse every value as soon as it came off the command line, before the CLI had connected. Sozip=10001was sent as the number10001, and a tool whose schema declareszipa string rejected it. That applied to the one-shot CLI, to mcpdo's--tool-arg, and to mcpdo'skey:=valuepositionals. Values now stay as raw text untiltools/call(or--load) has looked the tool up, which both paths already do fortool_not_found. Each value is then typed from the tool'sinputSchema, so there is no extra round trip.The shared helper is
core/cli/utils/tool-arg-types.ts:"string"1.10,9007199254740993and1e400stay verbatim.number/integer/boolean/object/arraycode: "usage") that names the key and never the value.typearray,anyOf/oneOf, notype--tool-args-jsonand an inline JSON positional are still sent verbatim.Design notes
runMethodand the load engine take aparseToolArgValuehook (RunMethodOptions/LoadRunExtras). The CLI passes a wrapper around its existingparseKeyValuePair, and the mcpdo daemon passes its existingkey:=valueparse. Edits to those functions, such as CLI and mcpdo silently round integers beyond 2^53 in --tool-arg, --tool-args-json, --metadata, --tool-metadata #3068's rejection of integers beyond 2^53, therefore apply wherever JSON parsing still happens. The string path never calls them.zip='"10001"'sends"10001"andmessage=""sends"". The issue's literal spec says "verbatim", butkey='"…"'was the documented way to force a string, and existing tests cover it (message="null",message=""). Sending the quotes literally would break every script that used the workaround. Only text that is one complete JSON string is unquoted. Everything else is kept as typed.:=. It gets the same schema typing as--tool-arg. It is mcpdo's only positional key/value syntax, and it has never meant "this is JSON" in the httpie sense:message:=hellohas always sent a string, and nothing like httpie's=exists beside it. So it is the general-purpose syntax, and the general-purpose rule applies. Explicit JSON is still available as an inline object,'{"zip":10001}'.events/poll/events/streampositionals have no schema and are unchanged.--loadtypes the flag arguments the same way after its own tool lookup. One exception: a value that contains a load placeholder (page={{rand:1-50}}) skips the type check, because the template engine makes the number per call.count=abc,n=1e400) is now reported after the connection and the tool lookup rather than at argument parsing, because the type isn't known before then. A malformed pair (novalue,=x,k=) still fails before connecting.Tests
clients/cli/__tests__/tool-arg-types.test.ts: unit coverage of the helper (each type, unions, mismatches, unquoting, parser hand-off, the placeholder skip,__proto__).clients/cli/__tests__/tools.test.ts: end to end against a typed tool.zip=10001andversion=1.10arrive as strings,count=3as an integer and a union-typed key as a number, andcount=manyexits 1 naming the key.clients/mcpdo/__tests__/daemon-connections.test.ts: the daemon typestoolArgText(a string stays a string, numbers are parsed, a mismatch is refused).parse-tool-args.test.tsis updated for the raw-text split.npm run local:gateis green.Docs: the CLI README, the mcpdo README,
skills/mcpdo/SKILL.mdanddocs/cli-smoke-testing.md.🤖 Generated with Claude Code