delete_connection
Remove a specific relationship between two stored memories in the Neo4j graph database, permanently deleting the connection based on source ID, target ID, and relationship type.
Instructions
Delete a specific connection between two memories (use with caution - this permanently removes the relationship)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fromMemoryId | Yes | ID of the source memory | |
| toMemoryId | Yes | ID of the target memory | |
| type | Yes | Exact relationship type to delete (e.g. WORKS_AT, KNOWS, MANAGES) |
Implementation Reference
- src/handlers/index.ts:280-293 (handler)The main handler logic for the 'delete_connection' tool within the handleToolCall switch statement. Validates arguments using isDeleteConnectionArgs and executes the deletion via Neo4jClient.case 'delete_connection': { if (!isDeleteConnectionArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid delete_connection arguments'); } const result = await neo4j.deleteRelationship(args.fromMemoryId, args.toMemoryId, args.type); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/tools/definitions.ts:151-172 (schema)MCP tool registration and input schema definition for 'delete_connection', exported in the tools array.{ name: 'delete_connection', description: 'Delete a specific connection between two memories (use with caution - this permanently removes the relationship)', inputSchema: { type: 'object', properties: { fromMemoryId: { type: 'number', description: 'ID of the source memory', }, toMemoryId: { type: 'number', description: 'ID of the target memory', }, type: { type: 'string', description: 'Exact relationship type to delete (e.g. WORKS_AT, KNOWS, MANAGES)', }, }, required: ['fromMemoryId', 'toMemoryId', 'type'], }, },
- src/neo4j-client.ts:128-140 (helper)Neo4jClient method that performs the actual Cypher query to delete the relationship between two nodes.async deleteRelationship(fromNodeId: number, toNodeId: number, relationType: string): Promise<any> { const result = await this.executeQuery( `MATCH (a)-[r:${relationType}]->(b) WHERE id(a) = $fromId AND id(b) = $toId DELETE r RETURN count(r) as deletedCount`, { fromId: neo4j.int(fromNodeId), toId: neo4j.int(toNodeId), } ); return result[0]; }
- src/types.ts:45-49 (schema)TypeScript interface defining the expected arguments for delete_connection.export interface DeleteConnectionArgs { fromMemoryId: number; toMemoryId: number; type: string; }
- src/types.ts:104-113 (schema)Type guard function used to validate delete_connection arguments in the handler.export function isDeleteConnectionArgs(args: unknown): args is DeleteConnectionArgs { return ( typeof args === 'object' && args !== null && typeof (args as DeleteConnectionArgs).fromMemoryId === 'number' && typeof (args as DeleteConnectionArgs).toMemoryId === 'number' && typeof (args as DeleteConnectionArgs).type === 'string' ); }