From 335c5690c1c0fc8a2bc45b47c30c875d2f1756a8 Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Wed, 18 Mar 2026 10:12:49 -0400 Subject: [PATCH] fix(memory): wrap outputSchema in z.object() for proper Zod typing 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 #3622 --- src/memory/index.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/memory/index.ts b/src/memory/index.ts index b560bf1e53..433d35d05b 100644 --- a/src/memory/index.ts +++ b/src/memory/index.ts @@ -267,9 +267,9 @@ server.registerTool( inputSchema: { entities: z.array(EntitySchema) }, - outputSchema: { + outputSchema: z.object({ entities: z.array(EntitySchema) - } + }) }, async ({ entities }) => { const result = await knowledgeGraphManager.createEntities(entities); @@ -289,9 +289,9 @@ server.registerTool( inputSchema: { relations: z.array(RelationSchema) }, - outputSchema: { + outputSchema: z.object({ relations: z.array(RelationSchema) - } + }) }, async ({ relations }) => { const result = await knowledgeGraphManager.createRelations(relations); @@ -314,12 +314,12 @@ server.registerTool( contents: z.array(z.string()).describe("An array of observation contents to add") })) }, - outputSchema: { + outputSchema: z.object({ results: z.array(z.object({ entityName: z.string(), addedObservations: z.array(z.string()) })) - } + }) }, async ({ observations }) => { const result = await knowledgeGraphManager.addObservations(observations); @@ -339,10 +339,10 @@ server.registerTool( inputSchema: { entityNames: z.array(z.string()).describe("An array of entity names to delete") }, - outputSchema: { + outputSchema: z.object({ success: z.boolean(), message: z.string() - } + }) }, async ({ entityNames }) => { await knowledgeGraphManager.deleteEntities(entityNames); @@ -365,10 +365,10 @@ server.registerTool( observations: z.array(z.string()).describe("An array of observations to delete") })) }, - outputSchema: { + outputSchema: z.object({ success: z.boolean(), message: z.string() - } + }) }, async ({ deletions }) => { await knowledgeGraphManager.deleteObservations(deletions); @@ -388,10 +388,10 @@ server.registerTool( inputSchema: { relations: z.array(RelationSchema).describe("An array of relations to delete") }, - outputSchema: { + outputSchema: z.object({ success: z.boolean(), message: z.string() - } + }) }, async ({ relations }) => { await knowledgeGraphManager.deleteRelations(relations); @@ -409,10 +409,10 @@ server.registerTool( title: "Read Graph", description: "Read the entire knowledge graph", inputSchema: {}, - outputSchema: { + outputSchema: z.object({ entities: z.array(EntitySchema), relations: z.array(RelationSchema) - } + }) }, async () => { const graph = await knowledgeGraphManager.readGraph(); @@ -432,10 +432,10 @@ server.registerTool( inputSchema: { query: z.string().describe("The search query to match against entity names, types, and observation content") }, - outputSchema: { + outputSchema: z.object({ entities: z.array(EntitySchema), relations: z.array(RelationSchema) - } + }) }, async ({ query }) => { const graph = await knowledgeGraphManager.searchNodes(query); @@ -455,10 +455,10 @@ server.registerTool( inputSchema: { names: z.array(z.string()).describe("An array of entity names to retrieve") }, - outputSchema: { + outputSchema: z.object({ entities: z.array(EntitySchema), relations: z.array(RelationSchema) - } + }) }, async ({ names }) => { const graph = await knowledgeGraphManager.openNodes(names);