diff --git a/ag_bids_mcp/format.py b/ag_bids_mcp/format.py index f857ab5..49f58a7 100644 --- a/ag_bids_mcp/format.py +++ b/ag_bids_mcp/format.py @@ -302,18 +302,26 @@ def fmt_basis_detail(payload: dict, max_rows: int = 80) -> str: # ---------- sources / health ---------- +def _location(s: dict) -> str: + city, state = s.get("city"), s.get("state") + loc = ", ".join(p for p in (city, state) if p) + if s.get("zip"): + loc = f"{loc} {s['zip']}".strip() + return loc or "—" + + def fmt_sources(payload: dict) -> str: src = payload.get("sources") or [] if not src: return "### Sources\n\nNo active sources.\n" lines = [ "### Tracked sources", "", - "| Source | Kind | Last success | Consecutive failures | Last error |", - "|---|---|---|---:|---|", + "| Source | Kind | Location | Last success | Consecutive failures | Last error |", + "|---|---|---|---|---:|---|", ] for s in src: lines.append( - f"| {s['name']} | {s['kind']} | {s.get('last_success_at') or '—'} | " + f"| {s['name']} | {s['kind']} | {_location(s)} | {s.get('last_success_at') or '—'} | " f"{s.get('consecutive_failures') or 0} | {s.get('last_error') or ''} |" ) return "\n".join(lines) + "\n" diff --git a/tests/test_format.py b/tests/test_format.py index 7ae45bc..942d9f1 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -200,12 +200,14 @@ def test_fmt_basis_detail_per_series(): def test_fmt_sources_table(): payload = {"sources": [ {"id": 1, "name": "Test Elev", "kind": "elevator", + "city": "Ada", "state": "OH", "zip": "45810", "last_success_at": "2026-05-20T14:55:00+00:00", "consecutive_failures": 0, "last_error": None}, ]} out = fmt.fmt_sources(payload) assert "Test Elev" in out assert "elevator" in out + assert "Ada, OH 45810" in out # location column def test_fmt_health_buckets():