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.

Dossier sanctions: screen the country, keep total_entities, mark a failed list

Phoenix Agent (mac-studio)221049a68dc3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9ece2f..73d2cae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -297,6 +297,14 @@ source here, and no proxy is substituted for any of these measures.
request refused or unreachable, every ACLED tool said the credentials
were not configured. That case now has its own reason,
`acled_auth_failed`, and the error says the sign-in failed.
+- The sanctions section of `intel_country_dossier` was always empty: it
+ searched entity names for the ISO-3 code and read a key the search does
+ not return, and a failed SDN download read as zero matches. It now lists
+ SDN entries whose remarks name the country (by English name), carries
+ `total_entities`, `country_searched`, `match_method` and `more_matches`,
+ and a failed download sets `match_count` to null with `error`,
+ `degraded`, reason `sdn_unavailable` and a `data_gaps` entry. `intel
+ dossier` prints "not screened" in that case.
### Added: tropical cyclone forecast tracks
- `intel_cyclones` and `intel_jtwc_cyclones` take `include_forecast`
diff --git a/src/world_intel_mcp/analysis/dossier.py b/src/world_intel_mcp/analysis/dossier.py
index ef2b584..5cac939 100644
--- a/src/world_intel_mcp/analysis/dossier.py
+++ b/src/world_intel_mcp/analysis/dossier.py
@@ -82,6 +82,30 @@ _ISO2_TO_ISO3: dict[str, str] = {
}
_ISO3_TO_ISO2: dict[str, str] = {v: k for k, v in _ISO2_TO_ISO3.items()}
+# English names for the codes above that are not tier-1 countries (those
+# carry their own name in TIER1_COUNTRIES). Used to screen the SDN list.
+_EXTRA_COUNTRY_NAMES: dict[str, str] = {
+ "ARG": "Argentina", "AUS": "Australia", "BEL": "Belgium", "BRA": "Brazil",
+ "CAN": "Canada", "CHE": "Switzerland", "CHL": "Chile", "COL": "Colombia",
+ "DEU": "Germany", "EGY": "Egypt", "ESP": "Spain", "FRA": "France",
+ "GBR": "United Kingdom", "IDN": "Indonesia", "ITA": "Italy", "JPN": "Japan",
+ "KOR": "Korea, South", "NLD": "Netherlands", "NOR": "Norway", "PER": "Peru",
+ "PHL": "Philippines", "POL": "Poland", "SAU": "Saudi Arabia", "SWE": "Sweden",
+ "THA": "Thailand", "TUR": "Turkey", "VNM": "Vietnam", "ZAF": "South Africa",
+}
+
+# Entries listed in the sanctions section.
+_SANCTIONS_LIMIT = 10
+
+_SANCTIONS_METHOD = (
+ "OFAC SDN entries whose remarks name the country (nationality, citizenship, "
+ "address, registration), substring match on the English country name. Not "
+ "an exposure screen: entries tied to the country in other ways are missed, "
+ "and a name inside another also matches (Niger in Nigeria, Sudan in South Sudan). "
+ "total_entities is the number of SDN rows read before the search stopped, "
+ "not the size of the list."
+)
+
def _normalize_country(code: str) -> tuple[str, str]:
"""Return (iso2, iso3) from either format. Raises ValueError if unknown."""
@@ -101,6 +125,12 @@ def _normalize_country(code: str) -> tuple[str, str]:
raise ValueError(f"Country code must be 2 or 3 characters: {code}")
+def _sanctions_country_name(iso3: str) -> str:
+ from ..config.countries import TIER1_COUNTRIES
+
+ return (TIER1_COUNTRIES.get(iso3) or {}).get("name") or _EXTRA_COUNTRY_NAMES[iso3]
+
+
async def _safe(coro, label: str) -> dict:
"""Run a coroutine, catching exceptions."""
try:
@@ -163,7 +193,12 @@ async def fetch_country_dossier(
_safe(fetch_country_brief(fetcher, country_code=iso2), "country_brief"),
_safe(fetch_country_stocks(fetcher, country=iso3), "country_stocks"),
_safe(fetch_election_calendar(fetcher, country=iso3), "elections"),
- _safe(fetch_sanctions_search(fetcher, query=iso3, limit=10), "sanctions"),
+ _safe(
+ fetch_sanctions_search(
+ fetcher, country=_sanctions_country_name(iso3), limit=_SANCTIONS_LIMIT + 1
+ ),
+ "sanctions",
+ ),
_safe(fetch_news_feed(fetcher, category=None, limit=200), "news_feed"),
)
@@ -217,14 +252,37 @@ async def fetch_country_dossier(
elections = {"_error": election_data["_error"]}
# --- Section 5: Sanctions ---
+ # Until 2026-10-17 this searched entity names for the ISO-3 code and read
+ # "results" (the producer emits "matches"), so the list was always empty,
+ # and a failed SDN download read as zero matches. One extra row is asked
+ # for so a cut-off list is known to be cut off.
sanctions = {}
- if "_error" not in sanctions_data:
+ if "_error" in sanctions_data:
sanctions = {
- "matches": sanctions_data.get("results", []),
- "match_count": sanctions_data.get("count", 0),
+ "_error": sanctions_data["_error"],
+ "match_count": None,
+ "data_gaps": [f"sanctions search failed: {sanctions_data['_error']}; not screened"],
+ }
+ elif not sanctions_data.get("total_entities"):
+ sanctions = {
+ "matches": [],
+ "match_count": None,
+ "total_entities": 0,
+ "error": "The OFAC SDN list could not be read",
+ "degraded": True,
+ "reason": "sdn_unavailable",
+ "data_gaps": ["OFAC SDN list could not be read; sanctions not screened, not zero"],
}
else:
- sanctions = {"_error": sanctions_data["_error"]}
+ found = sanctions_data.get("matches") or []
+ sanctions = {
+ "matches": found[:_SANCTIONS_LIMIT],
+ "match_count": min(len(found), _SANCTIONS_LIMIT),
+ "more_matches": len(found) > _SANCTIONS_LIMIT,
+ "total_entities": sanctions_data.get("total_entities"),
+ "country_searched": sanctions_data.get("query", {}).get("country"),
+ "match_method": _SANCTIONS_METHOD,
+ }
# --- Section 6: News ---
# Every RSS feed (category=None), headlines matched on the country's
diff --git a/src/world_intel_mcp/cli.py b/src/world_intel_mcp/cli.py
index 014649e..7921b6a 100644
--- a/src/world_intel_mcp/cli.py
+++ b/src/world_intel_mcp/cli.py
@@ -1784,7 +1784,10 @@ def dossier(ctx: click.Context, country: str) -> None:
# Sanctions
sanc = data.get("sanctions", {})
- if sanc.get("match_count", 0) > 0:
+ if "match_count" in sanc and sanc["match_count"] is None:
+ # A failed SDN download is not zero matches.
+ console.print("[red]Sanctions:[/red] not screened (SDN list unavailable)")
+ elif (sanc.get("match_count") or 0) > 0:
console.print(f"[red]Sanctions:[/red] {sanc['match_count']} OFAC matches")
# News
diff --git a/src/world_intel_mcp/guide_prompts.py b/src/world_intel_mcp/guide_prompts.py
index 111cc7f..8fa3853 100644
--- a/src/world_intel_mcp/guide_prompts.py
+++ b/src/world_intel_mcp/guide_prompts.py
@@ -1105,7 +1105,10 @@ PROMPTS: tuple[ResearchPrompt, ...] = (
Step(
"intel_country_dossier",
"economy, sanctions, news and conflict context. It knows only "
- "the 50 countries in its own table and returns an error for others",
+ "the 50 countries in its own table and returns an error for others. "
+ "Its sanctions section lists sanctions-list entries whose remarks name the "
+ "country, which is not an exposure screen; match_count null means "
+ "the sanctions list could not be read, not zero matches",
args=(("country", "{country}"),),
only_if="country",
),
@@ -1233,7 +1236,10 @@ PROMPTS: tuple[ResearchPrompt, ...] = (
Step(
"intel_country_dossier",
"economy, elections, sanctions, news and conflict. It knows only "
- "the 50 countries in its own table and returns an error for others",
+ "the 50 countries in its own table and returns an error for others. "
+ "Its sanctions section lists sanctions-list entries whose remarks name the "
+ "country, which is not an exposure screen; match_count null means "
+ "the sanctions list could not be read, not zero matches",
args=(("country", "{country}"),),
),
Step(
diff --git a/src/world_intel_mcp/tests/test_dossier_sanctions.py b/src/world_intel_mcp/tests/test_dossier_sanctions.py
new file mode 100644
index 0000000..2b354ab
--- /dev/null
+++ b/src/world_intel_mcp/tests/test_dossier_sanctions.py
@@ -0,0 +1,128 @@
+"""Tests for the country dossier's sanctions section (analysis/dossier.py).
+
+The section is driven through the real ``sources.sanctions`` search, with
+the OFAC SDN CSV served by respx. Until 2026-10-17 it searched entity names
+for the ISO-3 code (so Sudan's search was the letters "SDN"), read
+"results" where the producer emits "matches" (so the list was always
+empty), and a failed SDN download read as zero matches.
+
+Gaps / not covered: the rows are fixture values in the SDN CSV layout, not
+the live list, so how often real remarks name a country in the form the
+search uses is not measured here.
+"""
+
+import httpx
+import pytest
+import respx
+
+from world_intel_mcp.analysis import dossier
+from world_intel_mcp.sources import elections, intelligence, markets, news
+from world_intel_mcp.sources.sanctions import _OFAC_CSV_URL
+
+
+def _row(n: int, name: str, remarks: str) -> str:
+ # ent_num, SDN_Name, SDN_Type, Program, Title, Call_Sign, Vess_type,
+ # Tonnage, GRT, Vess_flag, Vess_owner, Remarks
+ return f'{n},"{name}","individual","SDGT",-0-,-0-,-0-,-0-,-0-,-0-,-0-,"{remarks}"'
+
+
+def _other_sections(monkeypatch: pytest.MonkeyPatch) -> None:
+ """Every section but sanctions, answered locally."""
+
+ async def _brief(*args, **kwargs) -> dict:
+ return {"supporting_data": {}, "brief": ""}
+
+ async def _stocks(*args, **kwargs) -> dict:
+ return {"error": "not under test"}
+
+ async def _elections(*args, **kwargs) -> dict:
+ return {"elections": []}
+
+ async def _news(*args, **kwargs) -> dict:
+ return {"items": []}
+
+ monkeypatch.setattr(intelligence, "fetch_country_brief", _brief)
+ monkeypatch.setattr(markets, "fetch_country_stocks", _stocks)
+ monkeypatch.setattr(elections, "fetch_election_calendar", _elections)
+ monkeypatch.setattr(news, "fetch_news_feed", _news)
+
+
+async def test_dossier_sanctions_screens_the_country_not_the_code(fetcher, _other_sections) -> None:
+ rows = [
+ _row(1, "AHMED, Ali", "nationality Sudan; DOB 1970"),
+ _row(2, "SDN TRADING CO", "Address Tehran, Iran"),
+ _row(3, "OMAR, Musa", "citizen Sudan"),
+ _row(4, "NILE HOLDINGS", "Organization Established Date 2001; Khartoum, Sudan"),
+ ]
+ respx.get(_OFAC_CSV_URL).mock(return_value=httpx.Response(200, text="\n".join(rows)))
+
+ section = (await dossier.fetch_country_dossier(fetcher, country="SD"))["sanctions"]
+
+ assert [m["name"] for m in section["matches"]] == ["AHMED, Ali", "OMAR, Musa", "NILE HOLDINGS"]
+ assert section["match_count"] == 3
+ assert section["more_matches"] is False
+ assert section["total_entities"] == 4
+ assert section["country_searched"] == "Sudan"
+ assert "Not an exposure screen" in section["match_method"]
+ assert "error" not in section
+
+
+async def test_dossier_sanctions_outage_is_a_gap_not_zero_matches(fetcher, _other_sections) -> None:
+ respx.get(_OFAC_CSV_URL).mock(return_value=httpx.Response(503))
+
+ section = (await dossier.fetch_country_dossier(fetcher, country="SDN"))["sanctions"]
+
+ assert section["match_count"] is None
+ assert section["total_entities"] == 0
+ assert (section["degraded"], section["reason"]) == (True, "sdn_unavailable")
+ assert section["error"] == "The OFAC SDN list could not be read"
+ assert section["data_gaps"] == [
+ "OFAC SDN list could not be read; sanctions not screened, not zero"
+ ]
+
+
+async def test_dossier_sanctions_says_when_the_list_was_cut_off(fetcher, _other_sections) -> None:
+ rows = [_row(n, f"PERSON {n}", "nationality Iran") for n in range(12)]
+ respx.get(_OFAC_CSV_URL).mock(return_value=httpx.Response(200, text="\n".join(rows)))
+
+ section = (await dossier.fetch_country_dossier(fetcher, country="IR"))["sanctions"]
+
+ assert section["match_count"] == 10
+ assert len(section["matches"]) == 10
+ assert section["more_matches"] is True
+ assert section["country_searched"] == "Iran"
+
+
+async def test_dossier_sanctions_uses_english_names_beyond_tier_1(fetcher, _other_sections) -> None:
+ rows = [_row(1, "BERLIN GMBH", "Address Berlin, Germany"), _row(2, "X", "nationality France")]
+ respx.get(_OFAC_CSV_URL).mock(return_value=httpx.Response(200, text="\n".join(rows)))
+
+ section = (await dossier.fetch_country_dossier(fetcher, country="DE"))["sanctions"]
+
+ assert section["country_searched"] == "Germany"
+ assert [m["name"] for m in section["matches"]] == ["BERLIN GMBH"]
+
+
+def test_cli_dossier_says_sanctions_were_not_screened(tmp_path, monkeypatch: pytest.MonkeyPatch) -> None:
+ from click.testing import CliRunner
+
+ from world_intel_mcp import cli
+
+ monkeypatch.setenv("WORLD_INTEL_CACHE_DB", str(tmp_path / "cli-cache.db"))
+ monkeypatch.setattr(cli, "_fetcher", None)
+
+ async def _dossier(*args, **kwargs) -> dict:
+ return {
+ "overview": {"country": "Sudan", "iso2": "SD", "iso3": "SDN"},
+ "sanctions": {"matches": [], "match_count": None, "total_entities": 0},
+ }
+
+ monkeypatch.setattr(dossier, "fetch_country_dossier", _dossier)
+ result = CliRunner().invoke(cli.main, ["dossier", "-c", "SD"], env={"COLUMNS": "200"})
+ assert result.exit_code == 0, result.output
+ assert "Sanctions: not screened (SDN list unavailable)" in result.output