File size: 1,698 Bytes
e23172f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Verify trifecta-bro MCP server tools with local data."""
from __future__ import annotations

import json
import sys
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "src"))

from mcp_server import get_predictions, get_race, list_pdfs, get_latest_meetings, health


def call(name: str, fn):
    print(f"==> {name}")
    try:
        results = fn()
        assert isinstance(results, list) and len(results) == 1
        text = results[0].text
        obj = json.loads(text)
        print(json.dumps({"ok": True, "tool": name, "data": obj}, indent=2)[:3000])
    except Exception as exc:  # noqa: BLE001
        print(json.dumps({"ok": False, "tool": name, "error": str(exc)}, indent=2))
    print()


call("trifecta.health", health)

call("trifecta.get_latest_meetings", lambda: get_latest_meetings())

sample_dates = sorted(
    p.stem.replace("predictions-", "")
    for p in (REPO_ROOT / "data" / "predictions").glob("predictions-*.json")
)
if sample_dates:
    d = sample_dates[0]
    call("trifecta.get_predictions", lambda dd=d: get_predictions(dd))
    call("trifecta.list_pdfs", list_pdfs)
    try:
        payload = json.loads(
            (REPO_ROOT / "data" / "predictions" / f"predictions-{d}.json").read_text()
        )
        races = payload.get("races", [])
        if races:
            rn = races[0].get("race_number")
            call("trifecta.get_race", lambda dd=d, rn=int(rn): get_race(dd, rn))
    except Exception as exc:  # noqa: BLE001
        print(json.dumps({"ok": False, "tool": "trifecta.get_race", "error": str(exc)}, indent=2))
else:
    print("No predictions JSON files found under data/predictions")