store_memento
Store persistent knowledge like solutions, errors, and patterns with metadata and tags for reliable long-term retrieval across all sessions.
Instructions
Store a new memento with context and metadata.
Required: type, title, content. Optional: id, tags, importance (0-1), context.
USE FOR: Long-term knowledge that should survive across ALL sessions. DO NOT USE FOR: Temporary session state or project-specific context.
LIMITS:
title: max 500 characters
content: max 50KB (50,000 characters)
tags: max 50 tags, 100 chars each
id: if provided, must be unique string identifier
TAGGING BEST PRACTICE:
Always include acronyms AS TAGS (e.g., tags=["jwt", "auth"])
Fuzzy search struggles with acronyms in content
Tags provide exact match fallback for reliable retrieval
Types: solution, problem, error, fix, task, code_pattern, technology, command, file_context, workflow, project, general, conversation
Note: decision is not a standalone type — use type="general" with tags=["decision", "architecture"].
Note: pattern is not a standalone type — use type="code_pattern".
EXAMPLES:
store_memento(type="solution", title="Fixed Redis timeout", content="Increased timeout to 30s...", tags=["redis"], importance=0.8)
store_memento(type="error", title="OAuth2 auth failure", content="Error details...", tags=["auth", "oauth2"], id="custom-error-123")
Returns memory_id. Use create_memento_relationship to link related memories.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Type of memory to store | |
| id | No | Optional memory ID (if not provided, a UUID will be generated automatically) | |
| title | Yes | Short descriptive title for the memory | |
| content | Yes | Detailed content of the memory | |
| summary | No | Optional brief summary of the memory | |
| tags | No | Tags to categorize the memory | |
| importance | No | Importance score (0.0-1.0) | |
| context | No | Context information for the memory |
Implementation Reference
- src/memento/tools/memory_tools.py:26-99 (handler)The handle_store_memento function is the handler implementation for the store_memento MCP tool. It validates the input, manages memory IDs (generating a UUID if none is provided), creates a Memory object, and persists it in the SQLite database.
async def handle_store_memento( memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any] ) -> CallToolResult: """Handle store_memory tool call. Args: memory_db: Database instance for memory operations arguments: Tool arguments from MCP call containing: - type: Memory type (solution, problem, error, etc.) - title: Short descriptive title - content: Detailed content - summary: Optional brief summary - tags: Optional list of tags - importance: Optional importance score (0.0-1.0) - context: Optional context information - id: Optional memory ID (if not provided, one will be generated) Returns: CallToolResult with memory ID on success or error message on failure """ # Validate input arguments validate_memory_input(arguments) # Handle memory ID: generate or validate if "id" in arguments: # User provided an ID (might be empty or whitespace) memory_id = arguments["id"] # Strip whitespace and validate if not isinstance(memory_id, str): raise ValidationError("Memory ID must be a string") memory_id = memory_id.strip() if not memory_id: raise ValidationError( "Memory ID must be a non-empty string after removing whitespace" ) # Check if memory with this ID already exists existing = await memory_db.get_memory_by_id(memory_id) if existing: raise ValidationError(f"Memory with ID '{memory_id}' already exists") else: # Generate new UUID memory_id = str(uuid.uuid4()) # Extract context if provided context = None if "context" in arguments: context = MemoryContext(**arguments["context"]) # Create memory object with ID memory = Memory( id=memory_id, type=MemoryType(arguments["type"]), title=arguments["title"], content=arguments["content"], summary=arguments.get("summary"), tags=arguments.get("tags", []), importance=arguments.get("importance", 0.5), context=context, ) # Store in database stored_memory = await memory_db.store_memory(memory) return CallToolResult( content=[ TextContent( type="text", text=f"Memory stored successfully with ID: {stored_memory.id}", ) ] )