Skip to main content
Glama
AgentWong

Knowledge Graph Memory Server

by AgentWong

delete_relations

Remove specified connections between entities in the knowledge graph memory to maintain accurate relationship data.

Instructions

Delete multiple relations from the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYesAn array of relations to delete

Implementation Reference

  • The handler function that executes the SQL DELETE operation for relations.
    async def delete_relations(
        self, 
        relations: List[Dict[str, Any]], 
        batch_size: int = 1000
    ) -> None:
        """Remove specific relations using batch processing."""
        async with self.pool.get_connection() as conn:
            async with self.pool.transaction(conn):
                for i in range(0, len(relations), batch_size):
                    batch = relations[i:i + batch_size]
                    relation_objects = [Relation.from_dict(r) for r in batch]
                    
                    await conn.executemany(
                        """
                        DELETE FROM relations 
                        WHERE from_entity = ? 
                        AND to_entity = ? 
                        AND relation_type = ?
                        """,
                        [(r.from_, r.to, r.relationType) for r in relation_objects]
                    )
  • The definition of the delete_relations tool schema.
        name="delete_relations",
        description="Remove specific relations from the graph",
        inputSchema={
            "type": "object",
            "properties": {
                "relations": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "from": {"type": "string"},
                            "to": {"type": "string"},
                            "relationType": {"type": "string"}
                        },
                        "required": ["from", "to", "relationType"],
                        "additionalProperties": False
                    }
                }
            },
            "required": ["relations"],
            "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