Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix(mcp): read the graph edge count from stats() in the MCP summary readers (#1745)

hiro-nikaitoud0c35bf2dabc
diff --git a/semantica_mcp/mcp/resources/registry.py b/semantica_mcp/mcp/resources/registry.py
index 74efdbe3..82275993 100644
--- a/semantica_mcp/mcp/resources/registry.py
+++ b/semantica_mcp/mcp/resources/registry.py
@@ -31,6 +31,8 @@ def _read_graph_summary(uri: str) -> dict:
edge_count = graph.edge_count()
except Exception as exc:
log.debug("Unable to read graph edge_count(); defaulting to 0: %s", exc)
+ elif hasattr(graph, "stats"):
+ edge_count = graph.stats().get("edge_count", 0)
data = {
"node_count": len(all_nodes),
"edge_count": edge_count,
diff --git a/semantica_mcp/mcp/tools/graph.py b/semantica_mcp/mcp/tools/graph.py
index 1c105bf5..917c3c45 100644
--- a/semantica_mcp/mcp/tools/graph.py
+++ b/semantica_mcp/mcp/tools/graph.py
@@ -162,6 +162,8 @@ def handle_get_graph_summary(args: dict) -> dict: # noqa: ARG001
edge_count = graph.edge_count()
except Exception:
log.exception("graph.edge_count failed; defaulting edge_count to 0")
+ elif hasattr(graph, "stats"):
+ edge_count = graph.stats().get("edge_count", 0)
return {
"node_count": len(all_nodes),
"edge_count": edge_count,