Spaces:
Running
Running
File size: 1,033 Bytes
630d650 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#!/usr/bin/env python3
import argparse
import json
from collections import Counter
from pathlib import Path
def main() -> None:
parser = argparse.ArgumentParser(description="Replay and summarize cancer risk MCP log JSONL")
parser.add_argument("--log-jsonl", required=True, help="Path to cancer_risk_log.jsonl")
args = parser.parse_args()
path = Path(args.log_jsonl)
if not path.exists():
raise FileNotFoundError(f"Log file not found: {path}")
events = []
for line in path.read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line:
continue
events.append(json.loads(line))
tool_counts = Counter([e.get("tool_name", "unknown") for e in events])
print("# MCP Calculation Log Replay")
print(f"events={len(events)}")
for tool, n in sorted(tool_counts.items()):
print(f"- {tool}: {n}")
if events:
print("\nlast_event=")
print(json.dumps(events[-1], indent=2))
if __name__ == "__main__":
main()
|