fix(mcp): strip API extras from listMemories entries

The client parsed /v4/memories/list with z.looseObject, which keeps
unknown keys. The API returns extra per-entry fields (spaceId, orgId,
metadata, memoryRelations, temporalContext, forgetReason, …) that flow
into structuredContent, which is validated against the strict tool
outputSchema (additionalProperties: false) — producing
"data/memoryEntries/N must NOT have additional properties".

Switch memoryEntrySchema and memoryEntryHistorySchema to z.object, which
strips unknown keys on parse while still tolerating new API fields.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Dhravya Shah 2026-08-18 20:54:09 -07:00
parent 149589ae7e
commit 7430a3e9d0

View file

@ -34,7 +34,8 @@ export interface DocumentsListResponse {
pagination: SdkDocumentListResponse["pagination"]
}
const memoryEntryHistorySchema = z.looseObject({
// z.object strips API extras that the strict MCP output schema would reject.
const memoryEntryHistorySchema = z.object({
id: z.string(),
memory: z.string(),
version: z.number(),
@ -48,7 +49,7 @@ const memoryEntryHistorySchema = z.looseObject({
export type MemoryEntryHistory = z.infer<typeof memoryEntryHistorySchema>
const memoryEntrySchema = z.looseObject({
const memoryEntrySchema = z.object({
id: z.string(),
memory: z.string(),
version: z.number(),