Skip to main content
Glama
knowall-ai

Neo4j Agent Memory MCP Server

by knowall-ai

create_connection

Establish relationships between stored memories in a Neo4j graph database to create semantic connections with customizable types and metadata for AI agent knowledge organization.

Instructions

Create a connection between two memories (its good to have connected memories)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromMemoryIdYesID of the source memory
toMemoryIdYesID of the target memory
typeYesRelationship type such as KNOWS, WORKS_ON, LIVES_IN, HAS_SKILL, PARTICIPATES_IN
propertiesNoOptional relationship metadata (e.g. {since: "2023-01", role: "Manager", status: "active"})

Implementation Reference

  • The main handler logic for the 'create_connection' tool. Validates input arguments using isCreateConnectionArgs and executes neo4j.createRelationship to create a relationship between two memories.
    case 'create_connection': {
      if (!isCreateConnectionArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid create_connection arguments');
      }
      
      const result = await neo4j.createRelationship(
        args.fromMemoryId,
        args.toMemoryId,
        args.type,
        args.properties || { created_at: new Date().toISOString() }
      );
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Registration of the 'create_connection' tool in the tools array, including name, description, and input schema definition.
    {
      name: 'create_connection',
      description: 'Create a connection between two memories (its good to have connected memories)',
      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: 'Relationship type such as KNOWS, WORKS_ON, LIVES_IN, HAS_SKILL, PARTICIPATES_IN',
          },
          properties: {
            type: 'object',
            description: 'Optional relationship metadata (e.g. {since: "2023-01", role: "Manager", status: "active"})',
            additionalProperties: true,
          },
        },
        required: ['fromMemoryId', 'toMemoryId', 'type'],
      },
    },
  • TypeScript interface and validation function for CreateConnectionArgs used in the handler for input validation.
    export interface CreateConnectionArgs {
      fromMemoryId: number;
      toMemoryId: number;
      type: string;
      properties?: Record<string, any>;
    }
    
    export interface UpdateMemoryArgs {
      nodeId: number;
      properties: Record<string, any>;
    }
    
    export interface UpdateConnectionArgs {
      fromMemoryId: number;
      toMemoryId: number;
      type: string;
      properties: Record<string, any>;
    }
    
    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'
      );
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'Create' implying a write operation but doesn't disclose behavioral traits like permissions needed, whether connections are reversible, error conditions, or rate limits. The phrase 'its good to have connected memories' adds minimal context without practical details.

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

Conciseness3/5

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

The description is brief with one sentence, but 'its good to have connected memories' is redundant and doesn't add operational value. It could be more front-loaded with essential usage information, though it avoids excessive verbosity.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a mutation tool. It lacks details on what happens upon creation, error handling, or return values, leaving significant gaps for an AI agent to understand the tool's behavior fully.

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 parameters are well-documented in the schema. The description adds no additional meaning beyond the schema, such as explaining relationship types or property usage. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb 'Create' and resource 'connection between two memories', making the purpose understandable. However, it doesn't distinguish this from sibling tools like 'update_connection' or specify what makes a connection 'good' versus just possible.

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

Usage Guidelines2/5

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

The description provides minimal guidance with 'its good to have connected memories', which is vague and doesn't specify when to use this tool versus alternatives like 'update_connection' or prerequisites. No explicit when/when-not or alternative tool references are included.

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