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.
Python ai-toolsai-watchanthropicclaudecybersecuritydashboardgeofencinggeopoliticalgeospatialintelligencemarketsmcpmigrationmilitarymodel-context-protocolnuclearosintreal-timespace-weatherthreat-intelligence
ACLED and unrest: put limit in the cache key
Phoenix Agent (mac-studio)0cf7a6ecac16
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 82c0b32..00db472 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -283,6 +283,10 @@ source here, and no proxy is substituted for any of these measures.reading. The brief now says "Kp unavailable (no reading)" and`metrics_snapshot.kp_index` is null, and the digest lists "Space weather:no Kp reading" in `data_gaps`.+- `intel_acled_events` and `intel_unrest_events` keyed their cache on+ country and days only, so a short list cached for a small `limit` came+ back, for 15 minutes, to a call that asked for more rows, and a count+ below the limit then read as complete. `limit` is now part of both keys.### Added: tropical cyclone forecast tracks- `intel_cyclones` and `intel_jtwc_cyclones` take `include_forecast`diff --git a/src/world_intel_mcp/sources/conflict.py b/src/world_intel_mcp/sources/conflict.pyindex b05e99d..d618067 100644--- a/src/world_intel_mcp/sources/conflict.py+++ b/src/world_intel_mcp/sources/conflict.py@@ -172,7 +172,9 @@ async def fetch_acled_events(data = await acled_query(fetcher,params,- cache_key=f"conflict:acled:{cache_country}:{days}",+ # limit is part of the key: a cached short list must not answer a+ # call that asked for more rows.+ cache_key=f"conflict:acled:{cache_country}:{days}:{limit}",cache_ttl=900,)if data is None:diff --git a/src/world_intel_mcp/sources/intelligence.py b/src/world_intel_mcp/sources/intelligence.pyindex e440b8f..f885f41 100644--- a/src/world_intel_mcp/sources/intelligence.py+++ b/src/world_intel_mcp/sources/intelligence.py@@ -1242,7 +1242,7 @@ async def fetch_unrest_events(data = await acled_query(fetcher,params=params,- cache_key=f"intel:unrest:{cache_label}:{days}",+ cache_key=f"intel:unrest:{cache_label}:{days}:{limit}",cache_ttl=900,)diff --git a/src/world_intel_mcp/tests/test_sources.py b/src/world_intel_mcp/tests/test_sources.pyindex 37eec23..e2291e5 100644--- a/src/world_intel_mcp/tests/test_sources.py+++ b/src/world_intel_mcp/tests/test_sources.py@@ -818,6 +818,84 @@ async def test_fetch_acled_events_genuine_zero_has_no_error(assert result["count"] == 0+def _acled_pool_route(pool_size: int):+ """A respx side effect for the ACLED read endpoint that, like the real+ API, returns at most `limit` rows from a pool, and records each limit."""+ sent: list[int] = []++ def _answer(request: httpx.Request) -> httpx.Response:+ limit = int(request.url.params["limit"])+ sent.append(limit)+ rows = [+ {+ "event_id_cnty": f"SDN{i}",+ "event_date": "2026-10-01",+ "event_type": "Battles",+ "country": "Sudan",+ "latitude": str(10.0 + i),+ "longitude": str(30.0 + i),+ "fatalities": "1",+ }+ for i in range(min(limit, pool_size))+ ]+ return httpx.Response(200, json={"data": rows})++ return _answer, sent+++async def test_acled_events_cache_does_not_answer_a_larger_limit(+ fetcher: Fetcher, monkeypatch: pytest.MonkeyPatch+) -> None:+ """A short list cached for a small limit must not come back, inside the+ cache TTL, for a call that asked for more rows: a count below the limit+ would then read as a complete list."""+ from world_intel_mcp.sources import conflict++ async def _fake_token() -> str:+ return "fake-token"++ monkeypatch.setattr(conflict, "_acled_get_token", _fake_token)+ answer, sent = _acled_pool_route(5)+ with respx.mock(assert_all_called=False) as router:+ router.get(conflict._ACLED_API_URL).mock(side_effect=answer)+ small = await conflict.fetch_acled_events(+ fetcher, country="Sudan", days=60, limit=2+ )+ large = await conflict.fetch_acled_events(+ fetcher, country="Sudan", days=60, limit=1000+ )++ assert small["count"] == 2+ assert large["count"] == 5+ assert sent == [2, 1000]+++async def test_unrest_events_cache_does_not_answer_a_larger_limit(+ fetcher: Fetcher, monkeypatch: pytest.MonkeyPatch+) -> None:+ from world_intel_mcp.sources import conflict, intelligence++ async def _fake_token() -> str:+ return "fake-token"++ monkeypatch.setattr(conflict, "_acled_get_token", _fake_token)+ answer, sent = _acled_pool_route(5)+ with respx.mock(assert_all_called=False) as router:+ router.get(conflict._ACLED_API_URL).mock(side_effect=answer)+ small = await intelligence.fetch_unrest_events(+ fetcher, country="Sudan", days=60, limit=2+ )+ large = await intelligence.fetch_unrest_events(+ fetcher, country="Sudan", days=60, limit=1000+ )++ assert small["count"] + small["deduplicated"] == 2+ assert large["count"] + large["deduplicated"] == 5+ assert sent == [2, 1000]++# ---------------------------------------------------------------------------# News (GDELT search)# ---------------------------------------------------------------------------