Skip to content

fix: keep the tool bridge listable when plugin zod is newer than the SDK's - #20

Open
karimodm wants to merge 1 commit into
openchamber:mainfrom
karimodm:fix/zod-record-tool-bridge
Open

karimodm wants to merge 1 commit into
openchamber:mainfrom
karimodm:fix/zod-record-tool-bridge

Conversation

@karimodm

Copy link
Copy Markdown

Fixes #12.

jsonSchemaToZodShape maps object-typed tool parameters to z.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 own zod resolves to 4.5.x, the record processor calls ctx.deferred.push on a context the older converter never creates. tools/list then 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 the type: object hint.

Test: test/tool-bridge-schema-regression.ts goes through the proxy, captures the MCP server passed to the query starter, and calls its tools/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 into node_modules, the test fails on main with the #12 stack trace and passes on this branch. bun test/smoke.ts and tsc --noEmit pass.

A more complete fix would pin zod to the SDK's bundled version. This change removes the only construct that currently triggers the mismatch.

…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
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.

Tool bridge fails with 'ctx.deferred.push' when zod resolves to 4.5.x (SDK bundles zod 4.4.3)

1 participant