v2.6.1: MCP param-validator parity + doc fixes - #22
Merged
Conversation
added 2 commits
April 21, 2026 09:11
MCP send_command now runs the same validateParameter() call that the CLI uses for `devices command`, in both the dry-run and live paths. Out-of-range setBrightness, malformed setColor, AC setAll, Curtain/Blind Tilt setPosition, and Relay setMode failures now short-circuit with `isError: true`, errorClass 'usage', before any API call. setColor normalization (hex / named / comma forms → R:G:B) also runs for MCP; the dry-run wouldSend.parameter reflects the normalized value so agents see what would actually be sent. Also locks in plaintext `scenes describe <unknown>` candidate rendering (R-3) — the v2.6.0 code already emitted "Did you mean: …" via StructuredUsageError.context.candidates; these tests just prevent regression.
- Document `--filter` empty-value rejection (R-4): a clause like `name~` or `type=` with an empty RHS exits 2; drop the clause to remove the constraint. Behavior unchanged — README gap filled. - Replace Chinese device-name examples in README, command help text, and test fixtures with neutral English equivalents (`Living Room AC`, `family=home`, `alias=bedroom-lamp`, `AC` / `Bedroom AC` / `Fan Remote`). Substring relationships in name-resolver fixtures are preserved so the bug-1 regression suite still exercises exact+substring ambiguity. - Chinese characters in tests/utils/string.test.ts are retained on purpose — they exercise the CJK whitelist (\u4e00-\u9fff) in src/utils/string.ts:20, a product feature. - Bump package.json + package-lock.json to 2.6.1; CHANGELOG notes R-2 / R-3 / R-4 and the R-1 rejected-by-design ruling.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Follow-up to v2.6.0, addressing the 4 findings from the OpenClaw v2.6.0 re-audit:
send_commandnow runs the samevalidateParameter()call that the CLI uses fordevices command. Out-of-rangesetBrightness, malformedsetColor, ACsetAll, Curtain/Blind TiltsetPosition, and RelaysetModefailures short-circuit withisError: true/ errorClass'usage'before any API call — in both thedryRun:trueand live paths.setColorhex / named-colour / comma forms normalise toR:G:Bfor MCP too; dry-runwouldSend.parameterreflects the normalised value.scenes describe <unknown>already renderedDid you mean: <name> (<id>), …?viaStructuredUsageError.context.candidatesin v2.6.0 — reviewer's counter-example was a 0-scene account. Added tests for both paths (non-empty candidates → hint, empty → no hint).--filterempty-value rejection (name~,type=) is now called out in the README. Behaviour unchanged — doc gap filled.CallToolResult.isError: true; onlyUrlElicitationRequiredescapes as JSON-RPCerror. Faking a JSON-RPC error for Zod failures would need an SDK fork. The text payload already carriesMCP error -32602: …so agents can extract the code fromcontent[0].text. Called out in CHANGELOG "Rejected" section.Also bundles a repo-wide chore: replaced Chinese device-name examples in README, source help text, and test fixtures with neutral English equivalents (
Living Room AC,family=home,alias=bedroom-lamp). The CJK substring relationships in the name-resolver bug-1 regression suite are preserved (AC/Bedroom AC/Fan Remote). Chinese intests/utils/string.test.tsis intentional — it exercises the\u4e00-\u9fffwhitelist insrc/utils/string.ts:20, a supported product feature.See CHANGELOG v2.6.1 for full details.
Test plan
npm run build— cleannpm test— 991/991 passing (53 files), incl. 4 new MCP param-validator tests (R-2) and 2 new scenes plaintext-candidate tests (R-3)send_command setBrightness 101→isError:true+ "setBrightness … 1-100"send_command setColor '#FF0000' dryRun=true→wouldSend.parameter === '255:0:0'scenes describe ZZZplaintext → stderr containsDid you mean: …