Skip to content

Commit 95a9985

Browse files
authored
escape node label and rel type in memory server (#123)
1 parent 807d8ee commit 95a9985

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

servers/mcp-neo4j-memory/src/mcp_neo4j_memory/neo4j_memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async def create_entities(self, entities: List[Entity]) -> List[Entity]:
104104
WITH $entity as entity
105105
MERGE (e:Memory {{ name: entity.name }})
106106
SET e += entity {{ .type, .observations }}
107-
SET e:{entity.type}
107+
SET e:`{entity.type}`
108108
"""
109109
await self.driver.execute_query(query, {"entity": entity.model_dump()}, routing_control=RoutingControl.WRITE)
110110

@@ -119,7 +119,7 @@ async def create_relations(self, relations: List[Relation]) -> List[Relation]:
119119
MATCH (from:Memory),(to:Memory)
120120
WHERE from.name = relation.source
121121
AND to.name = relation.target
122-
MERGE (from)-[r:{relation.relationType}]->(to)
122+
MERGE (from)-[r:`{relation.relationType}`]->(to)
123123
"""
124124

125125
await self.driver.execute_query(
@@ -183,7 +183,7 @@ async def delete_relations(self, relations: List[Relation]) -> None:
183183
for relation in relations:
184184
query = f"""
185185
WITH $relation as relation
186-
MATCH (source:Memory)-[r:{relation.relationType}]->(target:Memory)
186+
MATCH (source:Memory)-[r:`{relation.relationType}`]->(target:Memory)
187187
WHERE source.name = relation.source
188188
AND target.name = relation.target
189189
DELETE r

0 commit comments

Comments
 (0)