Skip to main content
Glama

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
NameRequiredDescriptionDefault
typeYesNode type: concept (abstract ideas), file (source files), symbol (functions/classes), note (free-form).
labelYesShort identifier for the node. Used for deduplication with type.
contentYesDetailed content for the node. Used for embedding generation.
metadataNoOptional key-value metadata pairs.

Implementation Reference

  • 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");
    }
  • 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>;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full behavioral disclosure burden. It effectively explains the upsert logic (create vs update), deduplication key (label+type), auto-generated embeddings, and access count incrementing. Minor gap: lacks explicit mention of whether updates are destructive or if old versions persist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four tightly constructed sentences: (1) operation+resource, (2) node semantics+embeddings, (3) deduplication/update logic, (4) return value+workflow. Every sentence adds distinct value (purpose, behavior, mechanics, integration). No redundancy with schema definitions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the upsert complexity and lack of output schema, the description comprehensively covers the operational contract: input requirements, uniqueness semantics, mutation behavior, and output intent. Only minor gaps remain around error conditions and content size constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage (baseline 3), the description adds critical semantic context: it explains that label+type combination drives deduplication, content drives embeddings, and elaborates on the state change behavior (incrementing access count) that the schema doesn't convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses specific verbs 'Create or update' with clear resource 'memory node in the linking graph'. It distinguishes from siblings by defining nodes as representing specific concepts (files, symbols, notes) and explicitly mentioning the return value is 'for use in create_relation', delineating it from retrieval tools like search_memory_graph.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides clear workflow guidance by stating the return value (node ID) is intended 'for use in create_relation', establishing prerequisite relationships. However, it lacks explicit 'when not to use' guidance contrasting with retrieval siblings like retrieve_with_traversal or search_memory_graph.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ForLoopCodes/contextplus'

If you have feedback or need assistance with the MCP directory API, please join our Discord server