v1.0.139
Closes the OpenCode native-bridge validation gap — input schemas are now enforced before tool handlers run, matching the behavior MCP clients get for free.
Fix
OpenCode native bridge now validates tool input (#621). PRs #574/#597 added a native fast-path for OpenCode that bypasses the MCP stdio transport entirely — it calls registered tool handlers directly. The MCP SDK normally runs safeParseAsync against each tool's Zod inputSchema at server/mcp.js:174 before invoking the handler. The native path skipped that step, so:
z.preprocess(coerceCommandsArray, …)onctx_batch_execute.commandsnever fired → JSON-stringified args or bare-string commands crashed with opaquecommands.map is not a function.- Missing required fields surfaced as runtime TypeErrors instead of clear "Invalid arguments" messages.
v1.0.139 runs inputSchema.parse(args) inside buildNativeTools before invoking the handler. Validation failures surface as Invalid arguments for <tool>: <zod error path + reason>. Behavior is now byte-equivalent between the native fast-path and the MCP stdio path. Closes #621.
Tests
5 new tests in existing tests/opencode-plugin.test.ts (CONTRIBUTING L275 — no new test files):
- baseline well-formed args still pass through
- JSON-stringified
commandsarray coerced - bare-string
commandslifted to{label, command} - missing
commandsraises a clear validation error (not a TypeError) - JSON-stringified
queriesonctx_searchcoerced
All targeted: 5/5 pass. Full impacted suite preserves baseline.
Compatibility
15 adapters, 3 OS. No schema migration. engines.node >= 22.5.0 preserved.
Upgrade
npm install -g context-mode@latest
# Restart Claude Code (Cmd+Q + reopen) — `/reload-plugins` alone won't pick up the new MCP server.