Skip to content

outputSchema uses Zod objects instead of JSON Schema, violating spec and causing serialization failures #3622

Description

@hitechrv

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions