update_connection
Modify properties of relationships between stored memories in a Neo4j graph database to reflect changes in connections like status updates or temporal attributes.
Instructions
Update properties of an existing connection between memories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fromMemoryId | Yes | ID of the source memory | |
| toMemoryId | Yes | ID of the target memory | |
| type | Yes | Relationship type to identify which connection to update (e.g. WORKS_AT, KNOWS, MANAGES) | |
| properties | Yes | Properties to update/add (e.g. {status: "completed", end_date: "2024-01"}) |
Implementation Reference
- src/handlers/index.ts:250-263 (handler)Main handler logic for the 'update_connection' tool: validates arguments and calls Neo4jClient.updateRelationship to perform the update.case 'update_connection': { if (!isUpdateConnectionArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid update_connection arguments'); } const result = await neo4j.updateRelationship(args.fromMemoryId, args.toMemoryId, args.type, args.properties); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/tools/definitions.ts:110-136 (registration)Tool registration definition including name, description, and input schema for MCP.{ name: 'update_connection', description: 'Update properties of an existing connection between 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 to identify which connection to update (e.g. WORKS_AT, KNOWS, MANAGES)', }, properties: { type: 'object', description: 'Properties to update/add (e.g. {status: "completed", end_date: "2024-01"})', additionalProperties: true, }, }, required: ['fromMemoryId', 'toMemoryId', 'type', 'properties'], }, },
- src/types.ts:34-39 (schema)TypeScript interface defining the input arguments for update_connection.export interface UpdateConnectionArgs { fromMemoryId: number; toMemoryId: number; type: string; properties: Record<string, any>; }
- src/types.ts:86-95 (schema)Runtime type guard function used to validate update_connection arguments in the handler.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' ); }
- src/neo4j-client.ts:101-114 (helper)Neo4jClient method implementing the relationship update logic via Cypher query, called by the handler.async updateRelationship(fromNodeId: number, toNodeId: number, relationType: string, properties: Neo4jQueryParams): Promise<any> { const result = await this.executeQuery( `MATCH (a)-[r:${relationType}]->(b) WHERE id(a) = $fromId AND id(b) = $toId SET r += $props RETURN r as relationship`, { fromId: neo4j.int(fromNodeId), toId: neo4j.int(toNodeId), props: properties, } ); return result[0]; }