update_connection
Modify properties of relationships between stored memories in a Neo4j graph database, such as updating status or dates for connections like WORKS_AT or KNOWS.
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 for the 'update_connection' tool: validates args and delegates to Neo4jClient.updateRelationshipcase '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/types.ts:34-39 (schema)TypeScript interface defining input shape for update_connection argumentsexport interface UpdateConnectionArgs { fromMemoryId: number; toMemoryId: number; type: string; properties: Record<string, any>; }
- src/types.ts:86-95 (schema)Runtime type guard/validator for UpdateConnectionArgs used in the handlerexport 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/tools/definitions.ts:110-136 (registration)MCP tool definition and registration in the tools array, including name, description, and JSON schema{ 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/neo4j-client.ts:101-114 (helper)Core implementation of relationship update using Neo4j Cypher query (MATCH, SET, RETURN)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]; }