delete_relations
Remove specified relationships between stored entities while preserving the entities themselves in the Memento memory server.
Instructions
Remove specified relations between entities without deleting the entities themselves.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes | Array of relations to delete. |
Implementation Reference
- src/server.js:136-139 (handler)Handler function that invokes the knowledge graph manager's deleteRelations method and returns a textual success confirmation.async ({ relations }) => { await this.#knowledgeGraphManager.deleteRelations(relations); return { content: [{ type: 'text', text: 'Relations deleted' }] }; }
- src/server.js:129-135 (schema)Zod schema validating the input as an array of relations, each with 'from', 'to', and 'relationType' string fields.{ relations: z.array(z.object({ from: z.string().describe('Source entity name.'), to: z.string().describe('Target entity name.'), relationType: z.string().describe('Type of the relation to remove.') })).describe('Array of relations to delete.') },
- src/server.js:126-140 (registration)MCP server tool registration call for 'delete_relations', including description, input schema, and handler.this.tool( 'delete_relations', 'Remove specified relations between entities without deleting the entities themselves.', { relations: z.array(z.object({ from: z.string().describe('Source entity name.'), to: z.string().describe('Target entity name.'), relationType: z.string().describe('Type of the relation to remove.') })).describe('Array of relations to delete.') }, async ({ relations }) => { await this.#knowledgeGraphManager.deleteRelations(relations); return { content: [{ type: 'text', text: 'Relations deleted' }] }; } );
- src/sqlite/graph-repo.js:158-168 (helper)SQLite GraphRepository implementation of deleteRelations: iterates relations, gets entity IDs, executes DELETE SQL if both entities exist.async deleteRelations(relations) { for (const relation of relations) { const fromId = await this.getEntityId(relation.from); const toId = await this.getEntityId(relation.to); if (!fromId || !toId) continue; await this.db.run( `DELETE FROM relations WHERE from_id = ? AND to_id = ? AND relationType = ?`, [fromId, toId, relation.relationType] ); } }
- src/postgres/graph-repo.js:259-276 (helper)PostgreSQL GraphRepository implementation of deleteRelations: similar iteration, ID resolution, and DELETE query using parameterized query.async deleteRelations(relations) { for (const relation of relations) { const fromId = await this.getEntityId(relation.from); const toId = await this.getEntityId(relation.to); if (!fromId || !toId) { continue; } await this.#query( `DELETE FROM relations WHERE from_id = $1 AND to_id = $2 AND relationtype = $3`, [ fromId, toId, relation.relationType ] ); } }