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
Liquidity: only the portal's no-series detail makes an ECB 404 no-data
Phoenix Agent (mac-studio)4aaab0ad5ac0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5d436f7..8e5b1df 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -53,11 +53,12 @@ responses say so. `limit=0` returns the full history.`fetch_failure`, and name the failure in `data_gaps`: the HTTP status, noresponse, an open circuit or an unexpected payload. Each stale copy servedcounts in the circuit breaker's `total_stale_serves` (`intel_status`), and none- is re-cached as fresh. Only parsed bodies enter the cache. An ECB 404 whose- body is empty or a JSON object (the portal's problem answer) is a final- no-data answer, without outage retries; any other 404, such as an HTML or- plain-text error page, is retried, counted as a breaker failure and takes the- outage path. An empty ECB response is one only when a start was requested;+ is re-cached as fresh. Only parsed bodies enter the cache. An ECB 404 is a+ final no-data answer, without outage retries, only when its body is the+ portal's JSON problem answer whose detail starts "No Series was returned for+ the query"; any other 404, an empty body or an HTML or plain-text error page+ included, is retried, counted as a breaker failure and takes the outage path.+ An empty ECB response is one only when a start was requested;without one it is an unexpected payload and takes the outage path, as doesJSON that is not an object.Missing ECB roles and board rows are named; index bases, provisional statusdiff --git a/src/world_intel_mcp/sources/liquidity.py b/src/world_intel_mcp/sources/liquidity.pyindex f80a6ae..4557c5b 100644--- a/src/world_intel_mcp/sources/liquidity.py+++ b/src/world_intel_mcp/sources/liquidity.py@@ -813,22 +813,29 @@ def parse_sdmx_json(data: dict, dataset: str) -> list[dict]:_JSON_KINDS = {list: "array", str: "string", int: "number", float: "number", bool: "boolean", type(None): "null"}+# How the portal's answer to a key that matches no series opens its+# "detail" (application/problem+json, "title": "Not Found", "status": 404;+# every no-series 404 seen live on 2026-10-17).+_ECB_NO_SERIES_DETAIL = "No Series was returned for the query"++def _ecb_404_is_no_data(body: bytes) -> bool:"""Whether an ECB 404 is the portal's own answer to a key that matches- no series: an empty body or a JSON object (its problem+json, e.g.- "No Series was returned for the query"). A 404 with any other body- (an HTML or plain-text error page, JSON that is not an object) came- from something in front of the portal and takes the outage path.-- Residual risk: a JSON-object 404 from a moved gateway would still- read as no-data.+ no series: a JSON object whose "detail" starts with+ ``_ECB_NO_SERIES_DETAIL``. Any other 404 (an empty body, an HTML or+ plain-text error page, any other JSON) is not that answer and takes+ the outage path.++ Residual risk: if the portal rewords that detail, its real no-series+ answers take the outage path too (retried, counted as breaker+ failures, a marked stale copy served where one exists)."""- if not body.strip():- return Truetry:- return isinstance(json.loads(body), dict)+ doc = json.loads(body)except (ValueError, RecursionError): # UnicodeError is a ValueErrorreturn False+ detail = doc.get("detail") if isinstance(doc, dict) else None+ return isinstance(detail, str) and detail.startswith(_ECB_NO_SERIES_DETAIL)async def _ecb_fetch(diff --git a/src/world_intel_mcp/tests/test_liquidity_ecb_404.py b/src/world_intel_mcp/tests/test_liquidity_ecb_404.pyindex fc9599c..8942ebc 100644--- a/src/world_intel_mcp/tests/test_liquidity_ecb_404.py+++ b/src/world_intel_mcp/tests/test_liquidity_ecb_404.py@@ -1,16 +1,16 @@-"""ECB 404s: the portal's own "no series" answer versus an error page.+"""ECB 404s: the portal's own "no series" answer versus everything else.The ECB Data Portal answers a key that matches no series with a 404-whose body is empty or a JSON problem object; that stays a final-no-data answer (not retried, not a breaker failure, no stale copy). A-404 with any other body (an HTML or plain-text error page, JSON that is-not an object) came from something in front of the portal: it is+whose body is a JSON problem object with a "detail" that starts "No+Series was returned for the query"; only that stays a final no-data+answer (not retried, not a breaker failure, no stale copy). Any other+404 (an empty body, an HTML or plain-text error page, other JSON) isretried per the fetcher's rules, counted as a breaker failure, and thelast good copy is served marked, with the failure named in data_gaps.Gaps / not covered: live ECB responses (fixtures and respx only). The-residual risk stays: a JSON-object 404 from a moved gateway still reads-as no-data.+residual risk: if the portal rewords that detail, its real no-series+answers take the outage path."""import time@@ -41,6 +41,13 @@ _ERROR_PAGES = [pytest.param(httpx.Response(404, text=_HTML_404, headers={"content-type": "text/html"}), id="html"),pytest.param(httpx.Response(404, text="Not Found", headers={"content-type": "text/plain"}), id="plain-text"),pytest.param(httpx.Response(404, content=b"[]", headers={"content-type": "application/json"}), id="json-array"),+ pytest.param(httpx.Response(404, content=b""), id="empty"),+ pytest.param(httpx.Response(404, content=b"\r\n"), id="crlf"),+ pytest.param(httpx.Response(404, content=b'{"title":"No results"}', headers={"content-type": "application/json"}),+ id="json-object-without-detail"),+ pytest.param(httpx.Response(404, content=b'{"title":"Not Found","status":404,"detail":"No results found."}',+ headers={"content-type": "application/problem+json"}),+ id="problem-json-other-detail"),]@@ -76,6 +83,7 @@ async def test_error_page_404_on_the_board_serves_the_marked_stale_copy(fetcher,await liquidity.fetch_liquidity_board(fetcher)_age(fetcher, 7200)before = [fetcher.cache.get_stale_meta(k) for k in _BOARD_KEYS]+ assert None not in before # the keys name the board's copies, so the restamp check below is not vacuousfetcher.max_retries = 2bsi = respx.get(_ECB_BSI_URL).mock(return_value=response)ilm = respx.get(_ECB_ILM_URL).mock(return_value=response)@@ -174,3 +182,37 @@ def test_changelog_states_the_ecb_404_rule():"page, is retried, counted as a breaker failure and takes the outage path.") in textassert "ECB 404 responses are final no-data answers" not in text++[email protected]("body, no_data", [+ pytest.param(_ECB_404.encode(), True, id="live-problem-json"),+ pytest.param(b'{"detail":"No Series was returned for the query"}', True, id="detail-is-the-prefix"),+ pytest.param(b"", False, id="empty"),+ pytest.param(b" \n", False, id="whitespace"),+ pytest.param(b"\r\n", False, id="crlf"),+ pytest.param(b"{}", False, id="empty-object"),+ pytest.param(b'{"title":"No results"}', False, id="object-without-detail"),+ pytest.param(b'{"title":"Not Found","status":404,"detail":"No results found."}', False,+ id="unknown-dataflow-detail"),+ pytest.param(b'{"detail":"Error: No Series was returned for the query"}', False, id="prefix-not-at-start"),+ pytest.param(b'{"detail":"no series was returned for the query"}', False, id="prefix-in-lower-case"),+ pytest.param(b'{"detail":["No Series was returned for the query"]}', False, id="detail-not-a-string"),+ pytest.param(b'["No Series was returned for the query"]', False, id="json-array"),+ pytest.param(b'"No Series was returned for the query"', False, id="json-string"),+ pytest.param(b"No Series was returned for the query", False, id="plain-text"),+ pytest.param(b"[" * 100_000, False, id="nesting-past-recursion-limit"),+])+def test_ecb_404_is_no_data_only_for_the_portal_no_series_detail(body, no_data):+ assert liquidity._ecb_404_is_no_data(body) is no_data+++def test_changelog_states_the_strict_ecb_404_rule():+ text = " ".join((Path(__file__).parents[3] / "CHANGELOG.md").read_text().split())+ assert (+ "An ECB 404 is a final no-data answer, without outage retries, only when its body is the "+ "portal's JSON problem answer whose detail starts \"No Series was returned for the query\"; "+ "any other 404, an empty body or an HTML or plain-text error page included, is retried, "+ "counted as a breaker failure and takes the outage path."+ ) in text+ assert "whose body is empty or a JSON object" not in text+ assert liquidity._ECB_NO_SERIES_DETAIL == "No Series was returned for the query"