Skip to main content
Glama
AgentWong

Knowledge Graph Memory Server

by AgentWong

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
NameRequiredDescriptionDefault
namesYesAn 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}
  • 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

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/AgentWong/optimized-memory-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server