Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

fix: include method templates in MCP list_templates

Frankie-Xu8e014693f506
diff --git a/hyperextract/mcp_server.py b/hyperextract/mcp_server.py
index 3b4a1c1..9c06f46 100644
--- a/hyperextract/mcp_server.py
+++ b/hyperextract/mcp_server.py
@@ -82,14 +82,18 @@ def _dump(obj: Any) -> str:
# ---------------------------------------------------------------------------
-def list_templates() -> str:
+def list_templates(include_methods: bool = True) -> str:
"""List the available knowledge-extraction templates.
+ Args:
+ include_methods: When true (default), include ``method/<name>``
+ entries the CLI lists and ``he parse -t`` accepts.
+
Returns a JSON array of {name, type, description}.
"""
from hyperextract.utils.template_engine import Template
- templates = Template.list(include_methods=False)
+ templates = Template.list(include_methods=include_methods)
out = []
for name, cfg in sorted(templates.items()):
desc = getattr(cfg, "description", "") or ""
diff --git a/tests/test_mcp_server.py b/tests/test_mcp_server.py
index ef4c689..8fa05f9 100644
--- a/tests/test_mcp_server.py
+++ b/tests/test_mcp_server.py
@@ -59,6 +59,19 @@ def test_list_templates_returns_json():
assert {"name", "type", "description"} <= set(out[0].keys())
+def test_list_templates_includes_methods_by_default():
+ out = json.loads(mcp_server.list_templates())
+ names = {item["name"] for item in out}
+ assert any(name.startswith("method/") for name in names)
+ assert "method/graph_rag" in names or "method/chunk_rag" in names
+
+
+def test_list_templates_can_hide_methods():
+ out = json.loads(mcp_server.list_templates(include_methods=False))
+ names = {item["name"] for item in out}
+ assert all(not name.startswith("method/") for name in names)
+
+
# ---------------------------------------------------------------------------
# info (no client needed — reads json directly)
# ---------------------------------------------------------------------------