Conversation
…SDK's Object-typed tool parameters were mapped to z.record(), which newer zod (4.5.x) serialises through a processor the SDK's bundled zod 4.4.3 converter cannot run. tools/list then failed for every OpenCode tool. Map them to an open object instead, which serialises identically. Fixes openchamber#12
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.
Fixes #12.
jsonSchemaToZodShapemaps object-typed tool parameters toz.record(z.string(), z.any()). The SDK converts tool shapes to JSON Schema with the zod it bundles (4.4.3 in 0.3.260+). When the plugin's ownzodresolves to 4.5.x, the record processor callsctx.deferred.pushon a context the older converter never creates.tools/listthen throws for the whole server, and Claude runs the turn with no OpenCode tools.This PR maps object parameters to
z.object({}).catchall(z.any()). That serialises to the same{"type":"object","additionalProperties":{}}on both zod versions, so it keeps thetype: objecthint.Test:
test/tool-bridge-schema-regression.tsgoes through the proxy, captures the MCP server passed to the query starter, and calls itstools/list. The lockfile pins SDK 0.3.224, which uses the peer zod, so the dev tree doesn't reproduce the bug. With SDK 0.3.260 and zod 4.5.4 swapped intonode_modules, the test fails onmainwith the #12 stack trace and passes on this branch.bun test/smoke.tsandtsc --noEmitpass.A more complete fix would pin
zodto the SDK's bundled version. This change removes the only construct that currently triggers the mismatch.