Skip to main content
Glama
AgentWong
by AgentWong

delete_entity

Remove an entity and its relationships from the knowledge graph to manage Infrastructure-as-Code components.

Instructions

Remove an entity and its relationships from the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesEntity ID

Implementation Reference

  • The MCP tool handler for delete_entity. It validates, logs the operation, calls execute_delete_entity, and handles errors by raising McpError.
    async def handle_delete_entity(db: Any, arguments: Dict[str, Any], operation_id: str) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle delete_entity tool."""
        try:
            logger.info(
                "Deleting entity",
                extra={
                    "entity_id": arguments.get("entity_id"),
                    "operation_id": operation_id,
                },
            )
    
            # Execute deletion
            return execute_delete_entity(db, arguments)
    
        except Exception as e:
            error_msg = f"Failed to delete entity: {str(e)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            raise McpError(
                types.ErrorData(
                    code=types.INTERNAL_ERROR,
                    message=error_msg,
                    data={
                        "tool": "delete_entity",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema defining the input parameters for the delete_entity tool, requiring an 'id' string.
    "delete_entity": {
        "type": "object",
        "description": "Remove an entity and its relationships from the knowledge graph",
        "required": ["id"],
        "properties": {"id": {"type": "string", "description": "Entity ID"}},
    },
  • Dictionary registering the delete_entity tool handler along with other entity tools.
    entity_tool_handlers = {
        "create_entity": handle_create_entity,
        "update_entity": handle_update_entity,
        "delete_entity": handle_delete_entity,
        "view_relationships": handle_view_relationships,
    }
  • Helper function called by the handler to perform the deletion logic, invoking the core delete_entity function and returning a TextContent response.
    def execute_delete_entity(
        db: DatabaseManager, arguments: Dict[str, Any]
    ) -> List[TextContent]:
        """Execute delete entity operation."""
        logger.info("Deleting entity", extra={"args": arguments})
    
        success = delete_entity(db, arguments["id"])
        if not success:
            raise DatabaseError(f"Entity not found: {arguments['id']}")
    
        return [TextContent(type="text", text=f"Deleted entity {arguments['id']}")]
  • Core database operation that deletes observations and the entity from the SQLite database, returning success boolean.
    def delete_entity(db: DatabaseManager, entity_id: str) -> bool:
        """Delete an entity and its related observations."""
        try:
            with db.get_connection() as conn:
                conn.execute("BEGIN TRANSACTION")
                conn.execute("DELETE FROM observations WHERE entity_id = ?", (entity_id,))
                cursor = conn.execute("DELETE FROM entities WHERE id = ?", (entity_id,))
                affected = cursor.rowcount > 0
                conn.commit()
                return affected
        except sqlite3.Error as e:
            raise DatabaseError(f"Delete failed: {str(e)}")
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that relationships are also removed, which adds some context beyond a simple 'delete', but it doesn't cover critical aspects like whether the deletion is permanent, requires specific permissions, has side effects on related data, or what happens on success/failure. For a destructive operation with zero annotation coverage, this is inadequate.

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 that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy to understand at a glance.

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

Completeness2/5

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

Given the tool's destructive nature, lack of annotations, and no output schema, the description is insufficient. It doesn't explain return values, error conditions, or the full behavioral impact (e.g., cascading effects). For a deletion tool in a knowledge graph context, more detail is needed to ensure safe and correct usage.

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?

The input schema has 100% description coverage, with the single parameter 'id' documented as 'Entity ID'. The description doesn't add any meaning beyond this, such as format examples or constraints, so it meets the baseline of 3 where the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Remove') and target ('entity and its relationships from the knowledge graph'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'update_entity' or 'create_entity' beyond the verb choice, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'update_entity' or 'view_relationships', nor does it mention prerequisites or exclusions. It simply states what the tool does without contextual usage information.

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/iac-memory-mcp-server-project'

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