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)}")
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 it's a creation operation but doesn't disclose behavioral traits such as permissions needed, whether it's idempotent, error handling, or what happens on duplicate entities. For a mutation tool with zero annotation coverage, this is a significant gap.

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 front-loads the core purpose ('Create a new entity in the knowledge graph') and adds a useful detail ('with optional initial observations'). There is zero waste, and it's appropriately sized for the tool's complexity.

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 this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain return values, error conditions, or important behavioral aspects like idempotency or permissions. For a create operation in a knowledge graph context, more context 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?

Schema description coverage is 100%, so the schema already documents all three parameters (name, type, observation). The description mentions 'optional initial observations' which aligns with the observation parameter but adds no additional meaning beyond what the schema provides. Baseline 3 is appropriate when 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 verb ('create') and resource ('entity in the knowledge graph'), and specifies optional initial observations. It distinguishes from siblings like 'update_entity' and 'delete_entity' by indicating it's for creation, though it doesn't explicitly contrast with them.

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', nor does it mention prerequisites or context for creation. It lacks explicit when/when-not instructions or named alternatives.

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'

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