Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

create_entity

Add new entities to a knowledge graph for Infrastructure-as-Code data storage, with options to include initial observations.

Instructions

Create a new entity in the knowledge graph with optional initial observations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesEntity name
typeYesEntity type
observationNoInitial observation

Implementation Reference

  • MCP handler function for the create_entity tool that performs validation and delegates to execute_create_entity.
    async def handle_create_entity(db: Any, arguments: Dict[str, Any], operation_id: str) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle create_entity tool."""
        # Validate required arguments
        if not arguments.get("name") or not arguments.get("type"):
            raise ValidationError("Missing required arguments: name and type are required")
    
        logger.info(
            "Creating entity",
            extra={
                "entity_type": arguments.get("type"),
                "operation_id": operation_id,
            },
        )
    
        try:
            # Execute creation
            return await execute_create_entity(db, arguments)
    
        except Exception as e:
            error_msg = f"Failed to create 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": "create_entity",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema definition for the create_entity tool parameters.
    "create_entity": {
        "type": "object",
        "description": "Create a new entity in the knowledge graph with optional initial observations",
        "required": ["name", "type"],
        "properties": {
            "name": {"type": "string", "description": "Entity name"},
            "type": {"type": "string", "description": "Entity type"},
            "observation": {"type": "string", "description": "Initial observation"},
        },
    },
  • Registration of the create_entity handler in the entity_tool_handlers dictionary.
    entity_tool_handlers = {
        "create_entity": handle_create_entity,
        "update_entity": handle_update_entity,
        "delete_entity": handle_delete_entity,
        "view_relationships": handle_view_relationships,
    }
  • Core execution logic for creating an entity in the database, including optional observation, called by the handler.
    async def execute_create_entity(
        db: DatabaseManager, arguments: Dict[str, Any]
    ) -> List[TextContent]:
        """Execute create entity operation.
    
        Args:
            db: Database manager instance
            arguments: Tool arguments
        """
        logger.info("Creating new entity", extra={"tool_arguments": arguments})
    
        with db.get_connection() as conn:
            conn.execute("PRAGMA busy_timeout = 5000")  # 5s timeout
            conn.execute("BEGIN IMMEDIATE")
            try:
                # Create entity
                cursor = conn.execute(
                    """INSERT INTO entities (name, type)
                    VALUES (?, ?)""",
                    (arguments["name"], arguments["type"]),
                )
                entity_id = cursor.lastrowid
    
                # Add observation if provided
                if "observation" in arguments:
                    conn.execute(
                        "INSERT INTO observations (entity_id, content) VALUES (?, ?)",
                        (entity_id, arguments["observation"]),
                    )
    
                conn.commit()
                return [
                    TextContent(
                        type="text",
                        text=f"Created entity '{arguments['name']}' (ID: {entity_id})",
                    )
                ]
            except Exception as e:
                conn.rollback()
                logger.error(f"Failed to create entity: {str(e)}")
                raise DatabaseError(f"Failed to create entity: {str(e)}")

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it indicates this is a creation operation, it doesn't address important behavioral aspects like whether this requires specific permissions, what happens if an entity with the same name already exists, whether the operation is idempotent, or what the response looks like. For a mutation tool 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 communicates the core functionality without any wasted words. It's appropriately sized for a tool with 3 parameters and gets straight to the point with no unnecessary elaboration.

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?

For a mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after creation, what errors might occur, how the entity integrates with the knowledge graph system, or what the tool returns. Given the complexity of entity creation in a knowledge graph context, more contextual information is needed.

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 schema description coverage is 100%, so all parameters are documented in the schema. The description adds minimal value beyond the schema by mentioning 'optional initial observations' which corresponds to the 'observation' parameter. However, it doesn't provide additional context about parameter relationships or usage patterns beyond what's already in the structured schema.

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 verb ('create') and resource ('entity in the knowledge graph'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'update_entity' or explain how it relates to other entity management tools like 'delete_entity' and 'view_relationships', which prevents a perfect 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 'delete_entity'. It mentions 'optional initial observations' but doesn't explain when this feature is appropriate or what prerequisites might be needed for creating entities.

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