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.
This commit is contained in:
Mahesh Sanikommu 2026-10-12 16:42:02 -07:00
parent 2222e41d8a
commit 8200e7f27d
5 changed files with 13 additions and 4 deletions

View file

@ -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=

View file

@ -196,7 +196,7 @@ export class SupermemoryClient {
async createMemory(
content: string,
metadata?: Record<string, unknown>,
metadata?: Record<string, string | number | boolean | string[]>,
): Promise<{ id: string; status: string; namespace: string }> {
try {
const result = await this.client.add(this.namespace, {

View file

@ -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")
})

View file

@ -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")

View file

@ -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(