diff --git a/apps/docs/supermemory-mcp/mcp.mdx b/apps/docs/supermemory-mcp/mcp.mdx index c7f5f6dc..2b8be168 100644 --- a/apps/docs/supermemory-mcp/mcp.mdx +++ b/apps/docs/supermemory-mcp/mcp.mdx @@ -48,7 +48,7 @@ Your assistant chooses these tools automatically. Use this table when you need t | --- | --- | --- | --- | | `search_memory` | Semantic recall from one space | `query` (required), `containerTag` | Matching memories | | `get_profile` | Stable and recent profile context for one space | `containerTag` | Profile facts | -| `add_memory` | Save information or forget outdated information | `content` (required), `action` (`save` or `forget`), `containerTag` | Save or forget confirmation | +| `add_memory` | Save information or forget outdated information | `content` (required), `action` (`save` or `forget`), `containerTag`, optional `metadata` | Save or forget confirmation | | `list_documents` | Browse stored source documents and their summaries | `page`, `limit`, `containerTag` | Document IDs, titles, types, status, dates, and summaries | | `get_document` | Read the available content of one document | `documentId` (required) | Document metadata, summary, and available content | | `list_memories` | Browse recent extracted memory entries and their source document IDs | `page`, `limit`, `containerTag` | Memory IDs, text, versions, and source document IDs | diff --git a/apps/mcp/e2e/space-scope.test.ts b/apps/mcp/e2e/space-scope.test.ts index 3b5c013b..ff1e0ce5 100644 --- a/apps/mcp/e2e/space-scope.test.ts +++ b/apps/mcp/e2e/space-scope.test.ts @@ -22,12 +22,14 @@ describeWithAuth("MCP - space scoping", () => { const plainTools = (await plain.client.listTools()).tools expect(propsOf(plainTools, "add_memory")).toHaveProperty("containerTag") + expect(propsOf(plainTools, "add_memory")).toHaveProperty("metadata") expect(propsOf(plainTools, "search_memory")).toHaveProperty( "containerTag", ) expect(propsOf(plainTools, "get_profile")).toHaveProperty("containerTag") expect(propsOf(scopedTools, "add_memory")).toHaveProperty("containerTag") + expect(propsOf(scopedTools, "add_memory")).toHaveProperty("metadata") expect(propsOf(scopedTools, "search_memory")).toHaveProperty( "containerTag", ) diff --git a/apps/mcp/src/server/client/index.ts b/apps/mcp/src/server/client/index.ts index 1b575e15..3b4f402f 100644 --- a/apps/mcp/src/server/client/index.ts +++ b/apps/mcp/src/server/client/index.ts @@ -161,12 +161,13 @@ export class SupermemoryClient { async createMemory( content: string, + metadata?: Record, ): Promise<{ id: string; status: string; containerTag: string }> { try { const result = await this.client.add({ content, containerTag: this.containerTag, - metadata: { sm_source: MCP_SOURCE }, + metadata: { ...metadata, sm_source: MCP_SOURCE }, }) return { id: result.id, diff --git a/apps/mcp/src/server/tools/add-memory.ts b/apps/mcp/src/server/tools/add-memory.ts index c708deb5..23c729dd 100644 --- a/apps/mcp/src/server/tools/add-memory.ts +++ b/apps/mcp/src/server/tools/add-memory.ts @@ -12,6 +12,7 @@ export function register(deps: ToolDeps) { .describe("The memory content to save or forget"), action: z.enum(["save", "forget"]).optional().default("save"), containerTag: optionalContainerTagSchema, + metadata: z.record(z.string(), z.unknown()).optional().describe("Optional metadata to attach to the saved memory"), }) deps.server.registerTool( @@ -42,7 +43,7 @@ export function register(deps: ToolDeps) { } } - const result = await client.createMemory(args.content) + const result = await client.createMemory(args.content, args.metadata) const message = `Memory saved (ID: ${result.id}, space: ${result.containerTag})` const structuredContent: AddMemoryOutput = { action: "save",