MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / validate_index_file

Function validate_index_file

scripts/validate_schema.py:132–160  ·  view source on GitHub ↗

Validate a _index.json file.

(index_file: Path, errors: list, warnings: list)

Source from the content-addressed store, hash-verified

130
131
132def validate_index_file(index_file: Path, errors: list, warnings: list) -> bool:
133 """Validate a _index.json file."""
134 try:
135 with open(index_file, "r", encoding="utf-8") as f:
136 data = json.load(f)
137 except json.JSONDecodeError as e:
138 errors.append(f" ERROR: {index_file.relative_to(ROOT)}: invalid JSON: {e}")
139 return False
140
141 required = ["category", "last_updated", "entries"]
142 missing = [f for f in required if f not in data]
143 if missing:
144 errors.append(
145 f" ERROR: {index_file.relative_to(ROOT)}: missing fields: {', '.join(missing)}"
146 )
147 return False
148
149 # Validate each entry has required fields
150 for i, entry in enumerate(data.get("entries", [])):
151 entry_required = ["id", "title", "status", "source_url"]
152 entry_missing = [f for f in entry_required if f not in entry]
153 if entry_missing:
154 errors.append(
155 f" ERROR: {index_file.relative_to(ROOT)}: entry[{i}] missing: "
156 f"{', '.join(entry_missing)}"
157 )
158 return False
159
160 return True
161
162
163def validate_path(search_path: Path, errors: list, warnings: list) -> tuple[int, int]:

Callers 1

validate_pathFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected