Skip to content

Commit 335c569

Browse files
author
Charlie Tonneslan
committed
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
1 parent f424458 commit 335c569

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

src/memory/index.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ server.registerTool(
267267
inputSchema: {
268268
entities: z.array(EntitySchema)
269269
},
270-
outputSchema: {
270+
outputSchema: z.object({
271271
entities: z.array(EntitySchema)
272-
}
272+
})
273273
},
274274
async ({ entities }) => {
275275
const result = await knowledgeGraphManager.createEntities(entities);
@@ -289,9 +289,9 @@ server.registerTool(
289289
inputSchema: {
290290
relations: z.array(RelationSchema)
291291
},
292-
outputSchema: {
292+
outputSchema: z.object({
293293
relations: z.array(RelationSchema)
294-
}
294+
})
295295
},
296296
async ({ relations }) => {
297297
const result = await knowledgeGraphManager.createRelations(relations);
@@ -314,12 +314,12 @@ server.registerTool(
314314
contents: z.array(z.string()).describe("An array of observation contents to add")
315315
}))
316316
},
317-
outputSchema: {
317+
outputSchema: z.object({
318318
results: z.array(z.object({
319319
entityName: z.string(),
320320
addedObservations: z.array(z.string())
321321
}))
322-
}
322+
})
323323
},
324324
async ({ observations }) => {
325325
const result = await knowledgeGraphManager.addObservations(observations);
@@ -339,10 +339,10 @@ server.registerTool(
339339
inputSchema: {
340340
entityNames: z.array(z.string()).describe("An array of entity names to delete")
341341
},
342-
outputSchema: {
342+
outputSchema: z.object({
343343
success: z.boolean(),
344344
message: z.string()
345-
}
345+
})
346346
},
347347
async ({ entityNames }) => {
348348
await knowledgeGraphManager.deleteEntities(entityNames);
@@ -365,10 +365,10 @@ server.registerTool(
365365
observations: z.array(z.string()).describe("An array of observations to delete")
366366
}))
367367
},
368-
outputSchema: {
368+
outputSchema: z.object({
369369
success: z.boolean(),
370370
message: z.string()
371-
}
371+
})
372372
},
373373
async ({ deletions }) => {
374374
await knowledgeGraphManager.deleteObservations(deletions);
@@ -388,10 +388,10 @@ server.registerTool(
388388
inputSchema: {
389389
relations: z.array(RelationSchema).describe("An array of relations to delete")
390390
},
391-
outputSchema: {
391+
outputSchema: z.object({
392392
success: z.boolean(),
393393
message: z.string()
394-
}
394+
})
395395
},
396396
async ({ relations }) => {
397397
await knowledgeGraphManager.deleteRelations(relations);
@@ -409,10 +409,10 @@ server.registerTool(
409409
title: "Read Graph",
410410
description: "Read the entire knowledge graph",
411411
inputSchema: {},
412-
outputSchema: {
412+
outputSchema: z.object({
413413
entities: z.array(EntitySchema),
414414
relations: z.array(RelationSchema)
415-
}
415+
})
416416
},
417417
async () => {
418418
const graph = await knowledgeGraphManager.readGraph();
@@ -432,10 +432,10 @@ server.registerTool(
432432
inputSchema: {
433433
query: z.string().describe("The search query to match against entity names, types, and observation content")
434434
},
435-
outputSchema: {
435+
outputSchema: z.object({
436436
entities: z.array(EntitySchema),
437437
relations: z.array(RelationSchema)
438-
}
438+
})
439439
},
440440
async ({ query }) => {
441441
const graph = await knowledgeGraphManager.searchNodes(query);
@@ -455,10 +455,10 @@ server.registerTool(
455455
inputSchema: {
456456
names: z.array(z.string()).describe("An array of entity names to retrieve")
457457
},
458-
outputSchema: {
458+
outputSchema: z.object({
459459
entities: z.array(EntitySchema),
460460
relations: z.array(RelationSchema)
461-
}
461+
})
462462
},
463463
async ({ names }) => {
464464
const graph = await knowledgeGraphManager.openNodes(names);

0 commit comments

Comments
 (0)