mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-26 06:04:08 +00:00
fix(mcp): share the v5 metadata schema between add_memory and save_memory
This commit is contained in:
parent
cec177a7a3
commit
a954a818c0
2 changed files with 12 additions and 12 deletions
|
|
@ -10,6 +10,15 @@ import { forgetMemory } from "./forget-memory"
|
|||
import { addMemoryOutputSchema, type AddMemoryOutput } from "./output-schemas"
|
||||
import { textContent, type ToolDeps } from "./types"
|
||||
|
||||
// v5 metadata values are flat: string, number, boolean or string list.
|
||||
export const memoryMetadataSchema = 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")
|
||||
|
||||
export function register(deps: ToolDeps) {
|
||||
const inputSchema = z.object({
|
||||
content: z
|
||||
|
|
@ -25,14 +34,7 @@ export function register(deps: ToolDeps) {
|
|||
),
|
||||
namespace: optionalNamespaceSchema,
|
||||
...legacyNamespaceInput,
|
||||
// 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"),
|
||||
metadata: memoryMetadataSchema,
|
||||
})
|
||||
|
||||
deps.server.registerTool(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { saveSuccessViewSchema, type ViewMessage } from "../../shared/types"
|
|||
import { appResultMeta, appToolMeta } from "../app-metadata"
|
||||
import { namespaceSchema } from "../namespace"
|
||||
import { legacyNamespaceInput, namespaceArg, withLegacyView } from "./compat"
|
||||
import { memoryMetadataSchema } from "./add-memory"
|
||||
import { ADDITIVE_MEMORY_TOOL_ANNOTATIONS } from "./annotations"
|
||||
import { textContent, type ToolDeps } from "./types"
|
||||
|
||||
|
|
@ -13,10 +14,7 @@ export function register(deps: ToolDeps) {
|
|||
description: "Save content to memory",
|
||||
inputSchema: z.object({
|
||||
content: z.string().min(1),
|
||||
metadata: z
|
||||
.record(z.string(), z.unknown())
|
||||
.optional()
|
||||
.describe("Optional key-value metadata to attach to the memory"),
|
||||
metadata: memoryMetadataSchema,
|
||||
namespace: namespaceSchema.optional(),
|
||||
...legacyNamespaceInput,
|
||||
viewId: z.string().uuid().optional(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue