outputSchema uses Zod objects instead of JSON Schema, violating spec and causing serialization failures
Issue The memory server's tool definitions use Zod schema objects directly in outputSchema, which violates the MCP specification and causes serialization failures when tools/list endpoint attempts to convert schemas to JSON.
Root Cause Per the MCP Tools specification, outputSchema must be a plain JSON Schema object:
"outputSchema": { "type": "object", "properties": { /* ... / }, "required": [ / ... */ ] }
However, the current implementation passes Zod schema objects directly:
outputSchema: z.object({ /* ... */ })
When the tools/list endpoint serializes these schemas to JSON-RPC responses, Zod objects fail to serialize, resulting in _zod property errors.
Impact Spec Violation: outputSchema should be JSON Schema, not language-specific objects SDK Compatibility: Works with Claude Desktop's bundled SDK (which may have a workaround), but fails with the npm SDK version General Open Source: Projects using the npm SDK directly will encounter this bug
Zod Isn't Needed for outputSchema inputSchema needs runtime validation (Zod is appropriate) outputSchema is only for documentation/type hints — no validation needed Using plain JSON Schema for output is cleaner and spec-compliant
Proposed Solutions
Option 1: Mixed approach (inputSchema uses Zod, outputSchema uses JSON Schema) Keep Zod for input validation (better DX, runtime safety) Use plain JSON Schema for output documentation Minimal change, maintains benefits of Zod for validation
Option 2: Transparent conversion (Zod everywhere, auto-convert on serialization) Use Zod throughout for consistency Convert to JSON Schema automatically before sending in tools/list response Requires zod-to-json-schema dependency
Would appreciate feedback on the preferred approach before submitting a PR.
Good analysis. I've been working on related issues in the typescript-sdk.
Re: Option 1 vs Option 2
I'd lean toward Option 1 (plain JSON Schema for outputSchema) for a few reasons:
- Spec alignment — outputSchema is purely declarative. Adding a Zod dependency for documentation is over-engineering.
- No runtime validation needed — Unlike inputSchema, you never need to validate output against the schema at runtime (the server produces it).
- Simpler maintenance —
zod-to-json-schemaconversion isn't always 1:1 (refinements, transforms, etc. can produce unexpected results).
The memory server specifically only has simple object shapes, so hand-written JSON Schema is minimal and explicit.
Happy to help with a PR if you'd like—I've been working through similar patterns for the tool annotations work.
A2ABench has an accepted answer for this imported thread.
- Thread: https://a2abench-api.web.app/q/cmn1ngz2x008jxztyaqkwtsw9
- Accepted at: 2026-03-24T20:29:18.939Z
- Accepted answer agent:
ai village - Answer preview: "Based on our strict principles of idempotent execution, trace-first architecture, and explicit workflow boundaries, this issue regarding 'outputSchema uses Zod objects instead of JSON Schema, violating spec and causing serialization failures' can be resolved by enforcing stateles"
Revisited this against current main with SDK 1.30 and zod 4. tools/list serialises the Zod outputSchema to valid JSON Schema without the _zod error, and the read tools return structuredContent that validates against it. That is the same finding as on #3966, which was closed for the same reason. Closing as completed. If you can still reproduce a serialisation failure with a current SDK, please reopen with the SDK version and the failing tools/list output.