From 8200e7f27dbc45b06fd8b8949a0261f1da79c0b3 Mon Sep 17 00:00:00 2001 From: Mahesh Sanikommu Date: Mon, 12 Oct 2026 16:42:02 -0700 Subject: [PATCH] fix(mcp): adapt community fixes to v5 Restricts add_memory metadata to the flat value types v5 accepts, points the pagination hint at list_memories, and documents MCP_RESOURCE in .dev.vars.example now that OAuth metadata is advertised from it. --- apps/mcp/.dev.vars.example | 2 ++ apps/mcp/src/server/client/index.ts | 2 +- apps/mcp/src/server/format.test.ts | 2 +- apps/mcp/src/server/format.ts | 2 +- apps/mcp/src/server/tools/add-memory.ts | 9 ++++++++- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/mcp/.dev.vars.example b/apps/mcp/.dev.vars.example index dfc969e5..2e18c643 100644 --- a/apps/mcp/.dev.vars.example +++ b/apps/mcp/.dev.vars.example @@ -3,6 +3,8 @@ API_URL= MCP_URL= +# OAuth metadata is advertised from this, so set it to your local MCP URL + /mcp (defaults to prod). +MCP_RESOURCE= #(optional) POSTHOG_API_KEY= \ No newline at end of file diff --git a/apps/mcp/src/server/client/index.ts b/apps/mcp/src/server/client/index.ts index 0835ca32..3052d898 100644 --- a/apps/mcp/src/server/client/index.ts +++ b/apps/mcp/src/server/client/index.ts @@ -196,7 +196,7 @@ export class SupermemoryClient { async createMemory( content: string, - metadata?: Record, + metadata?: Record, ): Promise<{ id: string; status: string; namespace: string }> { try { const result = await this.client.add(this.namespace, { diff --git a/apps/mcp/src/server/format.test.ts b/apps/mcp/src/server/format.test.ts index 42d0ec3a..a4b9ff36 100644 --- a/apps/mcp/src/server/format.test.ts +++ b/apps/mcp/src/server/format.test.ts @@ -65,7 +65,7 @@ describe("formatMemoryEntriesList", () => { ) expect(firstPage).toBe( - "No active memories on page 1 (2 pages total).\n\nMore available - call listMemories with page: 2.", + "No active memories on page 1 (2 pages total).\n\nMore available - call list_memories with page: 2.", ) expect(secondPage).toContain("[still-active] Current fact") }) diff --git a/apps/mcp/src/server/format.ts b/apps/mcp/src/server/format.ts index 387f887c..963f1ccf 100644 --- a/apps/mcp/src/server/format.ts +++ b/apps/mcp/src/server/format.ts @@ -91,7 +91,7 @@ export function formatMemoryEntriesList( if (pagination.currentPage < pagination.totalPages) { parts.push( "", - `More available - call listMemories with page: ${pagination.currentPage + 1}.`, + `More available - call list_memories with page: ${pagination.currentPage + 1}.`, ) } return parts.join("\n") diff --git a/apps/mcp/src/server/tools/add-memory.ts b/apps/mcp/src/server/tools/add-memory.ts index e2dd70a4..6cad7416 100644 --- a/apps/mcp/src/server/tools/add-memory.ts +++ b/apps/mcp/src/server/tools/add-memory.ts @@ -25,7 +25,14 @@ export function register(deps: ToolDeps) { ), namespace: optionalNamespaceSchema, ...legacyNamespaceInput, - metadata: z.record(z.string(), z.unknown()).optional().describe("Optional metadata to attach to the saved memory"), + // v5 metadata values are flat: string, number, boolean or string list. + metadata: z + .record( + z.string(), + z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), + ) + .optional() + .describe("Optional metadata to attach to the saved memory"), }) deps.server.registerTool(