Skip to content

160-tool MCP server for real-time global intelligence from free public APIs: markets, liquidity, prediction markets, SEC filings, conflict, military, aircraft-cohort early warning, migration and border flows, cyber, climate, news and more. Dated observation history, 29 research prompts, cited briefs, geofences, SSE dashboard. MIT, no paid API keys.

News signals: judge partial days from a surviving series when the base call fails

Phoenix Agent (mac-studio)72b6e3a2fb05
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b930211..6ab8223 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,9 @@
every day; a day GDELT did not return is null in every column; both are
listed in `data_gaps`. Partial days (GDELT answered 2026-10-17 in
15-minute buckets for 3 days and hourly buckets for 7) are flagged
- `partial`, and today's unfinished UTC day is flagged `in_progress`. The
+ `partial`, judged from the first category series that answered when the
+ base call failed, and today's unfinished UTC day is flagged
+ `in_progress`. The
module spaces its own GDELT calls 5.5 s apart and retries a failed call
once.
- `intel_situations`: country pairs ("between": a headline naming two or
diff --git a/ROADMAP.md b/ROADMAP.md
index b9ee920..8b637cf 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -575,7 +575,7 @@ dashboard.
| 1 | Capture history and revisions | Earlier saved copies of a source, and values a later copy revised | :red_circle: |
| 1 | Collection health | Per-source expected cadence; overdue / failing / never-run per source, measured from the run log, not inferred from cache freshness. Says what it cannot prove | :red_circle: |
| 1 | Research guide over MCP | MCP resources (guide generated from the live registry and source health, measures glossary, "what this server will not do") and MCP prompts (worked research questions, each naming the tools it needs and the limit to respect). Server exposed no prompts or resources before | :red_circle: |
-| 1 | Hostility timeline | Per country pair or country, daily counts of threat / sanction / force / criticism coverage plus tone; sortable by most covered, most hostile, biggest change | :white_check_mark: Built 2026-10-17, unreleased: `intel_hostility_timeline` (GDELT DOC 2.0 `timelinevolraw` + `timelinetone`, one call per category, failed calls and missing days null) and `intel_situations` (RSS headlines, ranked by covered / hostile / change, change defined over feeds whose history spans both windows). Measured 2026-10-17: timeline modes answer (HTTP 200, `date_resolution` `hour` for `timespan=7d` and `15m` for `3d`, explicit zero buckets, `norm` = all monitored articles), but a `timespan=7d` request returned 54 hours (2026-10-15T10Z onward), and about half of calls drew 429 even 30 s apart (later probes, 16:51 to 16:53Z, 4 of 4 drew 429, so the resolution for 14 and 30 days and coverage before 2026-10-15 are unmeasured; a live MCP run at 17:00Z got 4 of 6 columns after the retry pass). Artlist was not used for daily counts: 250 records sorted by date covered 15 minutes. Situations see only the 22-country entity table |
+| 1 | Hostility timeline | Per country pair or country, daily counts of threat / sanction / force / criticism coverage plus tone; sortable by most covered, most hostile, biggest change | :white_check_mark: Built 2026-10-17, unreleased: `intel_hostility_timeline` (GDELT DOC 2.0 `timelinevolraw` + `timelinetone`, one call per category, failed calls and missing days null) and `intel_situations` (RSS headlines, ranked by covered / hostile / change, change defined over feeds whose history spans both windows). Measured 2026-10-17: timeline modes answer (HTTP 200, `date_resolution` `hour` for `timespan=7d` and `15m` for `3d`, explicit zero buckets, `norm` = all monitored articles), but a `timespan=7d` request returned 54 hours (2026-10-15T10Z onward), and about half of calls drew 429 even 30 s apart (later probes, 16:51 to 16:53Z, 4 of 4 drew 429, so the resolution for 14 and 30 days and coverage before 2026-10-15 are unmeasured; a live MCP run at 17:00Z got 4 of 6 columns after the retry pass, one at 17:20Z got 1 of 6, consistent with the server's breaker opening after 3 failed calls, which also skips the retry pass). Artlist was not used for daily counts: 250 records sorted by date covered 15 minutes. Situations see only the 22-country entity table |
| 1 | Story breadth | News clusters carry a distinct-outlet count; a top-stories view ranks by how many outlets carry a story | :white_check_mark: Built 2026-10-17, unreleased: clusters gain `outlets` / `outlet_count` (sister feeds of one publisher count once); `intel_top_stories` ranks by outlet count with an attention list (countries and organizations by mention growth). Found on the way: cluster `sources` was empty in every live cluster (key mismatch, `feed_name` vs `source_name`) and RSS times were shifted by the host UTC offset; both fixed. Concurrent RSS reads now share one request per feed (a live collector news-group cycle: 119 requests for 119 feeds) |
| 1 | Liquidity and flows | Fed balance sheet, Treasury General Account, reverse repo and net liquidity (FRED keyless CSV), money supply (US M2, euro area M1/M2/M3, never summed), ECB, ICI fund flows and ETF net issuance, FINRA margin statistics, BLS series; amounts kept separate from flows | :red_circle: |
| 1 | Kalshi + cross-venue markets | Kalshi public market data next to Polymarket; same-event comparison with an explicit match confidence; settled markets scored against pre-settlement prices (Brier) | :red_circle: |
diff --git a/src/world_intel_mcp/analysis/news_signals.py b/src/world_intel_mcp/analysis/news_signals.py
index 06c847e..fe9f978 100644
--- a/src/world_intel_mcp/analysis/news_signals.py
+++ b/src/world_intel_mcp/analysis/news_signals.py
@@ -29,6 +29,9 @@ Gaps / not covered:
- RSS feeds keep different amounts of history; change figures use only
feeds whose oldest retained item predates the prior window, so a feed
that keeps ten items never fakes a surge, but it also never counts.
+- When the base GDELT call fails, partial days are judged from a category
+ series' buckets. That every series shares the base series' bucket grid
+ was measured on one query (``Iran Israel``, 2026-10-17), not in general.
"""
from __future__ import annotations
@@ -451,25 +454,39 @@ async def fetch_hostility_timeline(
f"GDELT date_resolution {resolution!r} is not one this server has measured; "
"partial-day detection is off"
)
+ # The series whose buckets judge partial days: the base series, or when
+ # that call failed, the first category series that answered (measured
+ # 2026-10-17: category series carry the base series' bucket grid, zeros
+ # included). Without one, a surviving column could show a partial day's
+ # count unflagged.
+ coverage_col = next((c for c in ("articles", *GDELT_HOSTILITY_TERMS) if c in by_series), None)
+ if subdaily and coverage_col is None:
+ data_gaps.append("no volume timeline answered, so partial days are not flagged")
+ elif subdaily and coverage_col != "articles":
+ data_gaps.append(
+ f"partial days are judged from the {coverage_col} series' buckets "
+ "(the base articles call failed)"
+ )
today = now.date()
rows = []
missing_days: list[str] = []
for offset in range(days - 1, -1, -1):
day = (today - timedelta(days=offset)).isoformat()
base_points = by_series["articles"].get(day) if "articles" in by_series else None
+ coverage_points = by_series[coverage_col].get(day) if coverage_col else None
# Today's UTC day has not ended: its totals are not comparable with
# a full day's, whatever GDELT returned for the hours so far.
row: dict[str, Any] = {"date": day, "in_progress": day == today.isoformat()}
returned = None
- if "articles" in by_series:
- returned = len(base_points or [])
+ if coverage_col is not None:
+ returned = len(coverage_points or [])
row["buckets_returned"] = returned
if subdaily and returned is not None:
# partial = some elapsed hour of the day has no bucket at all
# (missing data). Today counts only wholly elapsed hours, so the
# current one may be absent: GDELT's newest bucket lags the clock.
hours = {
- str(p["date"])[9:11] for p in base_points or [] if len(str(p["date"])) >= 11
+ str(p["date"])[9:11] for p in coverage_points or [] if len(str(p["date"])) >= 11
}
elapsed = now.hour if row["in_progress"] else 24
missing_hours = sorted({f"{h:02d}" for h in range(elapsed)} - hours)
@@ -538,7 +555,9 @@ async def fetch_hostility_timeline(
"partial": (
"GDELT returned no bucket for at least one elapsed hour of that "
"UTC day (for today, only wholly elapsed hours count); "
- "hours_covered says how many hours had one"
+ "hours_covered says how many hours had one. Judged from the "
+ "base series, or the first category series that answered when "
+ "the base call failed; absent when it cannot be judged"
),
"in_progress": (
"the row is today's UTC day, which has not ended; its totals "
diff --git a/src/world_intel_mcp/tests/test_news_signals.py b/src/world_intel_mcp/tests/test_news_signals.py
index 632b6d2..e3cc2e5 100644
--- a/src/world_intel_mcp/tests/test_news_signals.py
+++ b/src/world_intel_mcp/tests/test_news_signals.py
@@ -250,6 +250,49 @@ async def test_hostility_timeline_failed_base_never_reports_zero_articles(
assert d16["tone"] == round(sum(_TONE[14:38]) / 24, 4)
+async def test_hostility_timeline_failed_base_still_flags_partial_days(fetcher, _fast) -> None:
+ # Live 2026-10-17 17:20Z: only the threat call answered, and its 10-15
+ # count (hours 10-23 only) carried no partial flag, because partial
+ # days were judged from the failed base series alone.
+ route, _ = _gdelt_router(fail={"articles"})
+ respx.get(url__regex=r".*api\.gdeltproject\.org.*").mock(side_effect=route)
+
+ r = await ns.fetch_hostility_timeline(fetcher, "Iran", "Israel", days=3, now=_NOW_GDELT)
+ days = {d["date"]: d for d in r["days"]}
+ assert days["2026-10-15"]["hostile"]["threat"] == sum(v // 5 for v, _ in _BASE[:14])
+ assert days["2026-10-15"]["partial"] is True
+ assert days["2026-10-15"]["hours_missing"] == [f"{h:02d}" for h in range(10)]
+ assert days["2026-10-16"]["partial"] is False
+ assert {d: v["buckets_returned"] for d, v in days.items()} == {
+ "2026-10-15": 14,
+ "2026-10-16": 24,
+ "2026-10-17": 16,
+ }
+ assert any("judged from the threat series" in g for g in r["data_gaps"])
+
+
+async def test_hostility_timeline_tone_only_leaves_partial_days_unjudged(fetcher, _fast) -> None:
+ # Volume calls answer 200 without a timeline (a failed call that does
+ # not trip the breaker, so the tone call still runs).
+ route, _ = _gdelt_router()
+
+ def _volume_malformed(request: httpx.Request) -> httpx.Response:
+ if request.url.params["mode"] == "timelinevolraw":
+ return httpx.Response(200, json={"query_details": {"date_resolution": "hour"}})
+ return route(request)
+
+ respx.get(url__regex=r".*api\.gdeltproject\.org.*").mock(side_effect=_volume_malformed)
+
+ r = await ns.fetch_hostility_timeline(fetcher, "Iran", "Israel", days=3, now=_NOW_GDELT)
+ assert r["degraded"] is True
+ assert all("partial" not in d and d["buckets_returned"] is None for d in r["days"])
+ tone = {d["date"]: d["tone"] for d in r["days"]}
+ assert tone["2026-10-16"] == round(sum(_TONE[14:38]) / 24, 4)
+ assert any("partial days are not flagged" in g for g in r["data_gaps"])
+
+
@respx.mock
async def test_hostility_timeline_unknown_resolution_is_disclosed(fetcher, _fast) -> None:
payload = _volraw("Iran", [v for v, _ in _BASE])