From b434a6b680fa2fe8ba412981a281273bc484a01d Mon Sep 17 00:00:00 2001 From: Daniel Chalef <131175+danielchalef@users.noreply.github.com> Date: Wed, 29 Oct 2025 22:51:24 -0700 Subject: [PATCH] fix: Convert entity_types from list to dict for Graphiti API The Graphiti add_episode() API expects entity_types as a dict[str, type[BaseModel]], not a list. Changed entity type building to create a dictionary mapping entity names to their Pydantic model classes. Fixed error: 'list' object has no attribute 'items' Changes: - Build entity_types as dict instead of list in config processing - Add fallback to convert ENTITY_TYPES list to dict if needed - Map entity type names to their model classes --- mcp_server/src/graphiti_mcp_server.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mcp_server/src/graphiti_mcp_server.py b/mcp_server/src/graphiti_mcp_server.py index 7ff18a06..c1c21ad4 100644 --- a/mcp_server/src/graphiti_mcp_server.py +++ b/mcp_server/src/graphiti_mcp_server.py @@ -151,7 +151,7 @@ class GraphitiService: # Build custom entity types if configured custom_types = None if self.config.graphiti.entity_types: - custom_types = [] + custom_types = {} for entity_type in self.config.graphiti.entity_types: # Create a dynamic Pydantic model for each entity type entity_model = type( @@ -162,10 +162,14 @@ class GraphitiService: '__doc__': entity_type.description, }, ) - custom_types.append(entity_model) + custom_types[entity_type.name] = entity_model # Also support the existing ENTITY_TYPES if use_custom_entities is set elif hasattr(self.config, 'use_custom_entities') and self.config.use_custom_entities: - custom_types = ENTITY_TYPES + # Convert ENTITY_TYPES list to dict if needed + if isinstance(ENTITY_TYPES, list): + custom_types = {et.__name__: et for et in ENTITY_TYPES} + else: + custom_types = ENTITY_TYPES # Store entity types for later use self.entity_types = custom_types