Skip to content

v2.6.1: MCP param-validator parity + doc fixes - #22

Merged
chenliuyun merged 2 commits into
mainfrom
fix/2.6.1-mcp-validator-parity
Apr 21, 2026
Merged

v2.6.1: MCP param-validator parity + doc fixes#22
chenliuyun merged 2 commits into
mainfrom
fix/2.6.1-mcp-validator-parity

Conversation

@chenliuyun

@chenliuyun chenliuyun commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to v2.6.0, addressing the 4 findings from the OpenClaw v2.6.0 re-audit:

  • R-2 (fixed): MCP send_command now runs the same validateParameter() call that the CLI uses for devices command. Out-of-range setBrightness, malformed setColor, AC setAll, Curtain/Blind Tilt setPosition, and Relay setMode failures short-circuit with isError: true / errorClass 'usage' before any API call — in both the dryRun:true and live paths. setColor hex / named-colour / comma forms normalise to R:G:B for MCP too; dry-run wouldSend.parameter reflects the normalised value.
  • R-3 (verified + locked in): Plaintext scenes describe <unknown> already rendered Did you mean: <name> (<id>), …? via StructuredUsageError.context.candidates in v2.6.0 — reviewer's counter-example was a 0-scene account. Added tests for both paths (non-empty candidates → hint, empty → no hint).
  • R-4 (documented): --filter empty-value rejection (name~, type=) is now called out in the README. Behaviour unchanged — doc gap filled.
  • R-1 (rejected by design): The MCP SDK wraps every tool-handler error as CallToolResult.isError: true; only UrlElicitationRequired escapes as JSON-RPC error. Faking a JSON-RPC error for Zod failures would need an SDK fork. The text payload already carries MCP error -32602: … so agents can extract the code from content[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 in tests/utils/string.test.ts is intentional — it exercises the \u4e00-\u9fff whitelist in src/utils/string.ts:20, a supported product feature.

See CHANGELOG v2.6.1 for full details.

Test plan

  • npm run build — clean
  • npm test — 991/991 passing (53 files), incl. 4 new MCP param-validator tests (R-2) and 2 new scenes plaintext-candidate tests (R-3)
  • Manual MCP smoke: send_command setBrightness 101isError:true + "setBrightness … 1-100"
  • Manual MCP smoke: send_command setColor '#FF0000' dryRun=truewouldSend.parameter === '255:0:0'
  • Manual CLI smoke: scenes describe ZZZ plaintext → stderr contains Did you mean: …

chenliuyun 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.
@chenliuyun
chenliuyun merged commit 683cbef into main Apr 21, 2026
4 checks passed
@chenliuyun
chenliuyun deleted the fix/2.6.1-mcp-validator-parity branch April 21, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant