Skip to main content
Glama
knowall-ai

Neo4j Agent Memory MCP Server

by knowall-ai

delete_memory

Permanently remove a stored memory and all its connections from the Neo4j graph database. Use this tool to delete specific agent memories and their relationships.

Instructions

Delete a memory and all its connections (use with caution - this permanently removes the memory and all its connections)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesID of the memory to delete

Implementation Reference

  • Handler for the 'delete_memory' tool. Validates arguments using isDeleteMemoryArgs, calls neo4j.deleteNode to delete the node and its connections, and returns the result as JSON.
    case 'delete_memory': {
      if (!isDeleteMemoryArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid delete_memory arguments');
      }
      const result = await neo4j.deleteNode(args.nodeId);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Neo4jClient method that performs DETACH DELETE on the node by ID, removing it and all connected relationships, returning the count of deleted nodes.
    async deleteNode(nodeId: number): Promise<any> {
      const result = await this.executeQuery(
        `MATCH (n) WHERE id(n) = $nodeId
         DETACH DELETE n
         RETURN count(n) as deletedCount`,
        {
          nodeId: neo4j.int(nodeId),
        }
      );
      return result[0];
    }
  • Tool definition including name, description, and input schema for MCP tool registration.
    {
      name: 'delete_memory',
      description: 'Delete a memory and all its connections (use with caution - this permanently removes the memory and all its connections)',
      inputSchema: {
        type: 'object',
        properties: {
          nodeId: {
            type: 'number',
            description: 'ID of the memory to delete',
          },
        },
        required: ['nodeId'],
      },
    },
  • TypeScript interface and runtime validator function for DeleteMemoryArgs used in handler validation.
    export interface DeleteMemoryArgs {
      nodeId: number;
    }
    
    export interface DeleteConnectionArgs {
      fromMemoryId: number;
      toMemoryId: number;
      type: string;
    }
    
    export interface ListMemoryLabelsArgs {
      // No arguments needed for this tool
    }
    
    export function isCreateMemoryArgs(args: unknown): args is CreateMemoryArgs {
      return typeof args === 'object' && args !== null && typeof (args as CreateMemoryArgs).label === 'string' && typeof (args as CreateMemoryArgs).properties === 'object';
    }
    
    export function isSearchMemoriesArgs(args: unknown): args is SearchMemoriesArgs {
      if (typeof args !== 'object' || args === null) return false;
      const searchArgs = args as SearchMemoriesArgs;
      if (searchArgs.query !== undefined && typeof searchArgs.query !== 'string') return false;
      if (searchArgs.since_date !== undefined && typeof searchArgs.since_date !== 'string') return false;
      return true;
    }
    
    export function isCreateConnectionArgs(args: unknown): args is CreateConnectionArgs {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof (args as CreateConnectionArgs).fromMemoryId === 'number' &&
        typeof (args as CreateConnectionArgs).toMemoryId === 'number' &&
        typeof (args as CreateConnectionArgs).type === 'string'
      );
    }
    
    export function isUpdateMemoryArgs(args: unknown): args is UpdateMemoryArgs {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof (args as UpdateMemoryArgs).nodeId === 'number' &&
        typeof (args as UpdateMemoryArgs).properties === 'object'
      );
    }
    
    export function isUpdateConnectionArgs(args: unknown): args is UpdateConnectionArgs {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof (args as UpdateConnectionArgs).fromMemoryId === 'number' &&
        typeof (args as UpdateConnectionArgs).toMemoryId === 'number' &&
        typeof (args as UpdateConnectionArgs).type === 'string' &&
        typeof (args as UpdateConnectionArgs).properties === 'object'
      );
    }
    
    export function isDeleteMemoryArgs(args: unknown): args is DeleteMemoryArgs {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof (args as DeleteMemoryArgs).nodeId === 'number'
      );
    }
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'), scope ('all its connections'), and caution needed. However, it lacks details on permissions, error handling, or confirmation steps, leaving some behavioral aspects unspecified.

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 front-loaded with the core action and includes a necessary warning in a single, efficient sentence. Every word earns its place, with no redundancy or unnecessary elaboration, making it highly concise and well-structured.

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?

Given the tool's complexity (destructive operation with no annotations or output schema), the description is mostly complete by emphasizing permanence and scope. However, it could improve by mentioning potential side effects (e.g., impact on connected data) or success/error responses, leaving minor gaps in full context.

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?

The input schema has 100% description coverage, with 'nodeId' clearly documented as 'ID of the memory to delete.' The description does not add any additional meaning or context about the parameter beyond what the schema provides, so it meets the baseline for high schema coverage without extra value.

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 memory and all its connections') and distinguishes it from sibling tools like 'delete_connection' (which only deletes connections) and 'update_memory' (which modifies rather than removes). The verb 'delete' is precise and the resource 'memory' is explicitly identified.

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

Usage Guidelines4/5

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

The description provides clear context with the warning 'use with caution - this permanently removes the memory and all its connections,' which implies this tool should be used for irreversible deletion. However, it does not explicitly state when to use alternatives like 'update_memory' for modifications or 'delete_connection' for partial removal, missing explicit sibling differentiation.

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