upsert_memory_node
Create or update memory nodes in a semantic graph to represent concepts, files, symbols, or notes with auto-generated embeddings for linking and retrieval.
Instructions
Create or update a memory node in the linking graph. Nodes represent concepts, files, symbols, or notes with auto-generated embeddings. If a node with the same label and type exists, it updates content and increments access count. Returns the node ID for use in create_relation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Node type: concept (abstract ideas), file (source files), symbol (functions/classes), note (free-form). | |
| label | Yes | Short identifier for the node. Used for deduplication with type. | |
| content | Yes | Detailed content for the node. Used for embedding generation. | |
| metadata | No | Optional key-value metadata pairs. |
Implementation Reference
- src/tools/memory-tools.ts:59-69 (handler)The `toolUpsertMemoryNode` function wraps the `upsertNode` core logic, executing the upsert and returning a formatted summary of the operation and graph state.
export async function toolUpsertMemoryNode(options: UpsertMemoryNodeOptions): Promise<string> { const node = await upsertNode(options.rootDir, options.type, options.label, options.content, options.metadata); const stats = await getGraphStats(options.rootDir); return [ `✅ Memory node upserted: ${node.label}`, ` ID: ${node.id}`, ` Type: ${node.type}`, ` Access count: ${node.accessCount}`, `\nGraph: ${stats.nodes} nodes, ${stats.edges} edges`, ].join("\n"); } - src/tools/memory-tools.ts:7-13 (schema)The `UpsertMemoryNodeOptions` interface defines the input structure required for the `upsert_memory_node` tool.
export interface UpsertMemoryNodeOptions { rootDir: string; type: NodeType; label: string; content: string; metadata?: Record<string, string>; }