58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
||
"""Render the human-readable MCP list from the single JSON registry."""
|
||
|
||
from __future__ import annotations
|
||
|
||
import argparse
|
||
import json
|
||
import pathlib
|
||
|
||
|
||
ROOT = pathlib.Path(__file__).resolve().parents[2]
|
||
REGISTRY = ROOT / "config" / "mcp-registry.json"
|
||
OUTPUT = ROOT / "docs" / "MCP_SERVERS.md"
|
||
|
||
|
||
def render() -> str:
|
||
document = json.loads(REGISTRY.read_text(encoding="utf-8"))
|
||
rows = []
|
||
for item in document["servers"]:
|
||
if not item.get("hub"):
|
||
continue
|
||
clients = ", ".join(item.get("clients", [])) or "–"
|
||
selection = str(len(item["tool_include"])) if item.get("tool_include") else "alle"
|
||
rows.append(
|
||
f"| {item['name']} | `{item['hermes_id']}` | `{item['url']}` | "
|
||
f"{clients} | {selection} |"
|
||
)
|
||
return "\n".join([
|
||
"# MCP-Server",
|
||
"",
|
||
"Diese Datei wird aus `config/mcp-registry.json` erzeugt. Änderungen gehören nur in die JSON-Registry.",
|
||
"",
|
||
"| Server | Hermes-ID | Endpunkt | Clients | Werkzeuge |",
|
||
"|---|---|---|---|---:|",
|
||
*rows,
|
||
"",
|
||
"Allgemeine Webrecherche ist ein eingebautes Hermes-Werkzeug und kein MCPHub-Server.",
|
||
"",
|
||
])
|
||
|
||
|
||
def main() -> None:
|
||
parser = argparse.ArgumentParser()
|
||
parser.add_argument("--check", action="store_true")
|
||
args = parser.parse_args()
|
||
expected = render()
|
||
if args.check:
|
||
if not OUTPUT.is_file() or OUTPUT.read_text(encoding="utf-8") != expected:
|
||
raise SystemExit("MCP registry documentation is out of date")
|
||
print("MCP_REGISTRY_OK")
|
||
return
|
||
OUTPUT.write_text(expected, encoding="utf-8")
|
||
print("MCP_REGISTRY_RENDERED")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|