Skip to main content
Glama

update_entity

Modify an entity's properties and add new observations in the IaC Memory MCP Server, enabling updates to Infrastructure-as-Code components with version tracking and relationship mapping for Terraform and Ansible resources.

Instructions

Update an existing entity's properties and add new observations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesEntity ID
nameNoNew name
observationNoNew observation
typeNoNew type

Implementation Reference

  • The MCP tool handler function that processes the update_entity tool call, logs the operation, delegates to the execute_update_entity helper, and handles any errors by raising an McpError.
    async def handle_update_entity(db: Any, arguments: Dict[str, Any], operation_id: str) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """Handle update_entity tool.""" try: logger.info( "Updating entity", extra={ "entity_id": arguments.get("entity_id"), "operation_id": operation_id, }, ) # Execute update return execute_update_entity(db, arguments) except Exception as e: error_msg = f"Failed to update 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": "update_entity", "operation_id": operation_id, }, ) )
  • Registration of the update_entity handler in the entity_tool_handlers dictionary, which is likely used to register tools with the MCP server.
    entity_tool_handlers = { "create_entity": handle_create_entity, "update_entity": handle_update_entity, "delete_entity": handle_delete_entity, "view_relationships": handle_view_relationships, }
  • JSON schema definition for the update_entity tool, defining required 'id' and optional properties like name, type, observation. Used for input validation.
    "update_entity": { "type": "object", "description": "Update an existing entity's properties and add new observations", "required": ["id"], "properties": { "id": {"type": "string", "description": "Entity ID"}, "name": {"type": "string", "description": "New name"}, "type": {"type": "string", "description": "New type"}, "observation": {"type": "string", "description": "New observation"}, }, },
  • Helper function execute_update_entity that orchestrates the entity update by calling the low-level update_entity, optionally adds a new observation to the database, and returns a success TextContent response.
    def execute_update_entity( db: DatabaseManager, arguments: Dict[str, Any] ) -> List[TextContent]: """Execute update entity operation.""" logger.info("Updating entity", extra={"args": arguments}) updates = {k: v for k, v in arguments.items() if k != "id"} success = update_entity(db, arguments["id"], updates) if not success: raise DatabaseError(f"Entity not found: {arguments['id']}") # Add observation if provided if "observation" in arguments: with db.get_connection() as conn: conn.execute( "INSERT INTO observations (entity_id, content) VALUES (?, ?)", (arguments["id"], arguments["observation"]), ) return [TextContent(type="text", text=f"Updated entity {arguments['id']}")]
  • Low-level database helper function that performs the actual SQL UPDATE on the entities table based on provided updates and entity_id, returning success boolean.
    def update_entity(db: DatabaseManager, entity_id: str, updates: Dict) -> bool: """Update an existing entity.""" set_clause = ", ".join(f"{k} = ?" for k in updates.keys()) values = tuple(updates.values()) + (entity_id,) query = f"UPDATE entities SET {set_clause} WHERE id = ?" try: with db.get_connection() as conn: cursor = conn.execute(query, values) return cursor.rowcount > 0 except sqlite3.Error as e: raise DatabaseError(f"Update failed: {str(e)}")

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