diff --git a/mcp_codebase.py b/mcp_codebase.py index 08ff085..c9e9f04 100644 --- a/mcp_codebase.py +++ b/mcp_codebase.py @@ -1986,13 +1986,15 @@ def build_indexes(): graph.add_node(node_id, **base_attrs, type=node_type) - # Try to find the target struct/trait that this impl implements + # Guard against empty lists that can be returned by the Rust parser target_name = None - if "implements_traits" in m: - target_name = m["implements_traits"][0] # assume first trait - elif "implements" in m: + if "implements_traits" in m and isinstance(m["implements_traits"], list) and m["implements_traits"]: + # assume first trait + target_name = m["implements_traits"][0] + elif "implements" in m and isinstance(m["implements"], list) and m["implements"]: target_name = m["implements"][0] + if target_name: target_node_id = f"{lang}::struct::{fpath}::{target_name}" if target_node_id not in graph.graph: