servers icon indicating copy to clipboard operation
servers copied to clipboard

fix(memory): strip type field from entities/relations in loadGraph

Open jared03 opened this issue 1 month ago • 0 comments

Summary

Fixes schema validation error in read operations (read_graph, search_nodes, open_nodes).

Problem

The JSONL file stores entities with a type field to distinguish them from relations:

{"type":"entity","name":"...","entityType":"...","observations":[...]}

But the output schema only expects {name, entityType, observations} - no type field.

This causes all read operations to fail with:

MCP error -32602: Structured content does not match the tool's output schema: data.entities[0] should NOT have additional properties

Solution

Strip the type field using destructuring before pushing to result arrays:

if (item.type === "entity") {
  const { type, ...entity } = item;
  graph.entities.push(entity as Entity);
}
if (item.type === "relation") {
  const { type, ...relation } = item;
  graph.relations.push(relation as Relation);
}

Testing

  • All 39 existing tests pass
  • All read operations now return valid responses
  • Write operations continue to work correctly
  • Existing JSONL files remain fully compatible

Fixes #3074

jared03 avatar Dec 01 '25 02:12 jared03