Skip to main content
Glama
AgentWong

Knowledge Graph Memory Server

by AgentWong

Delete Entities

delete_entities

Remove entities and their relationships from a knowledge graph to maintain accurate memory storage by specifying which items to delete.

Instructions

Delete multiple entities and their associated relations from the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityNamesYesAn array of entity names to delete

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYes
successYes

Implementation Reference

  • The handler function that executes the logic to delete entities and their associated relations from the SQLite database.
    async def delete_entities(
        self, 
        entity_names: List[str], 
        batch_size: int = 1000
    ) -> None:
        """Remove entities and their relations."""
        async with self.pool.get_connection() as conn:
            async with self.pool.transaction(conn):
                for i in range(0, len(entity_names), batch_size):
                    batch = entity_names[i:i + batch_size]
                    sanitized_names = [sanitize_input(name) for name in batch]
                    
                    placeholders = ','.join(['?' for _ in sanitized_names])
                    await conn.execute(
                        f"""
                        DELETE FROM relations 
                        WHERE from_entity IN ({placeholders})
                        OR to_entity IN ({placeholders})
                        """,
                        sanitized_names * 2
                    )
                    
                    await conn.execute(
                        f"DELETE FROM entities WHERE name IN ({placeholders})",
                        sanitized_names
                    )
  • The schema definition for the 'delete_entities' tool, specifying its expected input format.
        name="delete_entities",
        description="Remove entities and their relations",
        inputSchema={
            "type": "object",
            "properties": {
                "entityNames": {
                    "type": "array",
                    "items": {"type": "string"}
                }
            },
            "required": ["entityNames"],
            "additionalProperties": False
        }
    ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool deletes entities and relations, implying destructive behavior, but lacks critical details like permissions required, whether deletions are reversible, side effects on the graph, or rate limits. This is a significant gap for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it directly states the tool's action and scope. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which covers return values), no annotations, and high schema coverage, the description is minimally adequate. However, for a destructive tool with no annotations, it should provide more behavioral context (e.g., safety warnings, confirmation steps) to be complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the entityNames parameter. The description adds no additional meaning beyond implying deletion includes associated relations, but doesn't clarify parameter semantics like format constraints or examples. Baseline 3 is appropriate as the schema handles documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete multiple entities and their associated relations') and the resource ('from the knowledge graph'), making the purpose specific and unambiguous. It distinguishes this tool from siblings like delete_observations or delete_relations by specifying it targets entities and their relations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for deleting entities and relations together, but provides no explicit guidance on when to use this versus alternatives like delete_relations alone or other deletion tools. No prerequisites, exclusions, or comparative context are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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