Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

docs: sync MCP tool registry documentation

Sameer Kadamf3e6e6188cb2
diff --git a/semantica_mcp/mcp/README.md b/semantica_mcp/mcp/README.md
index 0e6e7c91..bc78c692 100644
--- a/semantica_mcp/mcp/README.md
+++ b/semantica_mcp/mcp/README.md
@@ -31,7 +31,7 @@ python -m mcp [--debug]
---
-## Tools (18 total)
+## Tools (22 total)
### Extraction
@@ -76,6 +76,15 @@ python -m mcp [--debug]
| `export_graph` | Export graph to JSON, CSV, GraphML, Parquet, Turtle, N-Triples, RDF/XML, JSON-LD |
| `get_provenance` | Audit history and source lineage for a node (`entity_id`) |
+### Semantic Retrieval
+
+| Tool | Description |
+|---|---|
+| `store_document` | Chunk a document, embed the chunks, and store them for semantic retrieval. Keyed on `(source, version)`; re-storing identical content is a no-op |
+| `retrieve_context` | Embed a natural-language query and return the most relevant stored chunks with scores and provenance, combined with related knowledge-graph relationships |
+| `update_document` | Replace the stored content of a document identified by `(source, version)`. Returns `not_found` when no stored document matches |
+| `remove_document` | Remove every chunk stored under `(source, version)` from the vector store |
+
---
## Resources (4 total)
@@ -262,7 +271,8 @@ mcp/
│ ├── decisions.py # Record, query, precedents, causal chain, impact
│ ├── graph.py # Add entity/relationship, search, summary, analytics
│ ├── reasoning.py # Forward-chaining rules, abductive hypotheses
-│ └── export.py # Graph export (multi-format) + provenance
+│ ├── export.py # Graph export (multi-format) + provenance
+│ └── retrieval.py # Semantic vector store: store, retrieve, update, remove
└── resources/
├── __init__.py # Re-exports RESOURCE_DEFINITIONS + handle_resource_read
└── registry.py # URI → handler map for the 4 semantica:// resources
diff --git a/semantica_mcp/mcp/resources/registry.py b/semantica_mcp/mcp/resources/registry.py
index ea73f4b1..74efdbe3 100644
--- a/semantica_mcp/mcp/resources/registry.py
+++ b/semantica_mcp/mcp/resources/registry.py
@@ -12,6 +12,7 @@ import logging
from .. import __version__
from ..session import get_graph
+from ..tools import TOOL_DEFINITIONS
log = logging.getLogger("semantica.mcp.resources")
@@ -70,15 +71,7 @@ def _read_schema_info(uri: str) -> dict:
"RELATED_TO", "CAUSED_BY", "LEADS_TO", "PART_OF",
"INSTANCE_OF", "SIMILAR_TO",
],
- "tools": [
- "extract_entities", "extract_relations", "extract_all",
- "record_decision", "query_decisions", "find_precedents",
- "get_causal_chain", "analyze_decision_impact",
- "add_entity", "add_relationship", "search_graph",
- "get_graph_summary", "get_graph_analytics",
- "run_reasoning", "abductive_reasoning",
- "export_graph", "get_provenance",
- ],
+ "tools": [t["name"] for t in TOOL_DEFINITIONS],
}
return {"uri": uri, "mimeType": "application/json", "text": json.dumps(info, indent=2)}
diff --git a/semantica_mcp/mcp/schemas.py b/semantica_mcp/mcp/schemas.py
index 4c909cb6..d12e1ffc 100644
--- a/semantica_mcp/mcp/schemas.py
+++ b/semantica_mcp/mcp/schemas.py
@@ -274,7 +274,7 @@ EXPORT_GRAPH = {
"properties": {
"format": {
"type": "string",
- "enum": ["turtle", "ttl", "nt", "xml", "json-ld", "json", "csv"],
+ "enum": ["turtle", "ttl", "nt", "xml", "json-ld", "json", "csv", "graphml", "parquet"],
"description": "Export format (default: json-ld)",
},
},
diff --git a/tests/test_mcp_tool_registry_consistency.py b/tests/test_mcp_tool_registry_consistency.py
new file mode 100644
index 00000000..e02a005f
--- /dev/null
+++ b/tests/test_mcp_tool_registry_consistency.py
@@ -0,0 +1,140 @@
+"""Regression tests for MCP tool-registry consistency.
+
+Verifies that every surface that advertises available tools stays in sync
+with the authoritative TOOL_DEFINITIONS list:
+
+1. semantica://schema/info resource — must list exactly the same tool names
+ as TOOL_DEFINITIONS (was hard-coded at 17, missing link_decisions and all
+ 4 retrieval tools).
+
+2. EXPORT_GRAPH inputSchema enum — must include every format that the
+ handler implementation actually accepts (was missing "graphml" and
+ "parquet").
+
+These are documentation/discovery surfaces; a mismatch does not break the
+tools themselves but misleads MCP clients that use tools/list or
+semantica://schema/info to discover capabilities.
+"""
+
+import json
+import os
+import sys
+import unittest
+
+os.environ.setdefault("SEMANTICA_DISABLE_PROGRESS", "1")
+
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
+
+
+class TestSchemaInfoToolList(unittest.TestCase):
+ """semantica://schema/info must expose exactly the tools in TOOL_DEFINITIONS."""
+
+ def _schema_info_tools(self):
+ from semantica_mcp.mcp.resources.registry import _read_schema_info
+ resource = _read_schema_info("semantica://schema/info")
+ return json.loads(resource["text"])["tools"]
+
+ def _defined_tool_names(self):
+ from semantica_mcp.mcp.tools import TOOL_DEFINITIONS
+ return [t["name"] for t in TOOL_DEFINITIONS]
+
+ def test_schema_info_tool_list_matches_tool_definitions(self):
+ """The schema/info resource must list every registered tool and nothing
+ more — it must not be a stale hard-coded subset."""
+ self.assertEqual(self._schema_info_tools(), self._defined_tool_names())
+
+ def test_schema_info_tool_count_is_22(self):
+ """TOOL_DEFINITIONS currently registers 22 tools; the resource must
+ reflect that exact count."""
+ self.assertEqual(len(self._schema_info_tools()), 22)
+
+ def test_schema_info_includes_link_decisions(self):
+ """link_decisions was missing from the old hard-coded list."""
+ self.assertIn("link_decisions", self._schema_info_tools())
+
+ def test_schema_info_includes_store_document(self):
+ self.assertIn("store_document", self._schema_info_tools())
+
+ def test_schema_info_includes_retrieve_context(self):
+ self.assertIn("retrieve_context", self._schema_info_tools())
+
+ def test_schema_info_includes_update_document(self):
+ self.assertIn("update_document", self._schema_info_tools())
+
+ def test_schema_info_includes_remove_document(self):
+ self.assertIn("remove_document", self._schema_info_tools())
+
+ def test_schema_info_tool_list_order_matches_tool_definitions(self):
+ """Order must also match so clients see a stable, predictable list."""
+ self.assertEqual(self._schema_info_tools(), self._defined_tool_names())
+
+
+class TestExportGraphSchemaEnum(unittest.TestCase):
+ """EXPORT_GRAPH inputSchema enum must include every format the handler
+ actually accepts (was missing graphml and parquet)."""
+
+ def _export_graph_enum(self):
+ from semantica_mcp.mcp.tools import TOOL_DEFINITIONS
+ tool = next(t for t in TOOL_DEFINITIONS if t["name"] == "export_graph")
+ return tool["inputSchema"]["properties"]["format"]["enum"]
+
+ def test_enum_includes_graphml(self):
+ """graphml was handled by the implementation but absent from the schema."""
+ self.assertIn("graphml", self._export_graph_enum())
+
+ def test_enum_includes_parquet(self):
+ """parquet was handled by the implementation but absent from the schema."""
+ self.assertIn("parquet", self._export_graph_enum())
+
+ def test_enum_preserves_existing_formats(self):
+ """Adding graphml/parquet must not remove any previously declared format."""
+ existing = {"turtle", "ttl", "nt", "xml", "json-ld", "json", "csv"}
+ enum_set = set(self._export_graph_enum())
+ self.assertTrue(
+ existing.issubset(enum_set),
+ f"Missing previously-declared formats: {existing - enum_set}",
+ )
+
+ def test_enum_total_count_is_nine(self):
+ """7 original + graphml + parquet = 9."""
+ self.assertEqual(len(self._export_graph_enum()), 9)
+
+ def test_export_graph_schema_enum_matches_handler_supported_formats(self):
+ """Schema enum and the handler's own accepted-format set must agree,
+ so tools/list and runtime behaviour stay in sync."""
+ from semantica_mcp.mcp.tools.export import handle_export_graph
+ import semantica_mcp.mcp.session as _session
+ from semantica_mcp.mcp.tools import TOOL_DEFINITIONS
+
+ # Minimal graph for the handler to process without error.
+ try:
+ from semantica.context.context_graph import ContextGraph
+ orig = _session._graph
+ _session._graph = ContextGraph()
+ _session._graph.add_node("n1", node_type="entity")
+ except Exception:
+ self.skipTest("ContextGraph not importable in this environment")
+
+ schema_enum = set(self._export_graph_enum())
+ try:
+ # Every value in the schema enum must not produce an
+ # "Unsupported format" error from the handler.
+ for fmt in schema_enum:
+ with self.subTest(fmt=fmt):
+ result = handle_export_graph({"format": fmt})
+ if "error" in result:
+ # pyarrow/graphml optional deps may be absent; that
+ # produces a graceful error but not an "unsupported"
+ # one — the schema claim is still correct.
+ self.assertNotIn(
+ "Unsupported format",
+ result["error"],
+ f"Format {fmt!r} is in the schema enum but the "
+ f"handler says it is unsupported: {result['error']}",
+ )
+ finally:
+ _session._graph = orig
+
+
+if __name__ == "__main__":
+ unittest.main()