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 a Neo4j graph database, permanently deleting the connection when it's no longer needed or incorrect.

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

  • Main handler logic for the delete_connection tool: validates arguments using isDeleteConnectionArgs and calls neo4j.deleteRelationship to perform the deletion.
    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),
          },
        ],
      };
  • Core implementation in Neo4jClient that executes the Cypher query to delete the specific relationship between two memory 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];
    }
  • Tool registration defining the name, description, and JSON input schema for the MCP protocol.
      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'],
      },
    },
  • TypeScript interface defining the expected arguments for delete_connection.
    export interface DeleteConnectionArgs {
      fromMemoryId: number;
      toMemoryId: number;
      type: string;
    }
  • Type guard function for validating delete_connection arguments before execution.
    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'
      );
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates the destructive nature ('permanently removes') and irreversible consequence ('use with caution'), which are critical for a deletion operation. It doesn't mention authentication requirements, rate limits, or error conditions, but covers the most important behavioral aspect for this type of tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise - a single sentence that communicates the core purpose upfront, followed by a crucial cautionary note. Every word earns its place, with no redundancy or unnecessary elaboration. The structure is front-loaded with the primary action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive operation with no annotations and no output schema, the description provides adequate context about the permanent nature of the action. It could benefit from mentioning what happens after deletion (e.g., whether it returns confirmation) or error scenarios, but given the straightforward nature of the operation and complete parameter documentation, it's reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema (it doesn't explain the meaning of 'connection' or provide additional context about the parameters). This meets the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Delete a specific connection') and resource ('between two memories'), distinguishing it from sibling tools like delete_memory (which deletes memories themselves) and update_connection (which modifies rather than removes connections). The verb+resource combination is precise and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance through the cautionary note ('use with caution - this permanently removes the relationship'), suggesting this should be used when permanent removal is intended. However, it doesn't explicitly state when to use this versus alternatives like update_connection for modifying relationships or when deletion is preferred over other operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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