Skip to content

fix(memory): use plain JSON Schema for outputSchema instead of Zod objects#3627

Open
ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
ctonneslan:fix/memory-output-schema-json
Open

fix(memory): use plain JSON Schema for outputSchema instead of Zod objects#3627
ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
ctonneslan:fix/memory-output-schema-json

Conversation

@ctonneslan
Copy link

@ctonneslan ctonneslan commented Mar 18, 2026

Problem

The memory server passes plain objects with Zod values as outputSchema:

outputSchema: {
  entities: z.array(EntitySchema)  // plain object, not z.object()
}

The SDK's McpServer.tool() expects outputSchema to be a full Zod schema (z.object()), not a plain object containing Zod schemas. This causes TypeScript type errors (AnySchema mismatch) and serialization failures when the SDK tries to convert via schemaToJson().

Fix

Wrapped all 9 outputSchema definitions in z.object():

- outputSchema: {
-   entities: z.array(EntitySchema)
- }
+ outputSchema: z.object({
+   entities: z.array(EntitySchema)
+ })

The SDK's schemaToJson() then correctly converts the Zod schema to JSON Schema for the tools/list response.

Fixes #3622

The memory server passed plain objects with Zod values as outputSchema
properties (e.g. { entities: z.array(...) }), but the SDK expects
outputSchema to be a full Zod schema (z.object({ ... })). This causes
type errors and serialization failures.

Wrapped all 9 outputSchema definitions in z.object() so the SDK can
properly convert them to JSON Schema via schemaToJson().

Fixes modelcontextprotocol#3622
@ctonneslan ctonneslan force-pushed the fix/memory-output-schema-json branch from e8ca89d to 335c569 Compare March 18, 2026 15:03
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.

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

1 participant