Skip to main content
Glama

update_memory

Modify existing memory data, including text, bucket, relationships, and reference details, in the Memory Box MCP Server to ensure accurate and updated information storage and retrieval.

Instructions

Update an existing memory including text, bucket, and relationships

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_idNoMove memory to different bucket
memory_idYesThe ID of the memory to update
raw_contentNoNew raw content for the memory
reference_dataNoUpdated reference data (same structure as save_memory)
source_typeNoUpdate source type
textNoNew text content for the memory

Implementation Reference

  • MCP tool handler implementation for 'update_memory': parses input arguments, validates memory_id, constructs updates object, calls memoryBoxClient.updateMemory, and returns formatted text response.
    case "update_memory": {
      const memoryId = request.params.arguments?.memory_id;
    
      if (!memoryId) {
        throw new McpError(ErrorCode.InvalidParams, "Memory ID is required");
      }
    
      const updates = {
        text: request.params.arguments?.text ? String(request.params.arguments.text) : undefined,
        rawContent: request.params.arguments?.raw_content ? String(request.params.arguments.raw_content) : undefined,
        bucketId: request.params.arguments?.bucket_id ? String(request.params.arguments.bucket_id) : undefined,
        sourceType: request.params.arguments?.source_type ? String(request.params.arguments.source_type) : undefined,
        referenceData: request.params.arguments?.reference_data
      };
    
      // Update the memory
      const result = await memoryBoxClient.updateMemory(Number(memoryId), updates);
    
      let responseText = `Memory ${memoryId} updated successfully!`;
      
      if (result.processing_status === "requires_processing") {
        responseText += "\n\nNote: The memory is being reprocessed and will be available shortly.";
      } else if (result.text) {
        responseText += `\n\nUpdated content:\n${result.text}`;
      }
    
      return {
        content: [{
          type: "text",
          text: responseText
        }]
      };
    }
  • Input schema definition for the 'update_memory' tool, defining parameters like memory_id (required), text, raw_content, etc., returned in listTools response.
    name: "update_memory",
    description: "Update an existing memory including text, bucket, and relationships",
    inputSchema: {
      type: "object",
      properties: {
        memory_id: {
          type: "integer",
          description: "The ID of the memory to update"
        },
        text: {
          type: "string",
          description: "New text content for the memory"
        },
        raw_content: {
          type: "string",
          description: "New raw content for the memory"
        },
        bucket_id: {
          type: "string",
          description: "Move memory to different bucket"
        },
        source_type: {
          type: "string",
          description: "Update source type"
        },
        reference_data: {
          type: "object",
          description: "Updated reference data (same structure as save_memory)"
        }
      },
      required: ["memory_id"]
    }
  • MemoryBoxClient.updateMemory helper method: validates updates, builds request body, performs PUT request to API endpoint /api/v2/memory/{memoryId}, handles errors.
    async updateMemory(
      memoryId: number,
      updates: {
        text?: string;
        rawContent?: string;
        bucketId?: string;
        sourceType?: string;
        referenceData?: any;
      }
    ): Promise<any> {
      try {
        // Validate that at least one update field is provided
        if (!updates.text && !updates.rawContent && !updates.bucketId && 
            !updates.sourceType && !updates.referenceData) {
          throw new McpError(
            ErrorCode.InvalidParams,
            "At least one of text, raw_content, bucket_id, source_type, or reference_data must be provided"
          );
        }
    
        const requestBody: any = {};
        
        if (updates.text !== undefined) {
          requestBody.text = updates.text;
        }
        
        if (updates.rawContent !== undefined) {
          requestBody.raw_content = updates.rawContent;
        }
        
        if (updates.bucketId !== undefined) {
          requestBody.bucketId = updates.bucketId;
        }
        
        if (updates.sourceType !== undefined) {
          requestBody.source_type = updates.sourceType;
        }
        
        if (updates.referenceData !== undefined) {
          requestBody.reference_data = updates.referenceData;
        }
    
        const response = await axios.put(
          `${this.baseUrl}/api/v2/memory/${memoryId}`,
          requestBody,
          {
            headers: {
              "Content-Type": "application/json",
              "Authorization": `Bearer ${this.token}`
            }
          }
        );
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new McpError(
            ErrorCode.InternalError,
            `Failed to update memory: ${error.response?.data?.detail || error.message}`
          );
        }
        throw error;
      }
    }
  • src/index.ts:543-866 (registration)
    Tool registration via listTools handler: includes 'update_memory' in the tools list with its schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "save_memory",
            description: "Save a memory to Memory Box",
            inputSchema: {
              type: "object",
              properties: {
                text: {
                  type: "string",
                  description: "The memory content to save (either text OR raw_content required)"
                },
                raw_content: {
                  type: "string",
                  description: "Raw content for processing (alternative to text)"
                },
                bucket_id: {
                  type: "string",
                  description: `The bucket to save the memory to (default: "${DEFAULT_BUCKET}")`
                },
                source_type: {
                  type: "string",
                  description: "Type of memory source (default: 'llm_plugin')"
                },
                reference_data: {
                  type: "object",
                  description: "Structured metadata for memory storage",
                  properties: {
                    source: {
                      type: "object",
                      required: ["platform"],
                      properties: {
                        platform: { type: "string", description: "Platform identifier (required)" },
                        type: { type: "string", description: "Source type" },
                        version: { type: "string", description: "Version info" },
                        url: { type: "string", description: "Source URL" },
                        title: { type: "string", description: "Source title" },
                        additional_metadata: { type: "object", description: "Extra metadata" }
                      }
                    },
                    context: {
                      type: "object",
                      properties: {
                        related_memories: { type: "array", items: { type: "object" }, description: "Related memory references" },
                        conversation_id: { type: "string", description: "Conversation identifier" },
                        message_id: { type: "string", description: "Message identifier" }
                      }
                    },
                    content_context: {
                      type: "object",
                      properties: {
                        url: { type: "string", description: "Content URL" },
                        title: { type: "string", description: "Content title" },
                        surrounding_text: { type: "string", description: "Context around selection" },
                        selected_text: { type: "string", description: "Selected text" },
                        additional_context: { type: "object", description: "Extra context" }
                      }
                    }
                  }
                }
              },
              required: ["text"]
            }
          },
          {
            name: "search_memories",
            description: "Search for memories using semantic search",
            inputSchema: {
              type: "object",
              properties: {
                query: {
                  type: "string",
                  description: "The search query (semantic search)"
                },
                bucket_id: {
                  type: "string",
                  description: "Filter to specific bucket"
                },
                source_type: {
                  type: "string",
                  description: "Filter by source type"
                },
                limit: {
                  type: "integer",
                  description: "Maximum number of results to return (1-100, default: 10)",
                  minimum: 1,
                  maximum: 100
                },
                offset: {
                  type: "integer",
                  description: "Number of results to skip for pagination (default: 0)",
                  minimum: 0
                },
                debug: {
                  type: "boolean",
                  description: "Include debug information in results (default: false)"
                },
                include_reference_data: {
                  type: "boolean",
                  description: "Include reference data in response (default: false)"
                },
                date_sort: {
                  type: "boolean",
                  description: "Sort semantic search results by date after similarity filtering (default: false)"
                },
                sort_order: {
                  type: "string",
                  description: "Sort order when date_sort is enabled (default: 'desc')",
                  enum: ["asc", "desc"]
                }
              },
              required: ["query"]
            }
          },
          {
            name: "get_all_memories",
            description: "Retrieve all memories with pagination support",
            inputSchema: {
              type: "object",
              properties: {
                all: {
                  type: "boolean",
                  description: "Get all memories (overrides pagination, default: false)"
                },
                bucket_id: {
                  type: "string",
                  description: "Filter to specific bucket"
                },
                source_type: {
                  type: "string",
                  description: "Filter by source type"
                },
                limit: {
                  type: "integer",
                  description: "Maximum number of results to return (1-100, default: 10)",
                  minimum: 1,
                  maximum: 100
                },
                offset: {
                  type: "integer",
                  description: "Number of results to skip for pagination (default: 0)",
                  minimum: 0
                },
                include_reference_data: {
                  type: "boolean",
                  description: "Include reference data in response (default: false)"
                },
                date_sort: {
                  type: "boolean",
                  description: "Sort results by date (default: false)"
                },
                sort_order: {
                  type: "string",
                  description: "Sort order (default: 'desc')",
                  enum: ["asc", "desc"]
                }
              }
            }
          },
          {
            name: "get_bucket_memories",
            description: "Get memories from a specific bucket",
            inputSchema: {
              type: "object",
              properties: {
                bucket_id: {
                  type: "string",
                  description: "The bucket to retrieve memories from"
                },
                limit: {
                  type: "integer",
                  description: "Maximum number of results to return (1-100, default: 10)",
                  minimum: 1,
                  maximum: 100
                },
                offset: {
                  type: "integer",
                  description: "Number of results to skip for pagination (default: 0)",
                  minimum: 0
                },
                include_reference_data: {
                  type: "boolean",
                  description: "Include reference data in response (default: false)"
                }
              },
              required: ["bucket_id"]
            }
          },
          {
            name: "get_related_memories",
            description: "Find semantically similar memories to a specific memory",
            inputSchema: {
              type: "object",
              properties: {
                memory_id: {
                  type: "integer",
                  description: "The ID of the memory to find related memories for"
                },
                min_similarity: {
                  type: "number",
                  description: "Minimum similarity threshold (0.0-1.0) for related memories (default: 0.7)"
                }
              },
              required: ["memory_id"]
            }
          },
          {
            name: "check_memory_status",
            description: "Check the processing status of a memory",
            inputSchema: {
              type: "object",
              properties: {
                memory_id: {
                  type: "integer",
                  description: "The ID of the memory to check status for"
                }
              },
              required: ["memory_id"]
            }
          },
          {
            name: "get_usage_stats",
            description: "Retrieve user usage statistics and plan information",
            inputSchema: {
              type: "object",
              properties: {
                // No specific parameters needed for this operation
              }
            }
          },
          {
            name: "get_buckets",
            description: "Retrieve a list of all available buckets",
            inputSchema: {
              type: "object",
              properties: {
                // No specific parameters needed for this operation
              }
            }
          },
          {
            name: "create_bucket",
            description: "Create a new bucket for organizing memories",
            inputSchema: {
              type: "object",
              properties: {
                bucket_name: {
                  type: "string",
                  description: "Name of the bucket to create"
                }
              },
              required: ["bucket_name"]
            }
          },
          {
            name: "delete_bucket",
            description: "Delete a bucket (empty by default, use force to delete with content)",
            inputSchema: {
              type: "object",
              properties: {
                bucket_name: {
                  type: "string",
                  description: "Name of the bucket to delete"
                },
                force: {
                  type: "boolean",
                  description: "Force deletion even if bucket contains memories (default: false)"
                }
              },
              required: ["bucket_name"]
            }
          },
          {
            name: "update_memory",
            description: "Update an existing memory including text, bucket, and relationships",
            inputSchema: {
              type: "object",
              properties: {
                memory_id: {
                  type: "integer",
                  description: "The ID of the memory to update"
                },
                text: {
                  type: "string",
                  description: "New text content for the memory"
                },
                raw_content: {
                  type: "string",
                  description: "New raw content for the memory"
                },
                bucket_id: {
                  type: "string",
                  description: "Move memory to different bucket"
                },
                source_type: {
                  type: "string",
                  description: "Update source type"
                },
                reference_data: {
                  type: "object",
                  description: "Updated reference data (same structure as save_memory)"
                }
              },
              required: ["memory_id"]
            }
          },
          {
            name: "delete_memory",
            description: "Delete a specific memory",
            inputSchema: {
              type: "object",
              properties: {
                memory_id: {
                  type: "integer",
                  description: "The ID of the memory to delete"
                }
              },
              required: ["memory_id"]
            }
          }
        ]
      };
    });
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states 'Update an existing memory' which implies mutation, but doesn't disclose permissions needed, whether changes are reversible, rate limits, or what happens to unspecified fields. The mention of 'relationships' hints at complexity but lacks operational details.

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?

Extremely concise single sentence with zero waste. Front-loaded with the core action ('Update an existing memory') followed by specific updatable elements. Every word contributes directly to understanding the tool's function.

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

Completeness2/5

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

For a mutation tool with 6 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what 'relationships' entail in 'reference_data', doesn't mention the required 'memory_id', and provides no information about return values or error conditions. The schema handles parameter documentation, but behavioral context is severely lacking.

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

Parameters3/5

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

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds marginal value by listing 'text, bucket, and relationships' which correspond to 'text', 'bucket_id', and 'reference_data' parameters, but doesn't provide additional syntax, format, or constraint details beyond what's in the schema descriptions.

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

Purpose4/5

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

The description clearly states the action ('Update') and resource ('an existing memory'), specifying what can be updated ('including text, bucket, and relationships'). It distinguishes from siblings like 'save_memory' (create) and 'delete_memory' (remove), but doesn't explicitly contrast with all alternatives.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives like 'save_memory' for creating new memories or 'delete_memory' for removal. It mentions updating 'relationships' but doesn't clarify when that's needed versus other tools. No explicit when-not-to-use or prerequisite information is provided.

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

Related 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/amotivv/memory-box-mcp'

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