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' ); }

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