Skip to content

Conversation

@majiayu000
Copy link

Summary

Problem

When memory.jsonl contains entities with extra properties (e.g., custom_id), the read_graph tool fails with:

MCP error -32602: Structured content does not match the tool's output schema: 
data/entities/0 must NOT have additional properties

Solution

Using Zod's .passthrough() allows the schema to accept additional properties while still validating required fields.

Fixes #3144

Added .passthrough() to EntitySchema and RelationSchema to allow
entities with extra properties to be read without schema validation
errors. This fixes the issue where read_graph fails when the stored
memory.jsonl contains entities with non-standard properties.

Fixes modelcontextprotocol#3144

Signed-off-by: majiayu000 <[email protected]>
@NeverMore93
Copy link

The issue is not resolved

@majiayu000
Copy link
Author

@NeverMore93 I've tested this fix and verified it works correctly. Here's my analysis:

Root Cause:
The validation error occurs on the client side, not the server side. When the server returns structuredContent, the MCP client validates it against the outputSchema using AJV (JSON Schema validator).

  • Without .passthrough(): JSON Schema has additionalProperties: false → validation fails
  • With .passthrough(): JSON Schema has additionalProperties: {} → validation passes

Test Results:
I reproduced the issue and confirmed the fix works:

# Before fix (additionalProperties: false)
Error: MCP error -32602: Structured content does not match the tool's output schema: 
data/entities/0 must NOT have additional properties

# After fix (additionalProperties: {})
SUCCESS! read_graph returns data with extra properties correctly

Could you share more details about your test environment?

  • MCP SDK version (npm list @modelcontextprotocol/sdk)
  • The exact error message you're seeing
  • Steps to reproduce the issue

This will help identify if there's a version-specific issue or a different scenario not covered by this fix.

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.

Memory MCP Schema Validation Error on read_graph for entities with additional properties

2 participants