open_nodes
Retrieve specific entities from a knowledge graph by name to access stored user information across conversations.
Instructions
Open specific nodes in the knowledge graph by their names
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| names | Yes | An array of entity names to retrieve |
Implementation Reference
- The core implementation of the open_nodes tool, which retrieves entities and their relations from the SQLite database.
async def open_nodes(self, names: List[str]) -> Dict[str, List[Dict[str, Any]]]: """Retrieve specific nodes and their relations.""" async with self.pool.get_connection() as conn: sanitized_names = [sanitize_input(name) for name in names] placeholders = ','.join('?' * len(sanitized_names)) # Get entities cursor = await conn.execute( f"SELECT * FROM entities WHERE name IN ({placeholders})", sanitized_names ) rows = await cursor.fetchall() entities = [] for row in rows: entity = Entity( name=row['name'], entityType=row['entity_type'], observations=row['observations'].split(',') if row['observations'] else [] ) entities.append(entity.to_dict()) relations = await self._get_relations_for_entities(conn, set(names)) return {"entities": entities, "relations": relations} - optimized_memory_mcp_server/main.py:245-257 (registration)Registration of the open_nodes tool in the main server setup.
types.Tool( name="open_nodes", description="Retrieve specific nodes by name", inputSchema={ "type": "object", "properties": { "names": { "type": "array", "items": {"type": "string"} } }, "required": ["names"], "additionalProperties": False