delete_solution
Permanently delete saved entries that are incorrect or irrelevant, freeing memory space without option to undo.
Instructions
Permanently delete a saved entry.
Use this to remove entries that were saved incorrectly, contain wrong information that can't be fixed with correct_solution, or are no longer relevant. This cannot be undone.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entry_id | Yes | The id of the entry to delete. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/longmem/server.py:644-671 (handler)The delete_solution tool handler function. It receives an entry_id, calls the store's delete_solution, and returns a JSON response indicating success or failure.
@mcp.tool() async def delete_solution( entry_id: Annotated[ str, Field(description="The id of the entry to delete."), ], ) -> str: """ Permanently delete a saved entry. Use this to remove entries that were saved incorrectly, contain wrong information that can't be fixed with correct_solution, or are no longer relevant. This cannot be undone. """ try: store, *_ = await _get_deps() deleted = await store.delete_solution(entry_id) if not deleted: return json.dumps({"deleted": False, "error": f"Entry {entry_id!r} not found."}, indent=2) return json.dumps({ "deleted": True, "id": entry_id, "message": "Entry permanently deleted.", }, indent=2) except Exception as exc: return _db_error(exc) - src/longmem/server.py:645-649 (schema)The entry_id parameter definition with Field annotation describing it as 'The id of the entry to delete.'
async def delete_solution( entry_id: Annotated[ str, Field(description="The id of the entry to delete."), ], - src/longmem/server.py:644-644 (registration)Tool registration via @mcp.tool() decorator on the delete_solution async function.
@mcp.tool() - src/longmem/store.py:473-487 (helper)The store-level delete_solution method that actually performs the database deletion. Queries for the entry, deletes it if found, and also removes it from the FTS index if applicable.
async def delete_solution(self, entry_id: str) -> bool: """Delete an entry by id. Returns True if it existed, False if not found.""" sid = self._safe_id(entry_id) rows = await ( self._table.query() .where(f"id = '{sid}'") .limit(1) .to_list() ) if not rows: return False await self._table.delete(f"id = '{sid}'") if self._fts: await self._fts.remove(entry_id) return True