Skip to main content
Glama
knowall-ai

Neo4j Agent Memory MCP Server

by knowall-ai

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
NameRequiredDescriptionDefault
fromMemoryIdYesID of the source memory
toMemoryIdYesID of the target memory
typeYesExact relationship type to delete (e.g. WORKS_AT, KNOWS, MANAGES)

Implementation Reference

  • 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), }, ], }; }
  • 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'], }, },
  • 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]; }
  • TypeScript interface defining the expected arguments for delete_connection.
    export interface DeleteConnectionArgs { fromMemoryId: number; toMemoryId: number; type: string; }
  • 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' ); }

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/knowall-ai/mcp-neo4j-agent-memory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server