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"] } } ] }; });

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