File size: 709 Bytes
2f203f5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | """Shared versioning between MCP tool JSON contracts and `@data360/tool-types` / UI packages."""
from __future__ import annotations
import json
from functools import lru_cache
from importlib import resources
@lru_cache(maxsize=1)
def get_tool_contract_version() -> str:
"""Return the tool contract version (semver) shipped with this server build."""
raw = resources.files("data360").joinpath("tool_contract_version.json").read_text(
encoding="utf-8"
)
data = json.loads(raw)
version = data.get("version")
if not isinstance(version, str) or not version.strip():
raise ValueError("tool_contract_version.json: missing or invalid 'version'")
return version.strip()
|